-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[rustc] SIGSEGV maximum backtrace depth reached #133772
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
Comments
@bf Did you reach this in a practical use-case, or is this purely synthetic? |
Purely synthetic. I've been working with rust for a couple of weeks and found some interesting edge cases concerning security risks arising from IMO there are several by-design security risks for developers using rust right now. When you build software with rust, you're unknowingly accepting these security risks. The stance of rust security team elegantly avoids these risks by stating they are out of scope because all code is trusted. I'm currently trying to document these security risks, so they can be explicitly accepted by developers using rust, and maybe nudge the rust security team towards implementing more security controls and fail-safes so rust follows a more defense-in-depth approach. I have documented how rust users can be exploited by compiling untrusted code with But getting all your data stolen by simply formatting code with I'll be sharing a write-up soon. |
@bf I think there's some confusion regarding what "security" we're talking about here.
I can only speak for For resource exhaustion crashes, we typically prioritize them or triage them according to how likely/feasible is it for a regular user to write similar code "organically". In this provided pure synthetic example, it involves nesting
I think this is explicitly a non-goal for
If you are compiling untrusted code with EDIT: to add, the build might be sandboxed, but that concern is delegated to you.
This is simply not a threat model that we consider, AFAIK. |
@bf A stack overflow does not, itself, constitute an exploit, as the term is commonly defined in security research1. If you are familiar with security research involving languages that are compiled to machine code, you must know this? I would hope you would have read the error message and recognized that this hit a signal handler that responds to the quite-intentional page fault caused by hitting the stack protector2. I would hope that if you are familiar enough to be able to confidently make claims about security concerns and exploits, it would not need additional explanation... but perhaps it is missing something in the diagnostic? I am happy to amend it, if so, but it would have to be a small addition, as it already uses a lot of vertical space and I don't think we can fully explain "what is a page fault, anyways?" within that. Otherwise, I am not sure from where you have derived the idea that, by putting in an amount of code that induces resource exhaustion, you have reached an exploit. As a batch program, rustc is not even expected to be particularly resilient to resource exhaustion, unlike e.g. a web server, where such might be a reasonable expectation? We can make rustc resilient more resilient to inputs, but that might compromise other desirable qualities like speed of compilation, or simply divert work from more important things, like making it easier to write safe code with rustc (so that other programs that rustc compiles are more secure by design). Eventually, all programs will run out of memory if they are given a sufficiently ridiculous task, and the errors are rarely pretty. All these considerations happen in addition to the detail that jieyouxu already described regarding the trustedness of certain inputs. Footnotes
|
Unfortunately I'm not good with machine code & exploiting overflows, which is why I asked. Thanks for confirming that the SIGSEGV is not exploitable @workingjubilee.
I understand this, and I think it is an artificial blind spot in rust security posture. I have gathered my thoughts on rust security at https://github.com/bf/rust-security-problems and will create new reports for the most glaring issues. Then the issues and your decision will be documented. |
cc @rust-lang/security just in case you're interested. I can't tell if OP was trying to address you. |
Triage: let's keep this issue focused on the resource exhaustion stack overflow from the code sample itself and open separate issues for the security concerns. |
You might be interested in reading the discussion in rust-lang/rfcs#1515 |
Then the unfamiliarity is understandable. I am happy to try to answer some questions you may have regarding such. A stack overflow is a segfault. Almost all such segfaults are very hypothetically exploitable: you have to find a way to bypass the protection. However, as mentioned, you are running headfirst into the exact wall that is designed to prevent things from getting worse, and you are doing the exact thing that would normally cause you to run into that wall. It's rather like intentionally running a command that can reformat your hard drive, and then not even reporting that your hard drive was formatted, but that a window popped up to ask for your password before you destroyed your access to your computer's data. Yes, that little popup was supposed to be there. To say "I found an exploit" implies something more like "I found a way to run the command that reformats my hard drive without hitting the password check". That would transgress a security boundary. Here, you are starting on the other side of the airtight hatchway, so there are quite a lot of interesting things you can do by running a program that can read and write to the filesystem. |
Here's another reproducer:
|
Code
Use javascript
x=10000; out="compile_error!(" + "concat!(".repeat(x) + '"A"' + ")".repeat(x); + ");"
to create rust code.Full code in evil3.rs.txt
Meta
rustc --version --verbose
:Error output
The text was updated successfully, but these errors were encountered: