Skip to content

cli: implement Node.js hardening flags (--disable-proto, --disallow-code-generation-from-strings, --frozen-intrinsics) - #35766

Closed
robobun wants to merge 12 commits into
mainfrom
farm/9be24fe8/node-hardening-flags
Closed

robobun wants to merge 12 commits into
mainfrom
farm/9be24fe8/node-hardening-flags

cli: implement Node.js hardening flags (--disable-proto, --disallow-c…

a0b93fd
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 25, 2026 in 14m 52s

Code review found 4 potential issues

Found 5 candidates, confirmed 4. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 4
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/cli/Arguments.rs:1332-1335 Extraneous trailing newline in --secure-heap warning
🟡 Nit src/js/internal/freeze_intrinsics.ts:296-298 freeze_intrinsics override setter references uncaptured TypeError/String
🟡 Nit test/js/node/process/node-hardening-flags.test.ts:131-135 Invalid --disable-proto mode test should assert exit code 12
🟡 Nit src/js/node/events.ts:65 EventEmitter constructor uses uncaptured Object.getPrototypeOf

Annotations

Check warning on line 1335 in src/runtime/cli/Arguments.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Extraneous trailing newline in --secure-heap warning

The trailing `\n` in this format string produces a double newline in stderr — `bun_core::warn!` expands to `pretty_errorln!`, which already appends one. Every other `bun_core::warn!` call in this file (lines 1241, 1246, 1251, 1262, 1285, 1290, 2373) omits the trailing `\n`; drop it here for consistency.

Check warning on line 298 in src/js/internal/freeze_intrinsics.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

freeze_intrinsics override setter references uncaptured TypeError/String

The `enableDerivedOverride` setter references bare `TypeError` and `String`, which resolve via `globalThis` at user-code time — but `globalThis` itself is not frozen (only the `.globalThis` slot is), so user code can null these out and degrade the thrown error. The file already captures a dozen other primordials at module-load time for exactly this reason (and Node's `freeze_intrinsics.js` pulls both from `primordials`); consider capturing `const _TypeError = TypeError` and `const _String = Stri

Check warning on line 135 in test/js/node/process/node-hardening-flags.test.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Invalid --disable-proto mode test should assert exit code 12

This test asserts `expect(exitCode).not.toBe(0)`, but the handler explicitly calls `Global::exit(12)` (matching Node.js's exit code for invalid CLI options, and the PR description's "Invalid modes exit 12"). Consider tightening to `expect(exitCode).toBe(12)` so a regression to a generic `exit(1)` or crash wouldn't silently pass.

Check warning on line 65 in src/js/node/events.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

EventEmitter constructor uses uncaptured Object.getPrototypeOf

Since you're touching this expression for hardening reasons anyway, consider using the `$getPrototypeOf(this)` intrinsic (declared in `src/js/builtins.d.ts:96`) instead of a runtime `Object.getPrototypeOf` lookup. REVIEW.md's built-in-JS rules call for $-prefixed intrinsics / globals captured at module load in `src/js/`, and Node's own `lib/events.js` uses the `ObjectGetPrototypeOf` primordial here — otherwise userland `Object.getPrototypeOf = () => null` breaks every subsequent `new EventEmitte