Repository navigation
Drop real UID/GID too so GTK's bwrap image loaders can run (#1310) - #1338
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
drop_privs() only changed the effective IDs, leaving the process at ruid=0/euid=65534. Children inherit that mixed state and bubblewrap treats it as a setuid invocation and refuses to start, so glycin's sandboxed image loaders exit with status 1 and GTK aborts in ensure_surface_for_gicon(). Use setresuid()/setresgid() where available to set the real and effective IDs to the unprivileged user while keeping the saved set-user-ID at 0, so regain_privs() (redirect commands, atexit restore of ip_forward) keeps working. Platforms without setresuid() keep the old seteuid()/setegid() behaviour. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This branch has not been deployed
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.
Summary
Second half of #1310, on top of the
SIGCHLDfix in #1315 (the two are independent and can merge in either order).drop_privs()only changed the effective IDs, so after "Accept" in the GTK setup screen ettercap runs asruid=0 / euid=65534. Every child inherits that mixed state. bubblewrap treatsruid != euidas a setuid invocation and refuses to start (setuid use of bubblewrap is not supported, orUnexpected setuid user 65534, should be 0on older bwrap). As a result glycin's sandboxed image loader exits with status 1 and GTK aborts inensure_surface_for_gicon(). This is theLoader process exited early with status '1'crash that @koeppea reproduced on Kali.Fix: when
setresuid()is available, also set the real IDs and keep only the saved set-user-ID as root:After the drop:
Uid: 65534 65534 0 65534.exec()resets the saved ID to the effective one, so children (bwrap, glycin) run fully as nobody.regain_privs()still works because the saved UID is 0. It also now restoresruid=0, so thegetuid()checks inrestore_ip_forward()/restore_ipv6_forward()still pass.Other changes:
HAVE_SETRESUIDis detected viacheck_function_exists. Platforms without it (macOS) keep the oldseteuid()/setegid()path. bwrap only exists on Linux anyway.include/ec.h:<unistd.h>is now included while_GNU_SOURCE/__USE_GNUare still defined. Without that, glibc doesn't declaresetresuid()/setresgid().remote_browserplugin'sgetuid() == 0branch no longer runs after the drop. Itssetuid(1000)already failed with EPERM there (euid was 65534), so the browser ran as nobody in practice anyway.How to reproduce / test (Debian testing, no Kali needed)
Deterministic bwrap check (from @0x03c1):
End-to-end GUI: I used a
debian:testingcontainer (--privilegedso bwrap can create user namespaces) withglycin-loaders 2.x,bubblewrap,libgtk-3-dev, Xvfb and xdotool. GTK3 build,ettercap -Gas root. Steps: click Accept (this is where privileges are dropped), leave the GUI idle for 90 s so glycin tears down its loaders, then open the header-bar menus so new icons have to be loaded.0 65534 0 65534Gtk:ERROR ... gtkiconhelper.c:495 ... image-missing.svg: Loader process exited early65534 65534 0 6553465534 65534 0 65534Also checked
ettercap -Twithip_forward=1: it reads0while ettercap runs and is back to1after SIGTERM. That confirms theregain_privs()atexit path still works with the new IDs.Link to Devin session: https://app.devin.ai/sessions/ea7a02d2d699413da9dfa2d8482944bf
Open in Devin Desktop: https://app.devin.ai/desktop/session/ea7a02d2d699413da9dfa2d8482944bf?variant=devin
Requested by: @eaescob