Headline
CVE-2023-5686: heap-buffer-overflow in /radare2/shlr/java/code.c:211:21 in java_print_opcode in radare2
Heap-based Buffer Overflow in GitHub repository radareorg/radare2 prior to 5.9.0.
Description
heap-buffer-overflow in /radare2/shlr/java/code.c:211:21 in java_print_opcode
Version
$ r2 -v
radare2 5.8.9 31339 @ linux-x86-64
birth: git.5.8.8-691-gb2de2288d8 2023-10-17__01:18:28
commit: b2de2288d8299f89288c503fc2ce22381b61aba0
Platform
$ uname -a
Linux user-GE40-2PC-Dragon-Eyes 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Asan
[31mERROR:[0m Invalid tag '83' at offset 0x00000047
[31mERROR:[0m Unable to parse class Attribute len (0x24020007) + offset (0x25b) exceeds length of buffer (0x5878)
[31mERROR:[0m unable to parse remainder of classfile after Method Attribute: 0
[31mERROR:[0m Unable to parse class Attribute len (0x47608fc2) + offset (0x255) exceeds length of buffer (0x5878)
[33mINFO:[0m Analyze all flags starting with sym. and entry0 (aa)
[33mINFO:[0m Analyze imports (af@@@i)
[35mWARN:[0m set your favourite calling convention in `e anal.cc=?`
[33mINFO:[0m Analyze symbols (af@@@s)
[33mINFO:[0m Recovering variables
[33mINFO:[0m Analyze all functions arguments/locals (afva@@@F)
[2K
[33mINFO:[0m Analyze function calls (aac)
[33mINFO:[0m Analyze len bytes of instructions for references (aar)
[33mINFO:[0m Finding and parsing C++ vtables (avrr)
[33mINFO:[0m Analyzing methods
[33mINFO:[0m Finding xrefs in noncode section (e anal.in=io.maps.x)
[33mINFO:[0m Emulate functions to find computed references (aaef)
=================================================================
==3433174==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000132dd2 at pc 0x7fe86fbfe09b bp 0x7fff8b14f4c0 sp 0x7fff8b14f4b8
READ of size 1 at 0x602000132dd2 thread T0
#0 0x7fe86fbfe09a in java_print_opcode /home/user/fuzzing_radare2/radare2/shlr/java/code.c:211:21
#1 0x7fe86fbfe86c in r_java_disasm /home/user/fuzzing_radare2/radare2/shlr/java/code.c:309:10
#2 0x7fe86f9fb8e6 in decode /home/user/fuzzing_radare2/radare2/libr/arch/p/java/plugin.c:215:15
#3 0x7fe86f562c85 in r_arch_decode /home/user/fuzzing_radare2/radare2/libr/arch/arch.c:320:9
#4 0x7fe86dc629cf in r_anal_op /home/user/fuzzing_radare2/radare2/libr/anal/op.c:186:8
#5 0x7fe8719d718f in r_core_anal_esil /home/user/fuzzing_radare2/radare2/libr/core/canal.c:5715:8
#6 0x7fe87182176a in cmd_anal_all /home/user/fuzzing_radare2/radare2/libr/core/./cmd_anal.inc.c:13183:6
#7 0x7fe871737429 in cmd_anal /home/user/fuzzing_radare2/radare2/libr/core/./cmd_anal.inc.c:14267:8
#8 0x7fe87182381f in r_core_cmd_call /home/user/fuzzing_radare2/radare2/libr/core/cmd.c:6303:9
#9 0x7fe87182381f in cmd_anal_all /home/user/fuzzing_radare2/radare2/libr/core/./cmd_anal.inc.c:13042:7
#10 0x7fe871737429 in cmd_anal /home/user/fuzzing_radare2/radare2/libr/core/./cmd_anal.inc.c:14267:8
#11 0x7fe8725c3940 in perform_analysis /home/user/fuzzing_radare2/radare2/libr/main/radare2.c:499:2
#12 0x7fe8725b931d in r_main_radare2 /home/user/fuzzing_radare2/radare2/libr/main/radare2.c:1720:4
#13 0x555816ea152d in main /home/user/fuzzing_radare2/radare2/binr/radare2/radare2.c:114:9
#14 0x7fe872229d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#15 0x7fe872229e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#16 0x555816de3444 in _start (/home/user/fuzzing_radare2/radare2/binr/radare2/radare2+0x1f444) (BuildId: 655cd64f4959101bcf192e77bc6bf062577e0708)
0x602000132dd2 is located 0 bytes to the right of 2-byte region [0x602000132dd0,0x602000132dd2)
allocated by thread T0 here:
#0 0x555816e6628e in __interceptor_malloc (/home/user/fuzzing_radare2/radare2/binr/radare2/radare2+0xa228e) (BuildId: 655cd64f4959101bcf192e77bc6bf062577e0708)
#1 0x7fe872764b88 in r_mem_dup /home/user/fuzzing_radare2/radare2/libr/util/mem.c:306:12
SUMMARY: AddressSanitizer: heap-buffer-overflow /home/user/fuzzing_radare2/radare2/shlr/java/code.c:211:21 in java_print_opcode
Shadow bytes around the buggy address:
0x0c048001e560: fa fa fd fd fa fa fd fd fa fa 04 fa fa fa 04 fa
0x0c048001e570: fa fa 04 fa fa fa 00 00 fa fa 00 00 fa fa 00 00
0x0c048001e580: fa fa 00 00 fa fa 00 01 fa fa 00 00 fa fa 00 01
0x0c048001e590: fa fa 00 00 fa fa 00 01 fa fa 00 00 fa fa 00 01
0x0c048001e5a0: fa fa 00 00 fa fa 00 01 fa fa 00 00 fa fa 00 00
=>0x0c048001e5b0: fa fa 00 01 fa fa 04 fa fa fa[02]fa fa fa fa fa
0x0c048001e5c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048001e5d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048001e5e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048001e5f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048001e600: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==3433174==ABORTING
Reproduce
r2 -A -q poc
POC File
https://github.com/gandalf4a/crash_report/blob/main/radare2/r2/r2_hbo_211
Credit
Gandalf4a
Impact
This vulnerability allows a remote attacker to cause a denial of service or even arbitrary code execution on an affected radare2 r2. Exploiting this vulnerability requires user interaction, as the target must open a malicious file.
Occurrences