Skip to content

feat: opt-in SigV4 signing for DNS registration (#173 client half) - #242

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/173-dns-sigv4-client
Jun 25, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/173-dns-sigv4-client

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

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.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. That's exactly the principal the Lambda will authorize once AuthType is 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:

  • Signing is off by default. A SigV4-signed request against the current AuthType: NONE Function URL is accepted unchanged (the auth headers are simply ignored), so enabling the build changes nothing live.
  • The signing build must reach instances before the infra AuthType flip — 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)

  1. Codify the dns-updater in tofu (import existing fn — no endpoint change).
  2. Cross-account lambda:InvokeFunctionUrl grant to spored roles (additive).
  3. (this PR) client SigV4 signing.
  4. Flip Function URL AuthType: AWS_IAM + deploy the IAM-aware handler, in lockstep with turning SPORE_DNS_SIGV4 on.
  5. Delete the legacy identity-doc parsing / signature.go / embedded certs / cross-account default-allow.

Tests

  • TestCallAPI_UnsignedByDefault — no Authorization header when signing is off (proves non-breaking).
  • TestCallAPI_SignedWhenEnabled — AWS4-HMAC-SHA256 header scoped to .../us-east-1/lambda/aws4_request.
  • TestSignRequest_NoOpWhenDisabled — the disabled guard.

No go.mod change — the v4 signer was already in the dependency graph. make check green.

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

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 27.50000% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/dns/client.go 27.50% 26 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 571d2d0 into main Jun 25, 2026
6 of 7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/173-dns-sigv4-client branch June 25, 2026 00:21
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.
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.

[HIGH] dns-updater accepts unsigned identity docs + default-allows cross-account → Route53 spoofing

1 participant