Open
Description
cjs-module-lexer has a stack depth of 2048:
Line 8 in dd9d9f9
this creates two stacks:
Lines 36 to 37 in dd9d9f9
However, when pushing to these stacks, there is no bounds check performed. For example:
Line 164 in dd9d9f9
If you run with a maliciously crafted input, you can overflow the stack and cause memory corruption.
import { parse, init } from 'cjs-module-lexer';
await init();
console.log(parse('exports.foo = 2;\n' + '{'.repeat(3069) + '}'.repeat(3069)));
Running this causes a Bus error: 10
crash.
This can also cause a crash of node itself by writing the above contents to a file and importing it via ESM.
Activity