Commit 77ab500
committed
fix(GHSA-6785-pvv7-mvg7): cap Buffer.alloc family with bufferAllocLimit option
Sandbox `Buffer.alloc(N)` (and allocUnsafe / allocUnsafeSlow /
deprecated `Buffer(N)` / `new Buffer(N)`) executes as a single
synchronous host C++ allocation. V8's `timeout` option cannot interrupt
it. A single ~100-byte sandbox payload could drive a 100 MB+ host RSS
jump and crash the host process via OOM in memory-constrained
environments.
New `bufferAllocLimit` option on VM constructor (default Infinity,
opt-in):
- lib/vm.js: validate option, plumb through `data` channel.
- lib/setup-sandbox.js: `checkBufferAllocLimit(size)` helper. The four
sandbox-side wrappers (alloc, allocUnsafe, allocUnsafeSlow, plus
BufferHandler.apply/construct for the deprecated Buffer(N) form) call
the helper before delegating. The new `alloc` wrapper is registered
via `connect()`. The captured host allocator is invoked via raw
`Reflect.apply` to avoid re-entering our own wrapper.
Oversized requests throw RangeError synchronously with no host
allocation.
Documented residuals: `new Uint8Array(N)`, `new ArrayBuffer(N)`,
`new SharedArrayBuffer(N)` and other typed-array constructors share the
same primitive class; `String.prototype.repeat(N)` is a similar surface;
repeated allocations under the cap (per-call, not aggregate budget).1 parent 6bbfbb3 commit 77ab500
4 files changed
Lines changed: 280 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1584 | 1584 | | |
1585 | 1585 | | |
1586 | 1586 | | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
1587 | 1643 | | |
1588 | 1644 | | |
1589 | 1645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
327 | 345 | | |
328 | 346 | | |
329 | 347 | | |
| |||
390 | 408 | | |
391 | 409 | | |
392 | 410 | | |
| 411 | + | |
| 412 | + | |
393 | 413 | | |
394 | 414 | | |
395 | 415 | | |
396 | 416 | | |
397 | 417 | | |
398 | 418 | | |
399 | 419 | | |
| 420 | + | |
| 421 | + | |
400 | 422 | | |
401 | 423 | | |
402 | 424 | | |
| |||
421 | 443 | | |
422 | 444 | | |
423 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
424 | 459 | | |
425 | 460 | | |
426 | 461 | | |
427 | 462 | | |
428 | 463 | | |
429 | 464 | | |
430 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
431 | 470 | | |
432 | 471 | | |
433 | 472 | | |
| |||
440 | 479 | | |
441 | 480 | | |
442 | 481 | | |
| 482 | + | |
| 483 | + | |
443 | 484 | | |
444 | 485 | | |
445 | 486 | | |
| |||
0 commit comments