4 ms·
Here's a shorter summary of the vulnerability: for (n = 1; n < (guint) argc; n++) Usually, after that loop, n equals argc (or could be less than argc if t
by josephcsible 5y ago
Here's a shorter summary of the vulnerability:
for (n = 1; n < (guint) argc; n++)
Usually, after that loop, n equals argc (or could be less than argc if the loop breaks or something). But if argc is 0, then n will equal 1 after. Later on, the program writes to argv[n]. If argc is 0, then argv[n] is argv[1], which is out-of-bounds, but happens to refer to the same place as envp[0] (at least on Linux). This lets the attacker set an arbitrary environment variable, after ld.so(8) already sanitized the environment. In particular, setting the GCONV_PATH environment variable (which is one that would have been removed during sanitization) will cause pkexec to load and execute code from a .so file in an attacker-controlled directory.
- tptacek 5y agoIt is a truly excellent vulnerability that hits a weird POSIX corner case, coupled with a fairly subtle coding error.
- likpok 5y agoHow does this exploit avoid environment sanitization? Is that because most environment sanitization (e.g. clearenv) adjusts the pointer rather than the memory, and argv[argc + 1] is the original environment location?
- lilyball 5y agoIt's because this environment manipulation occurs after ld.so sanitized the environment, and there are opportunities to then trigger behavior based on the environment before pkexec re-sanitizes it. The GCONV_PATH variable in particular makes it load shared code when attempting to log an error.
- josephcsible 5y agoBecause the code that gets exploited to set the environment variable runs after sanitization has already finished, and no further sanitization happens between then and when it gets read.