Skip to content

DNS updater: authorize callers, not just authenticate them, and validate ip_address #835

Closed

Description

@scttfrdmn

Security issue. Detail is in private advisory GHSA-7pm4-cqjg-vh2q; this issue tracks
the remediation only. Found while verifying #820, which it makes considerably worse.

spawn-dns-updater's Function URL is AuthType: AWS_IAM, and the handler correctly
namespaces the canonical record under the SigV4-verified caller. But the resource policy
is the statement AWS auto-generates and was never narrowed — Principal: "*" with only a
lambda:FunctionUrlAuthType condition — so any principal in any AWS account may
invoke it. SigV4 says who the caller is; nothing says they are a customer.

  • Narrow the resource policy to the accounts entitled to register DNS (explicit
    Principal list, or StringEquals on aws:PrincipalAccount). Note the natural
    registry — the spore-portal-accounts table — currently holds 0 items, so a
    lookup-based check has nothing to read and the allowlist has to come from somewhere
    else first. That is the decision this issue needs.
  • Validate ip_address as an IP literal. Today it is checked only for
    non-emptiness, so the handler relies on Route53 rejecting a malformed A value.
  • Re-verify after the change with a signed request from a non-entitled account,
    expecting 403 at the URL rather than inside the handler.

Why it matters beyond tidiness: record_name is caller-chosen and the record lands in the
real spore.host zone, so a stranger can publish a plausible subdomain
(login.<their-base36>.spore.host) pointing anywhere — a phishing primitive hosted and
paid for by spore.host. And it means #820's attacker set is not "another tenant" but
"anyone with a free AWS account".

The #173 reasoning in the handler is all about authentication — "unspoofable, and
independent of anything in the request body" — which is true and was the point. The
authorization half was never written, and the AWS-generated policy reads like a
deliberate grant.

Live state for reference: the zone serves gatetest.mycelium-development.spore.host and
tstest.mycelium-development.spore.host as CNAMEs to *.5k0zfnmq.spore.host, so the
alias feature has exactly one real tenant today.

Not attempted: a cross-account invoke against production. The policy is read directly off
the live function and its meaning is documented AWS behaviour.

Activity

  1. scttfrdmn commented on Oct 12, 2026

    @scttfrdmn
    ContributorAuthor

    PR #858 does the code half. Three things found while doing it that change this issue's premises — recording them here because two of them would have caused an outage if followed as written.

    1. The registry decision. This issue says spore-portal-accounts holds 0 items, "so a lookup-based check has nothing to read and the allowlist has to come from somewhere else first. That is the decision this issue needs." The answer is spawn-user-accounts, which holds 3 items carrying aws_account_id. It is keyed on user_id with GSIs on cli_iam_arn and email — none of which the updater knows, since it knows an account ID — so the lookup is a Scan projecting the single attribute, cached per container.

    2. Shipping it enforcing would have been an outage. The zone serves four live A records under c0zxr0ao.spore.host:

    keel-skx.c0zxr0ao.spore.host.      A  3.234.242.1
    keel-zen4.c0zxr0ao.spore.host.     A  3.235.101.250
    keel-zen5.c0zxr0ao.spore.host.     A  54.235.238.196
    loop-l12-esc.c0zxr0ao.spore.host.  A  52.203.65.248
    

    c0zxr0ao decodes to an account that is not in spawn-user-accounts. So enforcement is behind DNS_AUTHZ_MODE, defaulting to audit — the same dry-run-then-enforce staging the TTL reaper shipped with. The logs will say who actually calls before anything is refused.

    This issue's live-state note is also now stale in a useful way: it says the alias feature "has exactly one real tenant today" based on mycelium-development. There are two base36 subdomains in the zone, and the second is this one.

    3. account_base36 in the table is not trustworthy. The cli row for 435415984226 stores c8s8u, which decodes to 20565246 — not an account ID at all. Any ownership question must derive base36 from the verified account ID via encodeAccountID, never read it from the registry. That affects #820's alias-ownership path too, which already does the right thing.

    Checkbox status

    • Validate ip_address as an IP literal — shipped with Resolve the DNS alias owner server-side instead of from the request body #820 / PR Resolve the DNS alias owner server-side #836. Parsed with net.ParseIP and required to be v4, since the record written is an A record.
    • Narrow the resource policy — not done, and not something a deploy can do. Commands, snapshot and rollback are in docs/dns-updater-authorization.md. It needs one decision from you: whether to list the account owning those four records. Listing it reduces its access (it can invoke the function today, as can anyone) and grants spore.host nothing in that account, so it is not a cross-account trust and not subject to the project's account constraint — but that reasoning is worth checking rather than taking on faith.
    • Re-verify with a signed request from a non-entitled account, expecting 403 at the URL — after the above.

    Keeping this open; #858 says Refs, not Closes.

    Related: #859 — the deployed function is from 2026-06-25 and does not contain #820's fix, verified against the deployed bytes. So the alias-hijack advisory is still live in production regardless of this one.

  2. scttfrdmn commented on Oct 12, 2026

    @scttfrdmn
    ContributorAuthor

    Done and verified live. All three boxes closed.

    • Narrow the resource policy. Principal: "*" is gone. Replaced with three per-account statements, each retaining lambda:FunctionUrlAuthType: AWS_IAM:

      Sid Principal
      FunctionURLAllow966362334030 arn:aws:iam::966362334030:root (Mycelium Infrastructure)
      FunctionURLAllow435415984226 arn:aws:iam::435415984226:root (Mycelium Development)
      FunctionURLAllow942542972736 arn:aws:iam::942542972736:root (observed registrant)

      Added all three before removing the wildcard, so there was no window in which registration was refused.

    • Validate ip_address. Shipped with Resolve the DNS alias owner server-side instead of from the request body #820/Resolve the DNS alias owner server-side #836 and now actually deployed — must be an IPv4 literal confirmed present in the running binary.

    • Re-verify with a signed request from a non-entitled account, expecting 403 at the URL. Not simulated — tested live with SigV4-signed requests:

      966362334030   HTTP 400  {"error":"Unknown domain: probe.invalid"}
      435415984226   HTTP 400  {"error":"Unknown domain: probe.invalid"}
      752123829273   HTTP 403  {"Message":"Forbidden. For troubleshooting Function URL authorization issues, ..."}
      

      The probe deliberately sends an unknown domain, because the handler resolves the domain after the authorizer check — so a 400 proves the invoke was permitted and the caller authorized, while writing nothing to Route53 (zone confirmed unchanged at 17 records). The 403 is AWS's own Function-URL authorization message, not the handler's, which is how we know the refusal happened at the edge before the Lambda ran.

    How the allowlist was derived

    This issue said the decision it needed was where the allowlist comes from, since spore-portal-accounts is empty. Three sources, and one of my own earlier claims was wrong:

    1. spawn-user-accounts — 435415984226, 966362334030.
    2. The organization. Per the project's cross-account rule I ran the org check first: 966362334030 is a member of o-v33p2ygcff (master 752123829273), which holds eight accounts. Exactly two are spore.host — Mycelium Infrastructure and Mycelium Development. The other six are unrelated projects (Canopy, SnoozeBot, Starburst, Strata, cargoship, and the org master). That closes the "is there an account I don't know about" gap that made narrowing risky.
    3. Observed traffic — 942542972736 registered four records earlier today.

    Correction to my earlier comment on this issue: I described the zone as showing four live records under c0zxr0ao and treated the zone as a historical registrant record. It is not. Those records are now gone — the zone holds 17 records, untruncated — because spored deregisters on teardown, by design. The zone only ever shows currently running spores, so it cannot be used to enumerate who has registered historically. CloudTrail does not help either: Lambda InvokeFunctionUrl is a data event and is not being logged, so lookup-events has only AssumeRole.

    On including 942542972736

    Stated explicitly rather than left implicit, because that account is subject to a project constraint. This grant is inbound only: it permits principals in 942542972736 to invoke a spore.host Lambda. It creates no role, no trust policy and nothing assumable inside that account, and gives spore.host no access to it — the opposite direction from the constraint. It is also not a new grant: that account could already invoke this function under Principal: "*", so listing it preserves its existing access while removing the world's.

    Its statement is structurally identical to the two that were verified live. I deliberately did not probe with that account's credentials — the mechanism is already proven twice, so exercising them adds nothing worth the contact.

    DNS_AUTHZ_MODE stays in audit — deliberately

    DNS_ALLOWED_ACCOUNTS is set to the same three accounts, so flipping to enforce is safe whenever wanted. I am leaving it in audit because the edge now does the enforcing, and enforce would put a fail-closed DynamoDB Scan in the DNS-registration path: if the table or its grant breaks, registration breaks for everyone. The defence-in-depth gain is small now that the policy is narrowed; the new failure mode is not.

    The registry read is confirmed working regardless — this audit line from the live log is only producible if allowedAccounts() returned a non-error, non-empty set, i.e. the Scan succeeded under the new SpawnDNSAccountRegistryRead grant with its explicit Select:

    DNS caller WOULD BE REFUSED (DNS_AUTHZ_MODE is not "enforce", allowing):
      account 752123829273 is not registered in spawn-user-accounts and is not in DNS_ALLOWED_ACCOUNTS
    

    Rollback, if ever needed: aws lambda add-permission --function-name spawn-dns-updater --statement-id FunctionURLAllowIAMAccess --action lambda:InvokeFunctionUrl --principal '*' --function-url-auth-type AWS_IAM --region us-east-1.

    Closing. Advisory GHSA-7pm4-cqjg-vh2q can be published, with patched_versions set per #828 at the next release.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions