Repository navigation
Invoke initgroups() iff we got enough privileges (#11869) - #11872
Conversation
maskit
left a comment
There was a problem hiding this comment.
The change is necessary for 9.2.x, which uses traffic_manager. I don't think we need this for 10.x but it's probably nice to keep the code consistent.
cmcfarlen
left a comment
There was a problem hiding this comment.
This should check for superuser, right?
| // Always repopulate the supplementary group list for the new user. | ||
| if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) { | ||
| Fatal("switching to user %s, failed to initialize supplementary groups ID %ld", pwd->pw_name, (long)pwd->pw_gid); | ||
| if (geteuid() != 0) { // check that we have enough rights to call initgroups() |
There was a problem hiding this comment.
This should be geteuid() == 0?
There was a problem hiding this comment.
😅 you're totally right, fixed :)
ea7f164 to
6317684
Compare
|
|
|
My bad, I got mixed up with a separate workaround I had for #11869. |
| if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) { | ||
| Fatal("switching to user %s, failed to initialize supplementary groups ID %ld", pwd->pw_name, (long)pwd->pw_gid); | ||
| if (geteuid() == 0) { // check that we have enough rights to call initgroups() | ||
| if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) { |
There was a problem hiding this comment.
I think initgroups() should be called at the end of impersonate() too so that the supplementary groups would be repopulated when elevating privileges instead of dropping them.
There was a problem hiding this comment.
that would require to add CAP_SETGID to RestrictCapabilities()? maybe it's worth moving this discussion to another PR/issue and solve #11869 with this one
|
@jvgutierrez if you are happy with this can you merge it so then I can pick it back for a 9.2.x release tomorrow? Thanks |
|
cherry picked to 9.2.x |
|
Cherry-picked to v10.0.x |
The patches have beem merged into one. Reviewed-By: Daniel Leidert <[email protected]> Origin: apache/trafficserver#11855 Origin: apache/trafficserver#11872 Bug: GHSA-6j2p-q7p9-hmxw Bug-Debian: https://bugs.debian.org/1087531 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-50306 Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2024-50306 Gbp-Pq: Name CVE-2024-50306.patch
The patches have beem merged into one. Reviewed-By: Daniel Leidert <[email protected]> Origin: apache/trafficserver#11855 Origin: apache/trafficserver#11872 Bug: GHSA-6j2p-q7p9-hmxw Bug-Debian: https://bugs.debian.org/1087531 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-50306 Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2024-50306 Gbp-Pq: Name CVE-2024-50306.patch
Follow up of #11855, that rendered unusable ATS as root when spawned via traffic_manager. As mentioned on #11869, traffic_manager drops privileges when spawned as root and as consequence by the time that traffic_server attempts to call initgroups() it gets an EPERM error.
Fixes #11869