Repository navigation
feat: opt-in SigV4 signing for DNS registration (#173 client half) - #242
Merged
Merged
Conversation
Step 2 of the #173 cutover that moves the DNS updater off the spoofable instance-identity-document path onto Lambda Function URL AuthType: AWS_IAM. pkg/dns/client.go now SigV4-signs the POST to the DNS Function URL with the instance role's ambient credentials (service=lambda, the Function URL's region) when SPORE_DNS_SIGV4 is set. Gated OFF by default so this signing build can roll out to instances BEFORE the infra-side AuthType flip — a signed request against the current AuthType: NONE URL is accepted unchanged (the auth headers are ignored), so the rollout is non-breaking and lockstep-safe. Does NOT close the vulnerability on its own: that needs the coordinated infra cutover (codify dns-updater in tofu, cross-account lambda:InvokeFunctionUrl grant, flip AuthType: AWS_IAM + IAM-aware handler, delete the legacy identity-doc/signature.go/cert code). #173 stays open to track that. Tests: unsigned-by-default (no Authorization header, proves non-breaking), signed-when-enabled (AWS4-HMAC-SHA256 header scoped to .../lambda/aws4_request), and signRequest no-op when disabled. No go.mod change (signer already in the dependency graph). Refs #173.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Jun 25, 2026
scttfrdmn
added a commit
that referenced
this pull request
Jun 25, 2026
…ver (#173) (#243) Two additive, non-breaking pieces that ready the fleet for the DNS Function URL AuthType: AWS_IAM flip (the destructive infra step stays gated): - spored's systemd unit now sets SPORE_DNS_SIGV4=1, so launched instances SigV4-sign their DNS-registration requests (the client signing path shipped in PR #242, dormant until now). Harmless while the Function URL is still AuthType: NONE (the signature is ignored); this fields a signing fleet so the later flip doesn't break in-flight registration. Non-signing instances age out under their TTLs. - the spored instance role grants ITSELF lambda:InvokeFunctionUrl on the spawn-dns-updater function (pkg/aws/iam.go buildInlinePolicy). This is the scalable alternative to enumerating launch accounts in the Lambda's resource policy — accounts are unbounded and spored role names are dynamic (spawn-instance-<hash>), so each role self-authorizes and the Lambda enforces that a caller may only write records under its own SigV4-verified account subdomain. Scoped to the single dns-updater ARN, account-pinned. Tests: TestSporedDNSInvokeGrant (grant present + scoped, not '*'); updated TestBuildInlinePolicy counts (3 -> 4 spored base statements). Full pkg/aws suite green. Does NOT close the vuln — the AuthType flip + verified-account handler are the remaining gated infra steps. Refs #173.
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
Refs #173 (does not close it). This is step 2 of the coordinated cutover that moves the DNS updater off the spoofable instance-identity-document path onto a Lambda Function URL with
AuthType: AWS_IAM.pkg/dns/client.gonow SigV4-signs the POST to the DNS Function URL with the instance role's ambient credentials (servicelambda, the Function URL's region) whenSPORE_DNS_SIGV4is set. That's exactly the principal the Lambda will authorize onceAuthTypeis flipped — replacing the "any valid EC2 identity doc" gate that today default-allows cross-account callers.Why gated / why this is safe to ship now
The fix is inherently cross-repo and must roll out in lockstep, or DNS registration breaks for every instance. This PR is the one slice that is purely additive:
AuthType: NONEFunction URL is accepted unchanged (the auth headers are simply ignored), so enabling the build changes nothing live.AuthTypeflip — shipping it now (dormant) makes the later flip a config change, not a redeploy race.Still required to actually close #173 (infra, not this repo)
lambda:InvokeFunctionUrlgrant to spored roles (additive).AuthType: AWS_IAM+ deploy the IAM-aware handler, in lockstep with turningSPORE_DNS_SIGV4on.signature.go/ embedded certs / cross-account default-allow.Tests
TestCallAPI_UnsignedByDefault— noAuthorizationheader when signing is off (proves non-breaking).TestCallAPI_SignedWhenEnabled—AWS4-HMAC-SHA256header scoped to.../us-east-1/lambda/aws4_request.TestSignRequest_NoOpWhenDisabled— the disabled guard.No
go.modchange — the v4 signer was already in the dependency graph.make checkgreen.