Skip to content

Sign macOS binaries with allow-jit - #63

Open
mokagio wants to merge 1 commit into
mainfrom
mokagio/macos-allow-jit-entitlement
Open

mokagio wants to merge 1 commit into
mainfrom
mokagio/macos-allow-jit-entitlement

Conversation

@mokagio

@mokagio mokagio commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

The macOS binaries are signed with the hardened runtime but no entitlements, and under those conditions Bun silently runs with its JIT off.

Nothing fails: the binary starts, notarizes, and passes smoke tests, so the signing checks never caught it.

This came up while setting up CLI signing for another Bun project.

Measured on the shipped 0.6.4 binaries, with a CPU-bound JavaScript loop:

Binary Time JIT
arm64, shipped ~1,690 ms off
arm64, this PR's build ~144 ms on
x64 under Rosetta, shipped ~1,500 ms off
x64 under Rosetta, this PR's build ~220 ms on

Impact

Startup doesn't change: --version, --help and chats --help take about 200 ms with or without the entitlement. So only CPU-heavy JavaScript gets faster, and most commands, which wait on I/O, may not change noticeably. I didn't time commands that talk to a server.

Tradeoff

allow-jit is the only entitlement added. Bun needs it to run its JIT, and the other hardened runtime protections stay on, including library validation and the block on unsigned executable memory. The cost is that a memory-corruption bug would have an easier route to running code. It seems a small added risk for a CLI that runs its own bundled code.

How to test

Build 17 built from source, then signed and notarized both architectures. From its downloaded release archives, both binaries have the entitlement, spctl reports Notarized Developer ID, and the JIT is on.

verify_code_signing fails on the shipped 0.6.4 binary, on one with the entitlement set to false, and on an ad-hoc signature.

packages/cli/scripts/sign-macos-binaries.ts got the same flag, but neither Buildkite nor my local runs exercise it.

To reproduce on a built or released binary:

bundle exec fastlane verify_code_signing binary:<path>
BUN_BE_BUN=1 <path> <script>   # `numberOfDFGCompiles` from `bun:jsc` returns 1000000 with the JIT off

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants