Skip to content

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

Closed

Description

@scttfrdmn

Severity: HIGH — from the 2026-06 suite audit. Chosen fix: switch to IAM auth (no identity-doc / no cert).

The vulnerability (confirmed)

lambda/dns-updater/main.go: signature verification is non-fatal (logs "skipped … continuing" on failure), and the only other gate validateInstance returns ALLOW whenever DescribeInstances errors (which it always does cross-account — the Route53 zone is in the infra account by design). FQDN/record/IP come from attacker-controllable request fields. Net: an unauthenticated caller can UPSERT/DELETE arbitrary A-records.

Why we are NOT fixing this with the identity-document / PKCS#7 path

Investigated thoroughly (live, against a real instance):

  • The IMDS PKCS#7 / rsa2048 envelope contains zero embedded certs (verified by decoding a real envelope) — so verification requires embedding AWS's public cert.
  • AWS uses a distinct, self-signed RSA-2048 cert per region (~35 of them), published only in JS-rendered docs (no machine-readable URL; probed several, all 404/400). Self-signed ⇒ spored can't just "pass the cert along" (an attacker passes their own self-signed cert and it verifies).
  • spawn's currently-embedded certs are corrupt (won't parse) — verification has never actually worked; the endpoint has relied entirely on the skip-and-allow hole.
  • AWS just relocated/removed the verify-pkcs7.html doc page, demonstrating the cert-maintenance fragility (this is the recurring [audit] Dup: formatDuration and formatDurationForTTL are byte-identical — collapse to one #294 problem).

So the PKCS#7 path means hand-maintaining ~35 self-signed certs AWS rotates — rejected.

The fix: AWS_IAM auth on the DNS Lambda Function URL

The DNS updater is a Lambda Function URL (…lambda-url.us-east-1.on.aws), and the same infra already uses AuthType: AWS_IAM for the spore-bot admin API — so this is an established pattern, not a novel one.

Server (infra account, where the deploy lives — NOT this repo):

  1. Set the DNS Function URL AuthType: AWS_IAM.
  2. Grant the spored instance role (in each spawn launch account) lambda:InvokeFunctionUrl on the DNS function (cross-account resource policy + the role's own grant).
  3. Lambda reads the verified caller account/role ARN from the request's IAM/SigV4 identity (requestContext.authorizer.iam / signed principal) instead of parsing the identity document.

Client (pkg/dns/client.go, this repo):
4. SigV4-sign the POST with the instance role creds (aws-sdk-go-v2 signer) instead of a plain http.NewRequestWithContext.

Lambda (lambda/dns-updater/main.go):
5. Derive the FQDN's account subdomain from the verified caller account (not req.InstanceIdentityDocument/req.IPAddress).
6. Delete: identity-document parsing, verifyInstanceIdentitySignature, signature.go's embedded certs, and the cross-account default-allow in validateInstance.

Result: no identity document, no signature, no embedded cert, nothing to rotate (#294 closed for good), and stronger containment — only principals we explicitly grant can call at all, vs. "any valid EC2 doc".

Why this must be a COORDINATED client+infra change (not shippable from spawn repo alone)

If the client starts SigV4-signing but the Function URL AuthType flip + cross-account InvokeFunctionUrl grant aren't deployed in lockstep, all DNS registration breaks in prod. The deploy that owns the DNS Lambda + Function URL is in infra outside this repo. So execution order:

  1. Infra PR: cross-account InvokeFunctionUrl grant to spored roles (additive, safe to land first).
  2. Client PR (this repo): SigV4 signing, behind the existing endpoint config.
  3. Infra: flip AuthType to AWS_IAM + deploy the Lambda handler change — in lockstep with (2) rolling out.
  4. Remove the legacy identity-doc/cert code.

Interim

Not making verification fatal alone (the embedded certs are corrupt + the caller re-marshals the doc, so it would break ALL registration). The hole stays open only as long as the IAM cutover is pending; prioritize the infra grant + cutover. Live test plan: a throwaway instance SigV4-calls the IAM-auth Function URL and registers a record; verify an unsigned call now gets 403.

Priority

P0. Cross-repo (spawn client + infra). Companion HIGH #174 (CreateTags scoping) is independent and shipping separately.

Activity

  1. added
    bug
    on Jun 15, 2026
  2. scttfrdmn commented on Jun 24, 2026

    @scttfrdmn
    ContributorAuthor

    Infra prerequisite found

    Checked the spore-host umbrella: the dns-updater Lambda + Function URL are NOT under infrastructure-as-code. infra/tofu/ contains only spore-bot/main.tf (and that Function URL is authorization_type = "NONE"). The DNS Lambda (zqonqra6…lambda-url.us-east-1.on.aws) was deployed out-of-band (console/manual), so there's no IaC to PR the AuthType: AWS_IAM flip + cross-account InvokeFunctionUrl grant against today.

    So the IAM-auth cutover gains a step 0: bring the dns-updater under tofu in spore-host/infra/tofu/dns-updater/ (Lambda, Function URL, Route53 perms, env: DOMAIN_ZONES/DEFAULT_DOMAIN), importing the existing function so the live endpoint URL is preserved. Then the cutover (cross-account grant → client SigV4 → flip AuthType → remove legacy cert code) proceeds as described above. The aws_lambda_function_url resource in spore-bot/main.tf is the template for the Function-URL + permission wiring.

    Revised execution order:
    0. infra (spore-host): codify the dns-updater in tofu (import existing fn → no endpoint change).

    1. infra: add cross-account lambda:InvokeFunctionUrl grant for spored roles (additive).
    2. spawn (client): SigV4-sign the DNS request.
    3. infra: flip Function URL authorization_type = "AWS_IAM" + deploy the IAM-aware Lambda handler, in lockstep with (2).
    4. spawn: delete identity-doc parsing / signature.go / cross-account default-allow.
  3. added a commit that references this issue on Jun 25, 2026
  4. scttfrdmn commented on Jun 25, 2026

    @scttfrdmn
    ContributorAuthor

    Step 2 (client SigV4 signing) merged — #242

    pkg/dns/client.go now SigV4-signs the DNS Function URL POST with the instance role's ambient credentials (service lambda, the Function URL region), gated behind SPORE_DNS_SIGV4 (off by default). A signed request against the current AuthType: NONE URL is accepted unchanged, so this is non-breaking and can roll out to instances ahead of the flip. Ships in the next spawn release.

    Cutover status

    • 0. infra (spore-host): codify dns-updater in tofu (import existing fn → no endpoint change)
    • 1. infra: cross-account lambda:InvokeFunctionUrl grant to spored roles (additive)
    • 2. spawn (client): SigV4-sign the request — feat: opt-in SigV4 signing for DNS registration (#173 client half) #242 (merged, dormant behind SPORE_DNS_SIGV4)
    • 3. infra: flip Function URL AuthType: AWS_IAM + deploy IAM-aware handler — in lockstep with turning SPORE_DNS_SIGV4 on (the bootstrap should set it once the flip lands)
    • 4. spawn: delete identity-doc parsing / signature.go / embedded certs / cross-account default-allow in lambda/dns-updater/main.go

    Steps 0/1/3 are prod deploys in the infra account and the destructive AuthType flip — those are operator-driven, not auto-shippable from this repo. The vulnerability stays open until step 3 lands; prioritize the infra grant + cutover. Step 4 then removes the dead legacy code.

  5. scttfrdmn commented on Jun 25, 2026

    @scttfrdmn
    ContributorAuthor

    Cutover redesigned + code/IaC landed; only the gated prod flip remains

    After review, dropped the account-enumeration approach for the cross-account grant — it doesn't scale (spawn launches in unbounded accounts with dynamically-named spored roles, and the Lambda resource policy has a ~20KB ceiling). New model needs zero allow-list upkeep:

    • Resource policy Principal: "*" under AuthType: AWS_IAM = "any SigV4 signer", not anonymous.
    • spored role self-grants lambda:InvokeFunctionUrl (per-account, no infra enrollment).
    • Lambda namespaces on the verified account — a caller can only write records under base36(its-verified-accountID).<domain>. Cross-account spoofing closed cryptographically; no per-region certs ([audit] Dup: formatDuration and formatDurationForTTL are byte-identical — collapse to one #294 closed for good).

    Status

    The vulnerability stays open until 3b. 3b is the only destructive, prod-breaking step and is deliberately operator-gated: it must wait for a signing fleet (enabler shipped in a release + instances cycled), and the handler-deploy + AuthType-flip must happen together.

  6. scttfrdmn commented on Jun 25, 2026

    @scttfrdmn
    ContributorAuthor

    Safe prep done — release shipped + dual-path handler deployed; only the flip remains

    Step 3a (release): spawn v0.67.0 released — ships the enabler (SPORE_DNS_SIGV4=1 in spored's systemd unit), the spored self-grant (lambda:InvokeFunctionUrl), and the IAM-aware handler. spored binaries for 0.67.0 are live in S3 (verified, fresh upload), so any instance launched from v0.67.0+ now signs its DNS requests. Old instances age out under their TTLs.

    Step 3b-code (handler deploy): the dual-path handler is deployed to the live spawn-dns-updater (update-function-code, code-only — same role/env/URL, AuthType still NONE). Verified live:

    • new code SHA active, LastUpdateStatus: Successful
    • an unsigned/empty-identity call now returns the handler's own deny-by-default ("missing identity document/signature (and no AWS_IAM authorizer present)"), proving the dual-path logic is live; a real legacy request still takes the legacy path and succeeds → non-breaking.
    • rollback artifact of the prior code saved.

    Did NOT run the full scripts/deploy-custom-dns.sh — it would create a stray API Gateway + a duplicate IAM role (SpawnDNSLambdaRole ≠ the live tofu-managed SpawnDNSLambdaExecutionRole) and also has a build bug (go build main.go misses signature.go → undefined: verifyInstanceIdentitySignature). Used a surgical update-function-code instead.

    Remaining

    • Flip (enable_iam_invoke=true + authorization_type=AWS_IAM, tofu apply) — gated until a signing fleet has cycled in (v0.67.0+ instances) and old non-signing instances have aged out. Then verify a signed call registers + an unsigned call 403s at the auth layer.
    • Step 4 — delete signature.go / identity-doc parsing / certs / cross-account default-allow.

    Note: the deploy-custom-dns.sh go build main.go bug should be fixed to go build . (separate small PR).

  7. added a commit that references this issue on Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions