4 ms·
> There's a capability baked into the entire system named 'setuid' which allows certain binaries run by a user to access things as if they were root. It's actu
by cesarb 2y ago
> There's a capability baked into the entire system named 'setuid' which allows certain binaries run by a user to access things as if they were root.
It's actually "to access things as if they were the owner of the binary" (which usually is root, but that's not required).
The problem with that, is that other than the uid, the program inherits everything like a normal program. Environment variables, current directory, open file descriptors, and so on. If the program (and the dynamic linker it uses, and any library it uses including the C standard library) is not very careful, it can be tricked through these inherited things to do unexpected actions while being able to access things as if they were root (or whoever the owner of the binary is). For instance, some environment variables tell the dynamic linker to load extra libraries, or to change from where it loads libraries; these have to be ignored when running as a setuid process.