Program that runs with one set of permissions and accepts input from somone with different (especially lesser) permissions
For many command line interpreters (“shell”) of Unix operating systems, the internal field separator (abbreviated IFS) refers to a variable which defines the character or characters used to separate a pattern into tokens for some operations.
PATH
ENV
: a file to execute on startupLD_LIBRARY_PATH
: The search path for shared librariesLD_PRELOAD
: Extra modules loaded at runtimeopen()
system call allocates the first available file descriptor
, starting from 0.
Suppose you close fd 1, then invoke a setUID program that will open some sensitive file for output.
Anything it prints to
stdout
will overwrite that file.Similar tricks for
fd0
.
Method 1
: client opens the file and passes the open file descriptorMethod 2
: client sends access right the severA file descriptor is a form of capability, but can't be used over a network.
http://example.com/../../../etc/passwd
http://example.com/a/b/../../etc/passwd
mktemp()
is vulnerable to race-conditionmkstemp()
or mktemp()
with the O CREAT | O EXCL
flags to open()BAD
: A setUID program can give up and then regain its setUID status: save_uid = geteuid();
seteuid(getuid());
fd = open(file, O_RDONLY);
seteuid(save_uid);
GOOD
: run unprivileged most of the time, but assume
setUID status only when doing privileged operations