CVE-2023-50268 was not fully fixed. Comparing a nan with at least 10 decimial digits of payload (NAN1000000000 and above) still triggers a stack buffer overflow.
$ ./jq '8 != .' <<< 'NAN1000000000'
=================================================================
==2453849==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f0d88993870 at pc 0x55656ccc6eb9 bp 0x7ffeaa748a30 sp 0x7ffeaa748a20
WRITE of size 2 at 0x7f0d88993870 thread T0
#0 0x55656ccc6eb8 in decNumberCopy src/decNumber/decNumber.c:3375
#1 0x55656ccc79aa in decNaNs src/decNumber/decNumber.c:7706
#2 0x55656ccd01ba in decCompareOp src/decNumber/decNumber.c:6085
#3 0x55656cce4ef6 in decNumberCompare src/decNumber/decNumber.c:858
#4 0x55656cc71a63 in jvp_number_cmp src/jv.c:748
#5 0x55656cc7e93a in jvp_number_equal src/jv.c:773
#6 0x55656cc7e93a in jv_equal src/jv.c:1917
#7 0x55656cd1e5d5 in binop_notequal src/builtin.c:438
#8 0x55656cd1e5d5 in f_notequal src/builtin.c:55
#9 0x55656cc637b3 in jq_next src/execute.c:918
#10 0x55656cc590a9 in process src/main.c:185
#11 0x55656cc55772 in main src/main.c:724
#12 0x7f0d8b245ccf (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
#13 0x7f0d8b245d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
#14 0x55656cc58a74 in _start (/home/emanuele6/.source_code/jq/jq+0x14ca74) (BuildId: c6ebf62a567061fef19663a78d55e9f373c2232b)
Address 0x7f0d88993870 is located in stack of thread T0 at offset 112 in frame
#0 0x55656cc7183f in jvp_number_cmp src/jv.c:737
This frame has 3 object(s):
[32, 48) 'a' (line 737)
[64, 80) 'b' (line 737)
[96, 112) 'res' (line 746) <== Memory access at offset 112 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow src/decNumber/decNumber.c:3375 in decNumberCopy
Shadow bytes around the buggy address:
0x7f0d88993580: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x7f0d88993600: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x7f0d88993680: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 00 00 00 00
0x7f0d88993700: f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5 f5
0x7f0d88993780: f1 f1 f1 f1 00 00 f2 f2 00 00 f3 f3 00 00 00 00
=>0x7f0d88993800: f1 f1 f1 f1 00 00 f2 f2 00 00 f2 f2 00 00[f3]f3
0x7f0d88993880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7f0d88993900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7f0d88993980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7f0d88993a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7f0d88993a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
==2453849==ABORTING
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64953
CVE-2023-50268 was not fully fixed. Comparing a nan with at least 10 decimial digits of payload (
NAN1000000000and above) still triggers a stack buffer overflow.