Skip to content

fix: support Bun module accessor descriptors (fixes #386) - #443

Open
RyanGarber wants to merge 1 commit into
vercel-labs:mainfrom
RyanGarber:fix/bun-module-accessor-descriptors
Open

RyanGarber wants to merge 1 commit into
vercel-labs:mainfrom
RyanGarber:fix/bun-module-accessor-descriptors

Conversation

@RyanGarber

@RyanGarber RyanGarber commented Sep 20, 2026

Copy link
Copy Markdown

just-bash currently is entirely unusable with Bun (see #386).

Bun exposes Module._resolveFilename as an accessor descriptor. Spreading that descriptor and adding value creates an invalid mixed descriptor. This means even new Bash(...).exec("echo hello") fails when running in Bun, with DefenseInDepthBox: critical patches failed: Module._resolveFilename.

This installs a valid data descriptor for accessor-backed module methods in both DefenseInDepthBox and WorkerDefenseInDepth. Preserves enumerability/configurability and derive writability from setter availability. Existing data descriptors, blocking proxies, installation verification, fail-closed behavior, and saved descriptors used for teardown remain intact. Nothing about the existing defense-in-depth behavior changes.

Also adds a patch changeset and subprocess regression tests for getter-only and getter/setter descriptors, both module methods, main/worker blocking, and exact descriptor restoration.

Validation:

  • Accessor and lifecycle tests: 10 passed.
  • Built CLI on Bun 1.3.14: echo bun returns exit 0 with empty stderr.
  • Repository build/typecheck, lint:fix, and knip passed.
  • New accessor regressions fail against the unmodified upstream source and pass with this fix; generated-worker sync also passes.
  • Full pnpm test:run is not clean locally: 15,534 passed, 22 failed, 98 skipped, plus 7 runner errors. Failures include XZ tests after the optional node-liblzma install failed (node-gyp unavailable), timeout-sensitive tests under load, and process.env descriptor errors from the bundle/Vitest interaction. All unrelated to the changes in this PR.

@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

@RyanGarber is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@auto-maintain

auto-maintain Bot commented Sep 20, 2026

Copy link
Copy Markdown

🤖 auto-maintain review

Automated, advisory triage for @RyanGarber's PR. Facts below are read from the GitHub API.

Check Result
Author's merged PRs (this repo) 0 — ⚠️ first-time contributor
Account established ✅ (age 5176d · 12 followers · 29 public repos)
Commits signed/verified ✅ 1/1
Changeset included ✅ (.changeset/bun-module-accessors.md)

Review panel: 🟡 medium highest severity

just-bash maintainer code review: 🟢 low

No actionable correctness or maintainability issues found in the complete diff.

General code review: 🟢 low

No actionable correctness or compatibility issues found in the complete diff.

Adversarial security: 🟢 low

No actionable adversarial security findings in the complete base-to-head diff.

Adversarial security (second opinion): 🟢 low

Accessor-descriptor handling for Bun's Module._load/_resolveFilename is additive and fail-closed: the Node data-descriptor path is unchanged, the new branch installs through the host setter with post-install verification, adds a write gate that closes a setter-swap hole, and registers rollback before invoking host code with correct teardown ordering. No backdoor, exfiltration, dependency, or CI changes found.

Standard Bash and host portability: 🟡 medium

The runtime fix is portable, but the new Bun regression tests use a non-portable filesystem path conversion.

  • packages/just-bash/src/security/module-accessor-descriptors.bun.test.ts:32 — Using URL.pathname as `cwd` leaves percent-encoded characters (for example `%20`) and produces unsuitable Windows drive paths, so Bun tests fail in checkouts with spaces/non-ASCII names or on Windows. Convert the URL with `fileURLToPath()` instead.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

@RyanGarber RyanGarber changed the title fix: support Bun module accessor descriptors fix: support Bun module accessor descriptors [#386] Sep 20, 2026
@RyanGarber RyanGarber changed the title fix: support Bun module accessor descriptors [#386] fix: support Bun module accessor descriptors #386 Sep 20, 2026
@RyanGarber RyanGarber changed the title fix: support Bun module accessor descriptors #386 fix: support Bun module accessor descriptors (fixes #386) Sep 20, 2026
@RyanGarber
RyanGarber marked this pull request as ready for review September 20, 2026 17:59
Copilot AI lite review requested due to automatic review settings September 20, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The reviewed changes have no unresolved issues blocking approval.

Review effort: Lite
Findings: None

What changed in this PR

Fixes Bun compatibility by safely handling accessor descriptors for protected module methods.

Changes:

  • Supports accessor-backed descriptors in main and worker protections.
  • Adds regression tests for blocking and descriptor restoration.
  • Adds a patch changeset.
File Description
packages/​just-bash/​src/​security/​worker-defense-in-depth.ts Handles accessor-backed module methods in worker protection.
packages/​just-bash/​src/​security/​module-accessor-descriptors.test.ts Tests accessor variants, blocking, and restoration.
packages/​just-bash/​src/​security/​defense-in-depth-box.ts Handles accessor-backed module methods in main protection.
.changeset/​bun-module-accessors.md Documents the patch release.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@RyanGarber
RyanGarber force-pushed the fix/bun-module-accessor-descriptors branch from 3891c53 to 9442c46 Compare September 22, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants