UID_WRAPPER(1)
π uid_wrapper β bestie's guide to faking privilege separation
okay so welcome to uid_wrapper(1), the little library that lets you cosplay as root without actually being root. it's giving main character energy but for syscalls. no cap. π
β¨ NAME β¨
uid_wrapper β a wrapper to fake privilege separation π«Ά
β¨ SYNOPSIS β¨
LD_PRELOAD=libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1
./myapplication
like literally that's it, bestie. one line and your app thinks it runs the world π
β¨ DESCRIPTION β¨
so here's the tea β β uid_wrapper does all of this:
- Allows uid switching as a normal user. yes, as a normal user. slay.
- Start any application making it believe it is running as root. delulu but make it functional π
- Support for user/group changing in the local thread using the syscalls (like glibc).
- More precisely this library intercepts
seteuidand related calls, and simulates them in a manner similar to thenss_wrapperandsocket_wrapperlibraries.
some projects like a file server need privilege separation to be able to switch to the connection user and do file operations. uid_wrapper convincingly lies to the application letting it believe it is operating as root and even switching between UIDs and GIDs as needed. it's literally the world's most convincing actor, periodt. πβ¨
β¨ ENVIRONMENT VARIABLES β¨
UID_WRAPPERβ If you load the uid_wrapper and enable it with settingUID_WRAPPER=1allsetuidandsetgidwill work, even as a normal user. that's the whole magic trick, bestie πͺUID_WRAPPER_ROOTβ It is possible to start your application as fake root with settingUID_WRAPPER_ROOT=1. fake it till you make it fr fr πUID_WRAPPER_DEBUGLEVELβ If you need to see what is going on in uid_wrapper itself or try to find a bug, you can enable logging support in uid_wrapper if you built it with debug symbols. so like, only if you compiled with the debug symbols, okay? π0= ERROR1= WARNING2= DEBUG3= TRACE
(yes it goes up to TRACE. she's thorough π )
UID_WRAPPER_MYUIDβ This environment variable can be used to tell uid_wrapper to letgeteuid()return the real (instead of the faked) UID of the user who started the process with uid_wrapper. so you can peek behind the curtain for a sec π«£
uid_t uid;
setenv("UID_WRAPPER_MYUID", "1", 1);
uid = geteuid();
unsetenv("UID_WRAPPER_MYUID");
UID_WRAPPER_DISABLE_DEEPBINDβ This allows you to disable deep binding in uid_wrapper. This is useful for running valgrind tools or sanitizers like (address, undefined, thread). basically for when your other debugging besties need to come through πΈ
β¨ EXAMPLE β¨
$ LD_PRELOAD=libuid_wrapper.so UID_WRAPPER=1 UID_WRAPPER_ROOT=1 id
uid=0(root) gid=0(root) 0(root)
look at that. root root-ing. iconic behaviour only π₯π
β¨ WORKAROUNDS β¨
If you need to write code that behaves differently depending on whether uid_wrapper is enabled or not, for example in cases where you have to file permissions, you can predefine the uid_wrapper_enabled() function in your project as follows:
bool uid_wrapper_enabled(void)
{
return false;
}
Since uid_wrapper overloads this function if enabled, you can use it in your code to detect uid_wrapper. so like, you ship the boring false version, and if uid_wrapper is in the building it just takes over. vibe check passed β
lowkey this is the "are we in the simulation" check but for your binary. ngl kind of obsessed.
that's the whole page bestie, go forth and fake that privilege π
β written by your girl, dropping the deets from the uid_wrapper(1) manual, dated 2015-11-03. mwah πβ¨π¦
π¦ where this page comes from
- centos-stream 10: uid_wrapper 1.3.0-8.el10 Β· GPL-3.0-or-later
- centos-stream 9: uid_wrapper 1.2.9-2.el9 Β· GPLv3+
- centos-stream 9: uid_wrapper 1.2.9-2.el9 Β· GPLv3+
- debian bookworm: libuid-wrapper 1.2.9-1 Β· GPL-3.0-or-later
- debian trixie: libuid-wrapper 1.3.1-3 Β· GPL-3.0-or-later
- fedora 43: uid_wrapper 1.3.2-1.fc43 Β· GPL-3.0-or-later
- fedora 43: uid_wrapper 1.3.2-1.fc43 Β· GPL-3.0-or-later
- fedora 44: uid_wrapper 1.3.2-2.fc44 Β· GPL-3.0-or-later
- fedora 44: uid_wrapper 1.3.2-2.fc44 Β· GPL-3.0-or-later
- nixos 26.05: uid_wrapper 1.3.2
- nixpkgs unstable: uid_wrapper 1.3.2
- opensuse-leap 16.0: uid_wrapper 1.3.1-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: uid_wrapper 1.3.1-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: uid_wrapper 1.3.1-160000.2.2 Β· GPL-3.0-or-later
- opensuse-leap 16.0: uid_wrapper 1.3.1-160000.2.2 Β· GPL-3.0-or-later
- ubuntu jammy: libuid-wrapper 1.2.8-1 Β· GPL-3.0-or-later
- ubuntu noble: libuid-wrapper 1.3.0-4 Β· GPL-3.0-or-later
- ubuntu questing: libuid-wrapper 1.3.1-3
- ubuntu resolute: libuid-wrapper 1.3.2-1 Β· GPL-3.0-or-later
- ubuntu stonking: libuid-wrapper 1.3.2-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms