-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
REDOS vulnerability - Snyk.io found something #1039
Comments
I double-checked. The highlighted line in the Checkmarx output is still the same regex as what's in master - unless my eyes crossed while I was reading it (quite possible). Thoughts?? |
Several things don't check out:
it looks to me that's a heap memory allocation error, generated in the
|
It seems that the error is indeed caused by the When replaced with var genstr = function (len, chr) {
var result = chr;
for (i=1; i<=len; i *= 2) {
result += result;
}
return result;
} (notice the The same string is parsed by marked in fairly reasonable times and does not crash node. It even reaches 134 mb in length without any problem:
In fairness, commonmark does better:
In other words, the PoC crashed on itself, not marked. |
It's more like a joke, not a real vulnerability report. The code is written clearly unprofessional, it is completely absurd. I think we should not pay attention to this. |
https://snyk.io/vuln/npm:marked:20171207 - Snyk is kind of a big deal. So, I'm not sure we are in a position to ignore it. I'm going to try and loop in someone from the Snyk team - this is actually a service used by the US Gov't to verify security on packages as well; so, again, kind of a big deal. I'm definitely not understanding why this is classified as a "vulnerability"...what makes a consumer vulnerable if someone does this? |
Hey, Our vulnerability lead generator surfaced this recently and I realized it wasn’t covered in the 0.3.9 release (where a few of the vulnerabilities were fixed in). The Checkmarx Vulnerability report states they tried to contact the maintainer at the time, (i’m only assuming email) and there was no reply, so I assumed it fell between the chairs. Meanwhile, we’re reaching out to the folks at Checkmarx and see if we can get them to input more information on this. |
I ran their PoC on the current master branch using String.repeat() instead of their genstr function and removed the string generation from the time reported and i'm not seeing an exponential increase in time. I got all the way up to 300,000,000 characters without crashing and that only took 7 seconds to parse, That is about a 280MB string I'm thinking the string generation was what they were seeing increase the time exponentially. var marked = require('./');
var renderer = new marked.Renderer();
renderer.blockquote = function (text) {
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return escapedText;
}
for (i=37000000;i<=300000000;i=i+10000000) {
var str = '> blockquoteeeeeeeeeeeeeeeeeeeeeë@@@@@@@@@' + '@'.repeat(i) + '}';
console.log("LENGTH: " + str.length);
var start = process.hrtime();
marked(str, { renderer: renderer });
var end = process.hrtime(start);
console.log(end);
} |
@karenyavine: Thanks for jumping in and sending the intiial email. I also had the question regarding version numbers when I saw the initial finding - that's why I went to the highlighted code, which I assumed was the part of the call stack that failed because that is still the same in the current |
ps. Thanks for continuing to chase it down. The community did some really good work over December to get the vulnerabilities taken care of and we're pretty sure we got them all...but definitely want to make sure as we don't have the knowledge, skills, or tools to run these types of scans ourselves for various reasons. |
Downgrading to annoying pending furthe discussion with @karenyavine. They're swamped right now; so, maybe be a couple of weeks. |
ps. @Feder1co5oave and @UziTech - I'm kinda with y'all - this seems like an odd test and I'm still not sure what this makes someone "vulnerable" to exactly. Crashing an app can make someone vulnerable to something...I'm not a security guy; so, yeah, totally at a loss here but would love to learn something new. |
Well, if for example you use marked on a server a malicious user can take
out your service with a simple DOS attack based on vulnerable regexes.
And about that, I'm pretty sure marked is full of them. It just takes a
willing attacker to find another vulnerable rule. I think there are
automated scans for it too. I certainly cannot claim it is 100% safe from
ReDOS. In fact I'm inclined to do the opposite. If you use complex regexes
chances are you're vulnerable to ReDOS. We either switch off from regexes
or we accept that they can be unsafe and keep driving down this road.
I think we should recommend users that use marked in "production" server
environments to limit the input size to a reasonable threshold, say few
megabytes. That should be enough to avoid running out of heap space and
hanging for more than a few seconds.
|
Fair and thanks. Maybe this is why other libraries have moved away from regex. Would giving folks the ability to set a character - if they're using it to render on the fly be enough to satisfy the "keepers of all things vulnerabilities"?? (Like a config option.) Part of Marked's marketing in the README is to allow the parsing of large |
Hello all, This is Erez from Checkmarx. The advisory was already removed from our website and I will contact MITRE to delete the CVE. The way the code was written was indeed problematic. This is to be expected to some extent since the research team members are usually breakers and not builders. The lesson learned here is to double check ReGex PoCs and to quadruple check every PoC when we do not get a response from the developer, before submitting for a CVE. Sorry about that. Erez Yalon |
@ErezYalon: Thank you so much for letting us know. Also, I work for the gov't as a contractor; therefore, get introduced to a lot of acronyms that collide, can you help me out? MITRE? Just want to make sure I'm not translating them incorrectly. Closing. |
@ErezYalon Thank you for all the hard work you guys do at Checkmarx. Finding vulnerabilities is a difficult and absolutely necessary job. I'm sure we have all been a little too eager to get some answers at times. @joshbruce |
@UziTech: Thanks! PoCs was really hanging me up - that's Point of Contact in my world - and given the surrounding context it could have kinda worked. ;) |
Awesome, |
Working on some things behind the scenes to gain more flexibility in our decisions and collaboration efforts. Going to be adding things that are tied directly to the revival and progress of the project to #956 - unfortunately, I don't think there's a way to remove the other mentioned completely. |
Hey there Josh,
I'm Karen, a security analyst for snyk.io.
I saw you've done a ton of work to revive the marked package, and fix the vulnerabilities in it. I wanted to check in with you regarding a different vulnerability, which I believe was not fixed and might've just been missed (according to the advisory, an email was sent to the original maintainer but a public GH issue was never opened).
The vulnerability is a ReDoS, found by Checkmarx, and was assigned the CVE-2017-17461.
You can see the details here. I've ran their PoC and the process indeed crashes.
If you'd like, I could open an issue on github to help monitor the issue, but that's up to you :)
As the vulnerability is already public, am planning to add it to our vulnerability database today, as I would like to notify our users of this issue.
Cheers,
Karen
Security Analyst @ snyk.io
Taggin @Feder1co5oave, @UziTech, @KostyaTretyak
The text was updated successfully, but these errors were encountered: