Skip to content

heap-buffer-overflow exists in the function decToString in decNumber.c

High
emanuele6 published GHSA-686w-5m7m-54vc Dec 13, 2023

Package

jq (jq)

Affected versions

1.7

Patched versions

1.7.1

Description

System info
Ubuntu x86_64, clang 12.0
version: jq-master-cca1f7d-dirty

Command line
./jq . poc

Poc
poc:poc

AddressSanitizer output
==542903==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x613000000188 at pc 0x00000054e6e3 bp 0x7ffdf15aa0b0 sp 0x7ffdf15aa0a8
WRITE of size 1 at 0x613000000188 thread T0
#0 0x54e6e2 in decToString /src/jq/src/decNumber/decNumber.c:3764:5
#1 0x54c9d2 in decNumberToString /src/jq/src/decNumber/decNumber.c:449:3
#2 0x4f6b54 in jvp_literal_number_literal /src/jq/src/jv.c:653:5
#3 0x4f6b54 in jv_number_get_literal /src/jq/src/jv.c:668:12
#4 0x53a80b in jv_dump_term /src/jq/src/jv_print.c:231:35
#5 0x53eba6 in jv_dumpf /src/jq/src/jv_print.c:368:3
#6 0x53eba6 in jv_dump /src/jq/src/jv_print.c:372:3
#7 0x4ce841 in process /src/jq/src/main.c:207:7
#8 0x4cd2ac in main /src/jq/src/main.c:724:15
#9 0x7fe078a4f082 in __libc_start_main /build/glibc-BHL3KM/glibc-2.31/csu/../csu/libc-start.c:308:16
#10 0x41d7bd in _start (/src/jq/jq+0x41d7bd)

0x613000000188 is located 0 bytes to the right of 328-byte region [0x613000000040,0x613000000188)
allocated by thread T0 here:
#0 0x49867d in malloc (/src/jq/jq+0x49867d)
#1 0x5084bf in jv_mem_alloc /src/jq/src/jv_alloc.c:141:13
#2 0x53eba6 in jv_dumpf /src/jq/src/jv_print.c:368:3
#3 0x53eba6 in jv_dump /src/jq/src/jv_print.c:372:3

SUMMARY: AddressSanitizer: heap-buffer-overflow /src/jq/src/decNumber/decNumber.c:3764:5 in decToString
Shadow bytes around the buggy address:
0x0c267fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c267fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c267fff8000: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
0x0c267fff8010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c267fff8020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c267fff8030: 00[fa]fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c267fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c267fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c267fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c267fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c267fff8080: 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
Shadow gap: cc
==542903==ABORTING

Severity

High

CVE ID

CVE-2023-50246

Weaknesses

Credits