-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Improved security section in rustdoc for current_exe
#150828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
cc @rust-lang/security |
This comment has been minimized.
This comment has been minimized.
current_exe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this: I don't think the Rust standard library is the right place to educate people about specific attacks. So keeping the documentation short and simply reminding people to not blindly trust the output seems good.
|
Since you've already taken a look, |
|
See also #150824 improving other parts of this function's rustdoc. |
This comment has been minimized.
This comment has been minimized.
e9c161c to
8fb7d64
Compare
The link seems to be okay, it just redirects to https://vulners.com/securityvulns/SECURITYVULNS:DOC:22183, which seems to be a vulnerability related to /proc/self/exe. |
Huh, I'm sure it was consistently erroring the other day, but you're right, now it's back. Anyhow, that particular page, just a list of related vulnerability notices, doesn't seem especially useful to someone trying to understand how to use this Rust function. We could link to https://blog.cr0.org/2009/07/old-school-local-root-vulnerability-in.html which gives a better explanation. However this seems a bit in the weeds for Rust stdlib, and also possibly not likely to succeed on modern Linux, which should normally(?) prevent creation of untrusted hardlinks to setuid programs. |
This comment has been minimized.
This comment has been minimized.
Remove somewhat obvious comment about executing attacker-controlled programs. Be more clear the examples are not exhaustive.
8fb7d64 to
177dc5a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
A few improvements to the security section of the docs about
current_exebrokennot directly very helpful in understanding the risk./proc/self/exe. On modern Linux this should normally require permission to write to the executable.I did some web research for "argv0 vulnerability" and similar terms and didn't find anything else we should be documenting here. (There are issues about argc=0 but those should be prevented by memory safety in Rust.)
I found what the link seemed to be pointing to in https://vulners.com/cve/CVE-2009-1894, which talks about confusing a setuid program by creating a hardlink to its exe. I think this is in very particular circumstances something people should still be concerned about: a setuid program on a machine with
fs.protected_hardlinks = 0. I don't think this justifies warning people not to use the function at all.cc @mgeisler