-
Notifications
You must be signed in to change notification settings - Fork 199
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
Several heap-BoF crashes from pcre2_compile related to parsed_pattern #561
Comments
just to be clear (and without looking). are all those crashes and their line numbers associated with a specific revision of the code?, how about the latest released version? |
We originally found them on version |
(sorry, accidentally hit close) I just tested on the latest version and they appear there too. Happy to provide any other info on request. |
crashes on unreleased code are to be expected (indeed I know at least of another one I had yet to fix), it would be very important to know though if you can crash a released version of the code. |
I have looked into this, because the code mentioned by @stevenagy is in the area I've been working on recently. I reproduce with:
It does not reproduce with |
Interesting! Thanks for confirming. Does a crash on the latest master suggest this may be a regression? We're admittedly unfamiliar with PCRE2's policies on how the mainline repo differs from official release versions. :) In our fuzzing campaigns we by default just pulled libraries' latest master versions. I'd be happy to do a re-test with PCRE2's most recent official release if you would find that more helpful! |
The policy is (I believe) that unreleased code, on master branch, is a work-in-progress. We make no guarantees, we do not recommend it to be used in production, and we do not publish security advisories if there are issues found on master. The released versions however are in production use, and any issues there would be critical. I'm not sure which is preferable for external contributors to fuzz - perhaps both master and latest release? If one or the other, then I suppose master is more useful to us. The released version has already been quite extensively fuzzed, and further effort there is likely to be wasted compute (although there's a small probability a new issue could be uncovered). |
@PhilipHazel There appears to be an issue in the new (unreleased) scan_substring feature. It writes out more units to |
@zherczeg: ping just in case you missed this somehow and are not in the middle of pushing a fix. |
Thank you! It writes 3 numbers into the stream: The |
But PUTOFFSET write 2×uint32_t, so currently the code is writing 4 units. The worst-case pattern is "(scs:(1,1,1,1,1,1,1,...) )". You can only write 2× uint32_t in total, so the offset won't fit, at all. Problem. The same issue appears in the |
True. Btw, names cannot be empty string. Anyway a relative offset could help. If the next item is < 65535 characters away from the previous item, we encode a relative diff. Otherwise we have a huge buffer area. |
I assume you're working on a fix (or will do). I won't make a PR - but if you're busy I'd be happy to. |
I have already put something together. We should focus on landing the open PRs. as well. |
After Zoltan's PR, I can do a teeny extra PR to add an assertion. This bug slipped in, because we check that |
This can be closed. |
We found several crashing files (attached) through fuzzing the following program:
All crashes are heap-buffer-overflows stemming from the following source lines:
pcre2_compile.c:4014
pcre2_compile.c:4030
pcre2_compile.c:4304
pcre2_compile.c:4306
pcre2_compile.c:4307
These all appear to involve the
parsed_pattern
object.We were able to reproduce the crashes using the PCRE2 OSS-Fuzz harness here after modifying it to read data from file: https://github.com/PCRE2Project/pcre2/blob/master/src/pcre2_fuzzsupport.c.
Any feedback on these crashes would be greatly appreciated. :)
crashes.zip
The text was updated successfully, but these errors were encountered: