Skip to content

feat: field DNS request signing + spored self-grant for IAM-auth cutover (#173) - #243

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

scttfrdmn merged 1 commit into
mainfrom
feat/173-dns-iam-enabler

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Refs #173 (does not close it). Two additive, non-breaking pieces that ready the fleet for the DNS Function URL AuthType: AWS_IAM flip — the destructive infra step stays gated.

This is the redesigned step 1 + the enabler. After discussion, we are NOT enumerating launch accounts in the Lambda's resource policy: spawn launches in unbounded accounts whose spored roles are dynamically named (spawn-instance-<hash>), so an allow-list means per-account enrollment and a ~20KB policy ceiling. Instead, security comes from SigV4 + the Lambda's verified-account namespacing, which needs zero allow-list upkeep and no per-region certs.

Changes

  • spored fields signing by default — its systemd unit now sets SPORE_DNS_SIGV4=1, so launched instances SigV4-sign DNS requests (client path shipped dormant in feat: opt-in SigV4 signing for DNS registration (#173 client half) #242). Harmless while the URL is still AuthType: NONE (signature ignored); this fields a signing fleet so the later flip doesn't break in-flight registration. Old instances age out under their TTLs.
  • spored self-grant — the instance role grants itself lambda:InvokeFunctionUrl on spawn-dns-updater (pkg/aws/iam.go). Each role self-authorizes; 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 to the dns-updater ARN, not *); updated TestBuildInlinePolicy statement counts (3 → 4 spored base statements). Full pkg/aws suite green; make check clean.

What remains (gated, infra-side — tracked in #173)

  • Step 0 (codify dns-updater in tofu) — done locally, imported, tofu plan clean (committed separately in the spore-host umbrella).
  • Step 3 — flip the Function URL to AuthType: AWS_IAM + deploy the verified-account-namespacing handler. DESTRUCTIVE; do only once a signing fleet is fielded (this PR shipped + old instances aged out).
  • Step 4 — delete the legacy identity-doc / signature.go / embedded certs / cross-account default-allow.

…ver (#173)

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.
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 9fac313 into main Jun 25, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the feat/173-dns-iam-enabler branch June 25, 2026 04:50
scttfrdmn added a commit that referenced this pull request Jun 25, 2026
…#173 step 3 code) (#244)

Rewrites the DNS updater entrypoint to the Lambda Function URL event shape and
authorizes on the SigV4-VERIFIED caller account instead of the spoofable
instance-identity document.

Dual-path, so deploying this handler is safe BEFORE the AuthType flip:
- AWS_IAM path (post-flip): read the verified caller account from
  requestContext.authorizer.iam and namespace the record under
  base36(verifiedAccountID).<domain>. Unspoofable; no EC2 describe, no embedded
  cert, no per-region maintenance (#294).
- legacy path (pre-flip, AuthType: NONE): no authorizer present → fall back to
  legacyAuthorize() (the extracted old identity-doc + validateInstance flow) so
  registration keeps working until the flip. Deny-by-default when neither auth is
  present. This branch is deleted in #173 step 4.

Preferring the verified account when present decouples the handler deploy from
the AuthType flip: deploying behaves exactly as today, and the flip alone
activates the secure path — a low-risk cutover.

Handler/response/error types moved APIGatewayProxyRequest/Response →
LambdaFunctionURLRequest/Response (the Function URL event shape, which the
current NONE URL already delivers). Route53 upsert/delete/alias logic unchanged.

Tests: TestLegacyAuthorizeRejectsMissingIdentity (deny-by-default when no
credible identity). Existing helper tests unchanged. NOT YET DEPLOYED and the
Function URL is NOT YET flipped — those gated steps wait until a SigV4-signing
fleet is fielded (PR #243 enabler shipped in a release + old instances aged out).
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.

1 participant