Add POS36-C runtime safety check to setuid and security documentation#817
Open
mcepl wants to merge 4 commits intoluvit:masterfrom
Open
Add POS36-C runtime safety check to setuid and security documentation#817mcepl wants to merge 4 commits intoluvit:masterfrom
mcepl wants to merge 4 commits intoluvit:masterfrom
Conversation
Expose POSIX getgroups(), setgroups(), and initgroups() as Lua-callable functions (Unix-only). These are needed to properly manage supplementary group IDs when dropping privileges, addressing the security concern raised in issue luvit#341 (CERT POS36-C). New functions: - uv.getgroups(): returns table of supplementary group IDs - uv.setgroups(groups): sets supplementary group IDs from a table - uv.initgroups(user, group): sets groups from the group database References: luvit#341
Add a runtime check in luv_setuid() that prevents dropping from root
(euid 0) to an unprivileged user while supplementary groups are still
set. This addresses the CERT POS36-C vulnerability where setuid()
alone does not revoke supplementary group privileges.
The check returns an error instructing users to call uv.setgroups({})
or uv.initgroups() before uv.setuid(). Non-root callers and
root-to-root transitions are unaffected.
Also adds security warnings to setuid/setgid documentation in all
three doc files (docs.md, docs.lua, meta.lua) explaining the correct
privilege-dropping order.
See: https://wiki.sei.cmu.edu/confluence/display/c/POS36-C
Fixes: luvit#341
Member
|
|
Contributor
Author
So, they shouldn't be in git at all? |
Contributor
|
Where else would they be 😆 |
Bilal2453
reviewed
Mar 18, 2026
Bilal2453
reviewed
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a runtime check in
luv_setuid()that prevents dropping from root (euid 0) to an unprivileged user while supplementary groups are still set. This addresses the CERT POS36-C vulnerability wheresetuid()alone does not revoke supplementary group privileges.The check returns an error instructing users to call
uv.setgroups({})oruv.initgroups()beforeuv.setuid(). Non-root callers androot-to-root transitions are unaffected.
Also adds security warnings to
setuid/setgiddocumentation in allthree doc files (
docs.md,docs.lua,meta.lua) explaining the correctprivilege-dropping order.
See: https://wiki.sei.cmu.edu/confluence/display/c/POS36-C
Fixes: #341