809 matches found
shopify-scripts: Segmentation fault due to bad memory access in kh_get_mt
Crash file is: values=0,0,0,0 unusedbutneeded= Hash= values.each do values.each do values & values.each do values.each do % 0=nil end end end end $ ./dev/bin/mruby crash.rb Segmentation fault: 11 $ lldb ./dev/bin/mruby crash.rb lldb target create "./dev/bin/mruby" Current executable set to...
shopify-scripts: Null pointer derefence due to bug in codegen with negation without using value
Crash file is: p case when nil -0 nil end $ ./dev/bin/mruby crash.rb crash.rb:1:3: '' interpreted as argument prefix Segmentation fault: 11 $ lldb ./dev/bin/mruby crash.rb lldb target create "./dev/bin/mruby" Current executable set to './dev/bin/mruby' x8664. lldb settings set -- target.run-args...
shopify-scripts: Invalid handling of zero-length heredoc identifiers leads to infinite loop in the sandbox
Introduction ============ Certain invalid Ruby programs which should normally raise a syntax error are able to cause an infinite loop in MRuby's parser which makes the mruby-engine sandbox and consequently the MRI process it is running in unresponsive to SIGTERM. The process begins looping foreve...
shopify-scripts: Invalid memory write caused by incorrect upper bound in array_copy
Ok, here is a weird one! It only crashes in mruby, and can't be made to crash in mruby-engine as max memory possible to extend to is 256M which this requires more. The file is: values = 3,5,8 test = 1,6 results,= 1.2 values.each do |value| case value when test results 0x10000222d : movq %rdx, %ra...
shopify-scripts: Crash: Initialize Decimal with itself triggers an assertion
When Decimal is initialized with itself, a new empty mpdt will be created. To fill it with a value, tos of the current instance is called, which accesses the empty mpdt. This triggers an assertion, which leads to a crash. Patch I've created and attached a simple patch which just returns self when...
shopify-scripts: Null pointer dereference regression in parse.y
Hi, Just pulled the latest mruby code, and found that some of my fuzzing test cases now crash. Bisected it to commit 227daa881137d5251e03eea0883b9b574a1f064e. Reverting this change no longer causes a crash. The minimised file causing the crash is: f Also affects mruby-engine. Cheers, Hugh...
shopify-scripts: Crash: calling Proc::initialize_copy with a Proc instance where initialize never ran leads to a crash
Using the same trick from 184661 with Proc leads to another crash, this time in Proc related functions. Again, haven't looked into it besides validity testing and an initial code lookup more detailed investigation + possible patches when there's more time on my side. Again, to give you guys the...
shopify-scripts: Read after free in mrb_vm_exec with OP_ARYCAT reading R(B)
Hi, Slightly different one, this is a use after free as reported by an ASAN compiled binary. This one doesn't affect mruby-engine with the current instruction limit and memory limit, but if they are increased then it does. The file is: class Klazz def $thing.name [email protected]@thing.name nil end...
shopify-scripts: Denial of service due to invalid memory access in mrb_ary_concat
Hi, The following file causes a segmentation fault in mruby, which also causes a segmentation fault in mruby-engine. I've minimized this file down to the bare bones what crashes it, then renamed variables and tidied so you can see what is needed and what isn't. case "" when 0 end x case when true...
shopify-scripts: mruby-time: Crash host with uninitialized Time obj
So once again, another try ; As always hopefully unknown and valid ; Time::initializecopy performs its copy action even on Time objects on which initialize never ran, leading to a crash. The PoC crashes https://www.mruby.science/runs - didn't try Shopify production servers for the usual reasons. ...
shopify-scripts: Invalid memory access while freeing memory, caused by invalid type passed to mrb_ary_unshift
Hi, Phew, this was a tricky one as the cause wasn't next door to where the dereference happened! The file causing this is: a case when nil redo end $ ./dev/bin/mruby --version mruby 1.2.0 2015-11-17 $ ./dev/bin/mruby crash.rb crash.rb:1:3: '' interpreted as argument prefix trace: 0 crash.rb:3...
shopify-scripts: Null pointer dereference in ary_concat
Hi, The following file causes a segmentation fault in mruby, which also causes a segmentation fault in mruby-engine. I've minimized this file down to the bare bones what crashes it, then renamed variables and tidied so you can see what is needed and what isn't. a=0 b=nil a.each do |a| a = case a...
shopify-scripts: Segmentation fault when a Ruby method is invoked by a C method via Object#send
We can arrange for C to call Objectsend by aliasing it over initialize. This will cause Classnew a C function to call initialize which is actually Objectsend with arbitrary arguments. If we invoke a Ruby method through Objectsend, mruby segfaults: def foo end class X aliasmethod :initialize, :sen...
shopify-scripts: Null target_class DoS
The Objectinstanceexec method in mrbgems/mruby-object-ext/src/object.c executes a block in the context of an object. It sets the VM's targetclass pointer to the singleton class of this object. targetclass is used as the definition target for constants and methods. If a singleton class cannot be...
shopify-scripts: Segfault and/or potential unwanted (byte)code execution with "break" and "||=" inside a loop
Introduction ============ Certain invalid inputs invalid Ruby programs crash mruby and mrubyengine including the parent MRI VM. The programs always involve the ||= operator, loops and the break keyword. Proof of Concept ================ crash.rb -------- A ||= break while break 1. Save the above...
shopify-scripts: SIGSEGV on mruby's mark_tbl() (Invalid memory access)
There is an invalid memory access on mruby when calling to marktbl which causes a SIGSEGV and leads to denial of service. Sample The following code triggers the bug attached as marktbl.min2.rb: ruby t0me=% Array.new9t0me.empty?s=Array.new9%0 s=Array.dup.new23 Array0 Array0..6 Crash Here we can se...
shopify-scripts: SIGSEGV on mruby mrb_str_modify() (Invalid memory access)
There is an invalid memory read on mruby when calling to mrbstrmodify with a invalid RString which causes a SIGSEGV and leads to denial of service. Sample The following code triggers the bug attached as mrbstrmodify.min.rb: ruby def n if $0 end ""if 00end qqq=Proc.new|x|x.join qqq."",'...
shopify-scripts: Null pointer dereference due to TOCTTOU bug in mrb_time_initialize
mrbtimeinitialize sets the data pointer to NULL before parsing function arguments. Parsing function arguments can call out to ruby code to call methods to do type coercion. If the type coercion method tries to access the time object it will dereference a NULL pointer. The following snippet result...
shopify-scripts: Range constructor type confusion DoS
It's possible to crash mruby by redefining the Range class and then using the range literal syntax: Range = Array 1..2.inspect The mrbrangenew function allocates and initializes a range object backed by the RRange struct, however it uses runtime constant lookup to find the Range class object...
shopify-scripts: TOCTTOU bug in mrb_str_setbyte leading the memory corruption
The Stringsetbyte function caches the length of the string before loading the function arguments. Loading function arguments through mrbgetargs can call into ruby code to run type conversion methods toi, tos and the like. A malicious conversion method is able to force the string to be reallocated...