Skip to content

fix(docker): pin Bun's TLS trust to the OS CA store - #3040

Merged
clement-ux merged 3 commits into
masterfrom
clement/bun-use-system-ca
Oct 21, 2026
Merged

clement-ux merged 3 commits into
masterfrom
clement/bun-use-system-ca

Conversation

@clement-ux

@clement-ux clement-ux commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Why

On 2026-10-20, eMudhra TLS intermediates were compromised. The OS CA bundles (Debian, Alpine) are fixed and our CI rebuild picks them up. Bun is not fixed yet: it trusts its own built-in list of root certificates, which still includes the compromised eMudhra roots.

Why the first fix (--use-system-ca) did not work

The flag does not replace Bun's built-in list with the OS one, it adds the OS list to it. The compromised roots stay in Bun's list, so Bun still trusted the bad certificates. Tested in Docker: with the flag, Bun still connected to the compromised test site.

The fix

contracts/dockerfile-actions: CMD ["bun", "run", "--preload", "./bun-system-ca.ts", "runner.ts"]

A small preload script (./bun-system-ca.ts) makes Bun trust only the OS certificate bundle, for both fetch and node:tls/https. The --preload flag must come after run, otherwise Bun prints its help and exits without starting the app.

The actions themselves run under Node, which already uses the fixed OS bundle.

Tested (Docker, image built from this branch)

Compromised eMudhra site Normal sites (RPC, Discord, Google)
Before (prod today) accepted ❌ OK
After rejected ✅ OK

After deploy

Check that https://dv-g3b-emudhra.we-have-a-problem.com/ is rejected and an RPC call works from the new image. Rollback: release:propose with the previous digest of talos/origin-dollar (--origin-dollar), see talos infra/RUNBOOK.md "Roll back a bad deploy".

Dockerfile + one script only: no contract, address or ABI change.

🤖 Generated with Claude Code

Bun embeds its own copy of the Mozilla root store, so the CA bundle fixed
by the 2026-10-20 eMudhra intermediate compromise (ca-certificates in
Debian/Alpine) does not reach it until Bun ships a release. Pass
--use-system-ca so the runtime reads the OS store, which the CI rebuild
refreshes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--use-system-ca only adds the OS store to Bun's bundled Mozilla roots, so
the emSign roots distrusted after the 2026-10-20 eMudhra compromise stayed
trusted (verified in the container). Replace it with a preload that sets
the node:tls default CA list to the OS bundle and passes it as tls.ca on
every fetch, which ignores that default. --preload must follow `run`:
before it, Bun prints the run usage and exits 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clement-ux clement-ux changed the title fix(docker): make Bun trust the system CA store fix(docker): pin Bun's TLS trust to the OS CA store Oct 21, 2026
tls.setDefaultCACertificates and fetch's tls option are Bun runtime APIs
that the installed @types/node and DOM typings predate; talos typecheck
rejected them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clement-ux
clement-ux merged commit c83baa7 into master Oct 21, 2026
8 of 10 checks passed
@clement-ux
clement-ux deleted the clement/bun-use-system-ca branch October 21, 2026 15:48
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