The poisoned NUL byte, 2014 edition
googleprojectzero.blogspot.com
googleprojectzero.blogspot.com
The summary states,
> disclosed a glibc NUL byte off-by-one overwrite into the heap.
> a full exploit (with comments) for a local Linux privilege escalation.
Normally, I wouldn't see how such a bug could lead to privilege escalation. (glibc runs in userspace, after all.) But it is glibc, and glibc is everywhere.
I think the key is in the source code, where they state,
// It actually relies on a pkexec bug: a memory leak when multiple -u arguments are specified.
pkexec is setuid, so if it has a bug, then it's a great target for privilege escalation. Is the exploit the fact that they're passing bogus arguments to pkexec in such a way as to trigger this bug, corrupt the heap, and cause pkexec to either execute a binary of their choice or execute arbitrary code?> Why the 32-bit edition? I’m not going to lie: I wanted to give myself a break. I was expecting this to be pretty hard so going after the problem in the 32-bit space gives us just a few more options in our trusty exploitation toolkit.
https://web.archive.org/web/20080430162146/http://www.matasa...
(The original post on the matasano.com server seems to have been eaten; any chance that could be resurrected, tptacek?)
It seems very much like asking for trouble - I can't offhand think of a good reason why this would be required.
I'm sure there are plenty of programs that have similar memory leaks with commandline args, as many authors might, not unreasonably, think that abuse would be prevented by the shell ARG_MAX, which is 2621440 bytes on many systems. Perhaps some sort of adjustable lower limit might be appropriate here.
For another, notice that one of the features they used in this exploit was similar "adjustable lower limits"; changing ulimit values to defeat most of the value that ASLR provides.
In general, I think that using safer languages, like Rust, Go, Java, or even modern C++, is more likely to be the answer than imposing new arbitrary limits. These kinds of buffer overruns, failures to remember to free memory, and so on are all too common in C, and can be avoided if you just use safer languages and constructs that do bounds checking and automatic memory management.
That was changed some years ago: https://lkml.org/lkml/2007/8/19/44
$ for i in {1..99999}; do touch "this is a really long filename so lets see what bash does or does not will it fail or will it work"$i; done
$ rm *
bash: /usr/bin/rm: Argument list too longThe 15 million craziness only applies to cases where you're calling executables in ways that don't go through the shell, such as execve().
Is there a non-distro-breaking way to use PaX short of running hardened gentoo?