Commit 10aecc9
committed
fix(sandbox): expand CodeSandbox hardening to block realm intrinsics
CodeRabbit review on the SandboxedToolForge -> CodeSandbox consolidation
flagged the extraGlobals denylist as incomplete and the contextObj as
missing five realm intrinsics that node:vm exposes by default but
untrusted sandbox code has no legitimate need for.
Expanded both surfaces in lockstep:
- DANGEROUS_GLOBAL_KEYS now includes Reflect, Proxy, WebAssembly,
SharedArrayBuffer, Atomics so extraGlobals callers cannot inject them
- contextObj explicitly nulls the same five identifiers so the realm
intrinsics resolve to undefined inside the sandbox
Closes the Reflect.construct(Function, [...])() reflection escape that
would otherwise sidestep codeGeneration: { strings: false }, blocks
Proxy-based prototype-chain attacks, and removes the SharedArrayBuffer
/ Atomics Spectre side-channel surface. WebAssembly was already
blocked via codeGeneration: { wasm: false } but nulled here for
belt-and-suspenders.
ICodeSandbox.ts JSDoc reorganized to match the categorized denylist.
New test 'drops the expanded danger list' locks the behavior. All 74
CodeSandbox + 29 SandboxedToolForge tests green.1 parent 9fae662 commit 10aecc9
3 files changed
Lines changed: 62 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
64 | 76 | | |
65 | 77 | | |
66 | 78 | | |
| |||
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
310 | 334 | | |
311 | 335 | | |
312 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
320 | 351 | | |
321 | 352 | | |
322 | 353 | | |
| |||
0 commit comments