src: rethrow stack overflow exceptions in async_hooks When a stack overflow exception...
authorMatteo Collina <hello@matteocollina.com>
Sun, 26 Apr 2026 15:21:57 +0000 (17:21 +0200)
committerBastien Roucariès <rouca@debian.org>
Mon, 6 Apr 2026 14:18:52 +0000 (16:18 +0200)
commitcab95b46786107d4a6053958c1218c46542d23a8
tree24505d25ac25cdcb8113788ac08195ed8f8aa9cb
parente0c1373bd26802fabdf3241553e980fbb287008d
src: rethrow stack overflow exceptions in async_hooks When a stack overflow exception occurs during async_hooks callbacks (which use TryCatchScope::kFatal), detect the specific "Maximum call stack size exceeded" RangeError and re-throw it instead of immediately calling FatalException. This allows user code to catch the exception with try-catch blocks instead of requiring uncaughtException handlers.

The implementation adds IsStackOverflowError() helper to detect stack
overflow RangeErrors and re-throws them in TryCatchScope destructor
instead of calling FatalException.

This fixes the issue where async_hooks would cause stack overflow
exceptions to exit with code 7 (kExceptionInFatalExceptionHandler)
instead of being catchable.

Fixes: #37989
Ref: https://hackerone.com/reports/3456295
PR-URL: nodejs-private/node-private#773
Refs: https://hackerone.com/reports/3456295
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
CVE-ID: CVE-2025-59466
origin: backport, https://github.com/nodejs/node/commit/d7a5c587c02ebe18f9fe4de986bac55d80c2868f
bug: https://nodejs.org/en/blog/vulnerability/december-2025-security-releases#uncatchable-maximum-call-stack-size-exceeded-error-on-nodejs-via-async_hooks-leads-to-process-crashes-bypassing-error-handlers-cve-2025-59466---medium

Gbp-Pq: Name CVE-2025-59466.patch
src/async_wrap.cc
src/node_errors.cc
src/node_errors.h
test/parallel/test-async-hooks-stack-overflow-nested-async.js [new file with mode: 0644]
test/parallel/test-async-hooks-stack-overflow-try-catch.js [new file with mode: 0644]
test/parallel/test-async-hooks-stack-overflow.js [new file with mode: 0644]
test/parallel/test-uncaught-exception-handler-stack-overflow-on-stack-overflow.js [new file with mode: 0644]
test/parallel/test-uncaught-exception-handler-stack-overflow.js [new file with mode: 0644]