Log date · Sat
Does Bun bytecode protect your source code?
Bun bytecode is a startup optimization, not source protection. We compare two executables and explain the 1.4.3 runtime restriction.
The answer: bytecode is not secrecy
Do not treat Bun bytecode as source protection. With Bun 1.3.11 we built our own program as a plain executable and with --bytecode: both ran and printed 42, both contained the exact test marker, and each was 61,069,216 bytes. Bun likewise describes bytecode as a startup optimization, not obfuscation. [3]
| Question | Result |
|---|---|
| Did both builds run? | Both printed the same marker and 42. |
| Was the marker present? | An exact match was found in both files. |
| File sizes? | 61,069,216 bytes each. |
| Does this test 1.4.3? | No; the installed version was 1.3.11. |
This comparison checks one string and one execution path. It does not establish that the older build actually used bytecode, or test the performance and security fixes in 1.4.3. Equal file sizes do not prove identical contents and say nothing about startup speed in a large application.
What changed in 1.4.3
Bun released v1.4.3 at 05:24 UTC on October 10, 2026. [1] Its notes describe --bytecode-order, which lays out bytecode using a profile from a real run; --compile-jit-policy adjusts JIT tier-up thresholds, and --no-optimize-bytecode skips build-time bytecode optimization. The release reports 3–6% smaller --bytecode output; that is the publisher’s result, not our measurement. [2]
The release also fixed changing bytes across builds with --compile --bytecode --format=esm --splitting, and a crash when a debugger connected after a bytecode executable called inspector.open(). [2] Reproducing a hash helps compare builds only when the toolchain, dependencies and inputs are controlled; matching hashes alone do not establish that the source is trustworthy.
The notes also list TLS server verification during the handshake and certificate name-matching hardening, including CVE-2026-48618. Review those changes against your own networking code when upgrading. [2]
Our sample: output and marker
The sample contains a marker that is clearly not a secret and computes 42 with new Function. On the same machine, we built both files from the same source, ran them, then searched each file for the exact bytes.
const marker = 'DEMO-MARKER-not-a-secret-2026';
console.log('marker:', marker);
console.log('dynamic:', new Function('return 6 * 7')());== Run both ==
marker: DEMO-MARKER-not-a-secret-2026
dynamic: 42
marker: DEMO-MARKER-not-a-secret-2026
dynamic: 42
== Inspect exact sample marker ==
plain: present
bytecode: present
== File sizes in bytes ==
plain: 61069216
bytecode: 61069216An exact match answers only whether those bytes occur. A miss would not establish that other strings or transformed content are unreadable. Current Bun documentation says the compiled executable contains both code and bytecode. [3] Treat the entire client artifact as material delivered to its recipient, and keep shared privileged credentials out of it.
Runtime restrictions address a different problem
The 1.4.3 notes say that --disallow-code-generation-from-strings=strict embedded with --compile-exec-argv always applies: BUN_OPTIONS can raise the level but cannot lower it. [2] The ordinary level blocks eval and new Function; strict covers further paths that execute strings as code. This constrains runtime behavior; it does not hide code already shipped.
Our 1.3.11 sample returned 42 from new Function; it cannot verify the new restriction or environment-variable precedence. Before enabling it, test templates, plugins, workers and other features that generate code on the target version. The current documentation says to attach strict with an equals sign: a space can select a different level. [4]
Recommendations by case
These are engineering recommendations, not benefits measured by our experiment.
| Case | Action |
|---|---|
| Faster startup | Pin the version and compare realistic workloads under cold-start conditions. |
| Protect a server credential | Keep it on a controlled server; use scoped, revocable tokens. |
| Restrict dynamic code | Embed strict on the target Bun version; test features and environment precedence. |
| Check release integrity | Pin inputs, rebuild independently, compare hashes, then sign. |
If using a startup profile, exercise paths users actually take and measure again when dependencies or workloads change. Do not extrapolate performance from one small file-size result. Record the machine, version, build flags and repeated cold-start results so the comparison is meaningful.
Check your own build
Start with a test placeholder and an artifact you are authorized to inspect. The build commands below target 1.4.3; replace the entry point and paths for your project and check the version first. Search output can contain sensitive information, so do not put real credentials in commands or public logs.
bun --version
bun build --compile ./app.js --outfile ./app-plain
bun build --compile --bytecode ./app.js --outfile ./app-bytecode
LC_ALL=C grep -aqF "DEMO-MARKER-not-a-secret-2026" ./app-bytecode && echo presentTo test strict, embed the flag shown in the release notes, run normal features and a dynamic-code path expected to be rejected in an isolated environment, then test that BUN_OPTIONS cannot lower the restriction. Check that inspector.open() is used only where intended. Before release, review modules, assets and source maps; pin dependencies and compare hashes from two independent builds. Finally sign and notarize as appropriate for the target platform.
bun build --compile ./app.js --outfile ./app-strict \
--compile-exec-argv="--disallow-code-generation-from-strings=strict"
./app-strictYour checklist
- Pin the Bun version and record build flags.
- Inventory code, assets and source maps in the artifact.
- Keep shared privileged credentials on the server.
- Test strict and dynamic-code dependencies on the target version.
- Pin inputs, rebuild independently and compare hashes.
Primary sources
- GitHub: oven-sh/bun release Bun v1.4.3 · Source date 2026-10-10 · Checked 2026-10-12
- Bun Blog: Bun v1.4.3 · Source date 2026-10-10 · Checked 2026-10-12
- Bun documentation: Bytecode caching · Checked 2026-11-11
- Bun documentation: Code generation from strings · Checked 2026-11-11