Null pointer dereference in mrb_str_modify
The mruby function mrb_str_modify does not check whether the string's heap pointer is NULL before writing to it, leading to a null pointer dereference. An attacker could trigger a crash by running a crafted Ruby script that manipulates a string and forces garbage collection.
Originally disclosed on HackerOne
- Triaged in 10 days
- Fixed in 11 days
- Paid in 26 days
- Disclosed after 26 days
The function mrb_str_modify doesn't check if s->as.heap.ptr is NULL before operating in it.
Attempt to write to a NULL pointer happens here:
676 RSTR_PTR(s)[s->as.heap.len] = '\0';
Poc:
a = String.new
a[0]
GC.start()
a.upcase!
Version tested: https://github.com/mruby/mruby/blob/e1ff71029f95e3274136263adbdc51c662ec52de/src/string.c
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could cause a denial of service by crashing the mruby interpreter.
What the attacker needed
Ability to run Ruby code in mruby
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A null pointer dereference happens when a program tries to use a memory address that points to nothing (null). In this case, the mruby interpreter fails to check if a string's internal pointer is null before writing to it, which can cause the program to crash. This is a denial-of-service bug because it can make the interpreter stop working.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.