action: add mTLS security to multi-arch buildkitd#89
Draft
adityamaru wants to merge 1 commit intodevin/1775273254-multiarch-insecure-buildkitdfrom
Draft
action: add mTLS security to multi-arch buildkitd#89adityamaru wants to merge 1 commit intodevin/1775273254-multiarch-insecure-buildkitdfrom
adityamaru wants to merge 1 commit intodevin/1775273254-multiarch-insecure-buildkitdfrom
Conversation
Co-Authored-By: maru@blacksmith.sh <adityamaru@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:portwith 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:
generateMTLSCerts()— creates CA, server cert, client cert in/tmppushServerCertsToFollower()— SCPs CA + server cert/key to followerstartFollowerBuildkitd()— starts buildkitd with TLS flagsbuildx create --append --driver-opt cacert=…,cert=…,key=…— leader connects with client certAll certs are ephemeral and die with the VMs.
Review & Testing Checklist for Human
multiarch.ts:388-392): The health check on the follower runsbuildctl --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.multiarch.ts:188): Uses<(printf "subjectAltName=…")with{ shell: "/bin/bash" }. Confirm all target runner images have/bin/bashavailable (should be fine for Ubuntu-based Blacksmith VMs).--driver-optformat: Verify that passing each driver opt as a separate--driver-opt key=valueflag (not comma-separated) is the correct format for the remote driver. Docker docs suggest this is correct.linux/amd64,linux/arm64) on a Blacksmith runner with both PRs deployed. Verify buildkitd logs show TLS handshake and that an unauthenticatedbuildctlconnection to the exposed port is rejected.Notes
generateMTLSCertssays "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./tmpdies with the VM. No explicit cleanup added.devin/1775273254-multiarch-insecure-buildkitd.Link to Devin session: https://app.devin.ai/sessions/4bed582243a84e75be318f407802a563
Requested by: @adityamaru
Codesmith can help with this PR — just tag
@codesmithor enable auto-fix issues. Settings