-
Notifications
You must be signed in to change notification settings - Fork 96
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
Stack-buffer-overflow in renumber_by_map in regcomp.c #144
Comments
I successfully reproduce the issue in Onigmo. PoC code:
Crash:
If you cannot get crash with '(a)(?f)(?(90000))', you can try '(a)(?f)(?(900000))', '(a)(?f)(?(9000000))'... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this bug in ruby regex engine, which is in fact Onigmo regex engine. So here should be the place to report the bug.
Environment
Compilation
Reproduce
It also crashes on default ruby version in Ubuntu 16.04 (ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu])
Analysis in ruby source code
The bug comes from (renumber_by_map in regcomp.c:1959):
Here en->regnum is assigned new_val from map without checking the size of map.
With the input "".match /(())(?)((?(90000)))/, map is a 5 - element array and en->regnum = 90000 => en->regnum is assigned a new_val at map[90000] => buffer-over-flow. We can control the offset of the read and control the new_val to be assigned to en->regnum.
You can modify N in "".match /(())(?)((?(N)))/ until you get a crash.
This code is trigger only if the node is ENCLOSE_CONDITION and the following conditions are matched (regcomp.c:5769) and then disable_noname_group_capture is called:
The text was updated successfully, but these errors were encountered: