WSL: AT_SECURE not set to 1 for SUID programs
-
Your Windows build number:
[Version 10.0.15063] -
What you’re doing and what’s happening: The
AT_SECUREauxiliary vector entry is not set to 1 when running a SUID program:$ LD_SHOW_AUXV=1 /bin/su AT_SYSINFO_EHDR: 0x7ffff284f000 AT_HWCAP: 1f8bfbff AT_PAGESZ: 4096 AT_CLKTCK: 100 AT_PHDR: 0x400040 AT_PHENT: 56 AT_PHNUM: 9 AT_BASE: 0x7fda1ba00000 AT_FLAGS: 0x0 AT_ENTRY: 0x4033e5 AT_UID: 1000 AT_EUID: 0 AT_GID: 1000 AT_EGID: 1000 AT_SECURE: 0 AT_RANDOM: 0x7ffff21d8500 AT_EXECFN: /bin/su AT_PLATFORM: x86_64 Password: -
What’s wrong / what should be happening instead: Only
Password:should be printed because ifAT_SECUREis 1, the glibc dynamic linker will ignore mostLD_environment variables because they can be abused for privilege escalation. -
Strace of the failing command, if applicable: This bug occurs before the process starts running, so
straceis not applicable.
LD_SHOW_AUXV, as shown in the example, is comparatively harmless (it only leaks load addresses, defeating ASLR), but LD_PRELOAD is not ignored either, and that allows code execution as root. Fixing AT_SECURE will address all these issues at the same time (including the non-working secure_getenv, whose failing test in the glibc testsuite brought the issue to my attention).
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 15 (4 by maintainers)
Another possibly useful test suite:
I’m getting 20 failures on native Xenial and 105 failures on Xenial @ WSL build 16232. None of the native failures pass on WSL. Many failures are probably the same issues as in the glibc test suite.
@therealkenc, the auxiliary vector is supplied as part of the original process image and a pointer to it is passed to the startup code. It’s not obtained using a system call or anything that would be visible in
strace. Furthermore, the interaction ofstraceand SUID programs is complex and actually makes the bug harder to see.@benhillis @therealkenc Please configure glibc with
--prefix=/usr, otherwise the built glibc isn’t ABI-compliant with the real thing. See here for more details:Known test failures are documented on the release pages:
The math failures you see are likely due to broken
long doublesupport (issue #830).Stats for
glibc-2.23on Xenial, FWIW:[edited: with proper --prefix=/usr, my run, YRMV]
16237:
Native:
There’s known stuff in there, but also a few nuggets. Interestingly WSL passes some tests that Native fails (🤷). In the other direction, here is the short list. You can see the
tst-secure-getenvin there. Those nptl (native posix thread library) fails could explain some stuff. Maybe.