You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A malformed snapshot, after deserialization, produces bytecode with anomalous register_end / literal_end fields. When the VM executes it, vm_init_exec computes literal_start_p and the register area from these untrusted fields (vm.c:5190 reads data in the literal_end range), pointing outside the 24-byte shared struct (frame [32,56)) on the vm_run_global stack. ASan reports a stack-buffer-overflow: READ of size 8 at offset 56 — an out-of-bounds read of the stack variable shared.
Affected: JerryScript 3.0.0 (jerry-core/vm/vm.c:5190 in vm_init_exec, reached from vm_run_global at jerry-snapshot.c:1024)
Severity: High
CWE: CWE-125 (Out-of-bounds Read)
Detail
The root cause is again in the snapshot deserialization stage: the bytecode header fields register_end / literal_end / argument_end are not validated for consistency, so an illegal layout propagates into VM initialization. A 122-byte malformed snapshot is sufficient to trigger the stack OOB read and abort the process.
ERROR: AddressSanitizer: stack-buffer-overflow on address ... READ of size 8 at offset 56
#0 ... vm_init_exec vm.c:5190
#1 ... vm_run_global jerry-snapshot.c:1024
#2 ... fuzz_snapshot harness.c
The read goes 8 bytes past the 24-byte shared struct on the stack frame.
Replay exit code: 134 (ASan abort)
Deterministic: yes.
Impact
A 122-byte malformed snapshot deterministically triggers an ASan stack OOB read and aborts the process (DoS). The defect is a stack OOB read; primary impact is process crash. If a future path reuses the OOB-read address for a write (e.g., the VM writing back to the register area), stack corruption becomes possible, raising severity. On the current evidence, impact is DoS.
Suggested fix
Validate register_end / literal_end / argument_end consistency during snapshot deserialization; reject bytecode where the register/literal regions exceed the snapshot bounds.
In vm_init_exec, bound-check the computed literal_start_p / register area against the actual ecma_compiled_code_t extent before dereferencing.
Opened #5310 with a fix. vm_init_exec() was choosing the shared-frame layout
from argument_end (a bytecode header field) while the layout is really
described by VM_FRAME_CTX_SHARED_HAS_ARG_LIST, which is only set by callers
that actually build the args variant. The JERRY_ASSERT that would have caught
the mismatch is compiled out with NDEBUG. The fix tests the flag instead.
Re-verified on current master (b706935), 122-byte snapshot:
Distinct from #5301: #5301 is the unchecked function/literal offsets in jerry_exec_snapshot/snapshot_load_compiled_code (fixed by #5311), whereas
this one is reached later, in the VM, after a snapshot loads successfully.
Activity
[-]Malformed snapshot bytecode drives VM-init stack-buffer-overflow (vm_init_exec, vm.c:5190) (CWE-125)[/-][+][Bug]Malformed snapshot bytecode drives VM-init stack-buffer-overflow (vm_init_exec, vm.c:5190) (CWE-125)[/+]1820893135-pixel commentedon Sep 23, 2026
Opened #5310 with a fix.
vm_init_exec()was choosing the shared-frame layoutfrom
argument_end(a bytecode header field) while the layout is reallydescribed by
VM_FRAME_CTX_SHARED_HAS_ARG_LIST, which is only set by callersthat actually build the args variant. The
JERRY_ASSERTthat would have caughtthe mismatch is compiled out with
NDEBUG. The fix tests the flag instead.Re-verified on current
master(b706935), 122-byte snapshot:Distinct from #5301: #5301 is the unchecked function/literal offsets in
jerry_exec_snapshot/snapshot_load_compiled_code(fixed by #5311), whereasthis one is reached later, in the VM, after a snapshot loads successfully.