what should the security policy of this crate be? #994
-
On occasion, someone files a bug against this crate by following the Rust Security Policy. This is great and I am appreciative of folks being so conscientious about following our security policies. However, treating bugs as security problems tends to be heavyweight. And some bugs reported are not obviously security problems. For example, if there's a bug in the regex crate that can result in a panic while compiling a regex or running a search, is that a security problem that should go through responsible disclosure because it could in theory cause a denial-of-service attack? What if compiling a regex could use an "unexpected" amount of resources (CPU or memory or both)? What if regex search produces a match when it shouldn't, or does not match when it should? Are these security problems? I'll stop there. I'd like to hear thoughts from others. (I have my own opinions but want to wait for others to chime in.) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 21 replies
-
I think it'd be reasonable for the regex crate to declare which of its guarantees are considered "security" guarantees. For instance, regex could say "using unexpectedly excessive CPU or memory is a security bug, but safely panicking is not". (I'm not proposing this as the policy, just an example.) |
Beta Was this translation helpful? Give feedback.
-
My experience is... it is common for security researchers to operate by a fairly arbitrary definition of "security" that does not necessarily involve e.g. the ability to actually exploit the bug, or for the security bug to actually be a security flaw in context.Rust programs, in general, tend to not consider "denial of service" to be a "security bug" because it is part of the language's design to, in fact, deny service instead of e.g. following another codepath that can be exploited to subvert the program and acquire the coveted "remote code execution" vuln: a true, devastating exploit if actually obtained, as it usually allows subverting all other defenses and obtaining access to all available information. Obviously, this may be unacceptable in some situations. You do not want "denial of service" if you are the software running a pacemaker. In that context, it is not unfair to label a "denial of service" attack as a major security concern. However, this reveals the essential problem with a generic, context-free approach to security: what is acceptable and even preferred behavior in some cases is completely unacceptable in others. Even RCEs are often only obtained in certain situations. A computer is fundamentally an engine for "remote code execution", and it is very often that the computer's actual human user wishes to cause an "RCE" vulnerability to happen, such as by double-clicking on a program to launch it... which may seem absurd as an example, but it is not uncommon for a user to then be stopped by pre-installed security measures, only to then deliberately circumvent those. Which brings me to the last detail: some bugs, sometimes capable of causing actually horrifying vulnerabilities, have been dismissed with a simple "working as intended" due to the circumstances required being the equivalent of violating an As far as I know, this crate is immune to typical "ReDoS" attacks, and that is a well-known trait of it, so I think that property should be maintained and any flaw revealing a problem in that should be considered as a serious bug ("security" or not). However, I think that otherwise any panics reached during execution should simply be documented as part of the API. If you wanted to not hit a DoS ever, you wouldn't use a crate that has |
Beta Was this translation helpful? Give feedback.
-
My personal viewpoint is the only major security issue should be incorrect matches (either positive or negative). If someone is sanitizing data using regex (yes, that might not be the best idea, but people often do), then missed matches is a serious problem. Similarly, extra matches might be usable to corrupt data. Undocumented panics I wouldn't personally consider a security issue, but I can understand how some people would. They are certainly (to my mind) much more minor. Seeing as it's very hard to write panic-free Rust code anyway (because memory allocation can panic), I tend to assume any code can panic. Personally, I hate the "slow is a security problem", because there isn't a clear standard for "slow", so we end up with lots of ad-hoc attempts at defining slow. |
Beta Was this translation helpful? Give feedback.
-
To add my two cents to this conversation:
Well, the crate's description explicitly says:
So I'd start by stating that any non-linear time is "unexpected". And similarly, since the crate is using finite automata, I'd consider anything larger than constant memory (constant with regards to the text being matched) to be unexpected as well. Does that make sense? I hope that makes sense. |
Beta Was this translation helpful? Give feedback.
-
I would advocate for a fairly expansive definition of what's a vulnerability, but a fairly lightweight way of dealing with them when they're reported. For non-pathological regexes (anything someone would reasonably write), it's a vulnerability if an attacker who controls only the input can:
If the attacker controls both the regex and the input (but not anything else), it's a vulnerability if the attacker can:
Most of the time, though, I would recommend against any lengthy coordinated disclosure process. Just fix the bug as soon as possible and then publish the fix, stamp a release, and issue a RUSTSEC advisory all at once. |
Beta Was this translation helpful? Give feedback.
-
I am going to add this to the top-level crate documentation as part of the
I think that's probably good enough for now. It doesn't quite answer questions about performance on its, but there will be clarifying docs on that in the top-level crate docs as well. |
Beta Was this translation helpful? Give feedback.
I am going to add this to the top-level crate documentation as part of the
regex 1.9
release: