Skip to content

Proper handling of supplementary groups? #1055

@musicinmybrain

Description

@musicinmybrain

I was looking at a review request for a quickjs-ng package in Fedora, and I noticed the following message from rpmlint:

quickjs-ng.x86_64: E: missing-call-to-setgroups-before-setuid /usr/bin/qjs
This executable is calling setuid and setgid without setgroups or initgroups.
This means it didn't relinquish all groups, and this would be a potential
security issue.

The code in question is in js_os_exec

quickjs/quickjs-libc.c

Lines 3225 to 3227 in 3c9afc9

/* exec(args[, options]) -> exitcode */
static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)

and the call to setuid is at

quickjs/quickjs-libc.c

Lines 3377 to 3380 in 3c9afc9

if (uid != -1) {
if (setuid(uid) < 0)
_exit(127);
}

Now, it’s certainly true in general that failing to relinquish supplementary groups can entirely subvert an attempt to drop privileges. Imagine, for example, the case where a wheel or admin group is among the supplementary groups.

However, I don’t have the time or interest to fully audit the privilege-dropping code here – particularly, to read enough code to understand the surrounding context and security model – so I’m just reporting this as a possible issue that I think merits investigation and consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions