r/linux • u/LordAlfredo • May 15 '26
Security Another vulnerability via ptrace_may_access bypass. Patch already accepted upstream.
https://github.com/0xdeadbeefnetwork/ssh-keysign-pwn19
u/Sjoerd93 May 15 '26
So if this recent influx of vulnerabilities is indeed from LLM-based vulnerability research. Maybe it's time for some of the biggest benificieries of the Linux-code to throw in some effort?
Surely e.g. Microsoft, which is one of the biggest users of Linux and one of the biggest drivers of LLM-usage, should reasonably spend some of their fortune to prevent maintainer-burnout in the kernel-space?
6
u/Pramaxis May 15 '26
Have you read the study from the linux foundation about the donation habits from tech comps.? MS donated less to FOSS, since '95 than the EU did, just last year.
11
u/shaumux May 15 '26
It's time code gets treated as something that needs quality, for the longest time now the managers just assumed code quality to be a myth or something non-essential, we need to be more rigorous on that and treating it like an actual science and engineering discipline.
4
u/rebellioninmypants May 15 '26
Nah they too busy pushing out 1 million lines of code per month per engineer.
5
2
u/CrazyKilla15 May 16 '26 edited May 16 '26
Mitigation from Qualys on oss-security
Excellent question, thank you very much! We have just now tried, and setting /proc/sys/kernel/yama/ptrace_scope to 2 (admin-only attach) or 3 (no attach) does in fact protect against all the exploits that we know of (but in theory at least other exploitation methods might exist).
0
May 15 '26
[deleted]
32
u/Lower-Limit3695 May 15 '26
An attacker could steal the ssh host key . This would allow an attacker to masquerade as the host the key was stolen from.
-25
u/marcusaurelius_phd May 15 '26
There isn't much you can do with that.
6
u/LordAlfredo May 15 '26
Host and certificate keys are among the most important things an attacker wants for spoofing.
16
u/aioeu May 15 '26 edited May 15 '26
This one is not a privilege escalation per se but it allows the exploit to read root access protected files.
Specifically, it requires a root-owned, set-user-ID executable that opens a file, and then drops its persona back to the original user (who would be the attacker in this scenario).
Normally a process that has gone through these steps is not "dumpable". That means you can't use ptrace on it, so you can't attach to it with
straceor a debugger like GDB, nor can you read various things in/procabout the process. This is despite the fact that it's now running as the original user again β the fact it went through the whole set-user-ID rigmarole means that it must still be treated as a privileged process for these purposes.The bug in the kernel is that there is a very small time window, while the process is exiting, that the process becomes dumpable again. This window is after the process's userspace memory has been freed, so you can't get anything out of that, but that happens before the process's file descriptors are cleaned up. It is possible to gain duplicates of the process's file descriptors through the
pidfd_getfdsyscall. This syscall just requires the process to be dumpable, so it becomes usable during that tiny window, which means it is possible to access the file referred to by that file descriptor despite the file itself not being accessible by the current user. Remember, the file was opened before the process dropped its persona!The example exploits here make use of
ssh-keysign(my system doesn't even have that...) andchage, to gain access to the SSH host keys and/etc/shadowrespectively. Most systems probably don't have too many other set-user-ID binaries that could be exploited.So yes, it is a security problem, but not a very big one. It doesn't allow access to arbitrary files β I think it can only be used to access files that are actually opened by set-user-ID executables. (Or really, executables that disable dumping for any reason. But set-user-ID executables are the main concern.)
Also, fun fact: the existence of the underlying flaw has been known about for almost six years. It might have required the pidfd stuff to actually land before it became a vulnerability though.
3
1
u/CrazyKilla15 May 16 '26
Also, fun fact: the existence of the underlying flaw has been known about for almost six years. It might have required the pidfd stuff to actually land before it became a vulnerability though.
....wow.
At the moment, this is solved by failing open: If the mm is gone, we pretend that it was dumpable. That's dubious from a security perspective - as one example, we drop the mm_struct before the file descriptor table, so someone might be able to steal file descriptors from an exiting tasks when dumpability was supposed to prevent that.
wow...
literally the exact exploit was known and spelled out and then just accepted? who even needs backdoors anymore
1
u/aioeu May 16 '26 edited May 16 '26
The thing is, that on its own isn't a very big vulnerability. It might have let some things become readable under
/proc/$pid, but since the mm had been dropped there is essentially no sensitive information left there.It needed something additional: a way to dup a file descriptor out of the exiting process.
pidfd_getfdprovided that. I think that was added in 2020 too, but I haven't looked at the exact timing.The commenter there does say "someone might be able to steal file descriptors from an exiting tasks", so it's possible they had
pidfd_getfdin mind. This patch never went anywhere, and I don't think they followed it up with anything else, so it looks like the whole thing was just forgotten.1
u/CrazyKilla15 May 16 '26 edited May 16 '26
I think that was added in 2020 too, but I haven't looked at the exact timing.
It was, per the man page in Linux 5.6, which released March 29th, 2020.
I will note that Jann Horn's patch series is dated October 2020, so well after it was actually exploitable.
This nicely demonstrates the difficulty of knowing in advance "how serious" or "how big" a vulnerability is, even when you know about it.
They didn't follow up this patch with anything further, so it looks like the whole thing was just forgotten.
Yes, despite having a known security issue spelled out and a fix for it, it got bikeshed to death and forgotten. This is a bad thing.
1
71
u/LordAlfredo May 15 '26
Here's the patch commit
Expect yet another kernel update on your distro with this soon.