-
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
bugSomething isn't workingSomething isn't working
Description
cjs-module-lexer has a stack depth of 2048:
Line 8 in dd9d9f9
| #define STACK_DEPTH 2048 |
this creates two stacks:
Lines 36 to 37 in dd9d9f9
| uint16_t templateStack_[STACK_DEPTH]; | |
| uint16_t* openTokenPosStack_[STACK_DEPTH]; |
However, when pushing to these stacks, there is no bounds check performed. For example:
Line 164 in dd9d9f9
| openTokenPosStack[openTokenDepth++] = lastTokenPos; |
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.
SukkaW
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working