Skip to content

action: add mTLS security to multi-arch buildkitd#89

Draft
adityamaru wants to merge 1 commit intodevin/1775273254-multiarch-insecure-buildkitdfrom
devin/1775274331-multiarch-mtls
Draft

action: add mTLS security to multi-arch buildkitd#89
adityamaru wants to merge 1 commit intodevin/1775273254-multiarch-insecure-buildkitdfrom
devin/1775274331-multiarch-mtls

Conversation

@adityamaru
Copy link
Copy Markdown
Contributor

@adityamaru adityamaru commented Apr 4, 2026

Summary

Adds mTLS authentication to the multi-arch follower buildkitd connection, preventing unauthorized access to the exposed buildkitd TCP port.

Before (PR #88): Follower buildkitd listens on a publicly-reachable tcp://vm-xxx.vm.blacksmith.sh:port with no authentication — anyone who guesses the hostname+port can submit builds.

After: The leader generates an ephemeral CA + server/client certificate pair (EC P-256, 1-day validity). Server certs are SCP'd to the follower; buildkitd starts with --tlscacert/--tlscert/--tlskey. The leader connects via --driver-opt cacert=…,cert=…,key=…. Only the leader possesses the client cert signed by the ephemeral CA.

Flow:

  1. generateMTLSCerts() — creates CA, server cert, client cert in /tmp
  2. pushServerCertsToFollower() — SCPs CA + server cert/key to follower
  3. startFollowerBuildkitd() — starts buildkitd with TLS flags
  4. buildx create --append --driver-opt cacert=…,cert=…,key=… — leader connects with client cert

All certs are ephemeral and die with the VMs.

Review & Testing Checklist for Human

  • buildctl readiness check reuses server cert as client cert (multiarch.ts:388-392): The health check on the follower runs buildctl --tlscert server.crt --tlskey server.key. This works because buildkitd just validates the cert is CA-signed, but verify this is the intended behavior vs. using a dedicated client cert on the follower side.
  • Bash process substitution for SAN extension (multiarch.ts:188): Uses <(printf "subjectAltName=…") with { shell: "/bin/bash" }. Confirm all target runner images have /bin/bash available (should be fine for Ubuntu-based Blacksmith VMs).
  • --driver-opt format: Verify that passing each driver opt as a separate --driver-opt key=value flag (not comma-separated) is the correct format for the remote driver. Docker docs suggest this is correct.
  • End-to-end test: Trigger a multi-arch build (linux/amd64,linux/arm64) on a Blacksmith runner with both PRs deployed. Verify buildkitd logs show TLS handshake and that an unauthenticated buildctl connection to the exposed port is rejected.

Notes

  • Comment in generateMTLSCerts says "valid for 1 hour" but the openssl command uses -days 1 (24 hours). Functionally fine since builds are much shorter, but the comment is inaccurate.
  • Cert cleanup is implicit — /tmp dies with the VM. No explicit cleanup added.
  • This PR is stacked on top of action: implement multi-arch buildkitd with insecure mode #88 (insecure buildkitd). Base branch is devin/1775273254-multiarch-insecure-buildkitd.

Link to Devin session: https://app.devin.ai/sessions/4bed582243a84e75be318f407802a563
Requested by: @adityamaru


View in Codesmith

  • Auto-fix issues

Codesmith can help with this PR — just tag @codesmith or enable auto-fix issues. Settings

Co-Authored-By: maru@blacksmith.sh <adityamaru@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant