Repository navigation
Authorize DNS-updater callers against the account registry (#835) - #858
Merged
Merged
Conversation
The Function URL is AuthType: AWS_IAM and the record is namespaced under the SigV4-verified caller, so a caller cannot write outside its own subdomain. The authorization half was never written: the resource policy is the statement AWS auto-generates, Principal: "*", so any principal in any AWS account reached the handler with a verified identity. The verified account is now checked against spawn-user-accounts plus an explicit DNS_ALLOWED_ACCOUNTS list, failing closed on a lookup error and on a lookup that returns nothing at all. Enforcement is behind DNS_AUTHZ_MODE=enforce and defaults to audit, because the zone serves four live A records under a subdomain belonging to an account that is not in the registry. The ship-it-enforcing version would have been an outage. Also fixes the deploy script, which was unsafe to run and is why this function had not been deployed since 2026-06-25: it granted IAM to a role that does not exist, its update path replaced the whole environment (deleting DOMAIN_ZONES), and it ignored --region. Refs #835
This was referenced Oct 12, 2026
Closed
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3 tasks
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.
Advisory GHSA-7pm4-cqjg-vh2q.
Refs #835deliberately — this does not close it; see What this does not do below.The defect
The Function URL is
AuthType: AWS_IAMand the canonical record is namespaced under the SigV4-verified caller account, so a caller cannot write outside its ownbase36subdomain. That half was right (#173).The other half was never written. The function's resource policy is the statement AWS auto-generates for a Function URL —
Principal: "*", gated only onlambda:FunctionUrlAuthType— so any principal in any AWS account reached the handler with a verified identity. Read off the live function:{"Sid":"FunctionURLAllowIAMAccess","Effect":"Allow","Principal":"*", "Action":"lambda:InvokeFunctionUrl", "Condition":{"StringEquals":{"lambda:FunctionUrlAuthType":"AWS_IAM"}}}record_nameis caller-chosen and the record lands in the realspore.hostzone, so a stranger with a free AWS account could publishlogin.<their-base36>.spore.hostpointing anywhere.Which registry — and the hazard the issue didn't know about
#835 proposed
spore-portal-accounts. It holds 0 items, so a lookup against it authorizes nobody.spawn-user-accountsis the populated one (3 items carryingaws_account_id).But the zone serves four live A records under
c0zxr0ao.spore.host—keel-skx,keel-zen4,keel-zen5,loop-l12-esc— andc0zxr0aodecodes to an account that is not in that table. The obvious implementation of this issue, shipped enforcing, would have taken four running hosts off the air. HenceDNS_AUTHZ_MODE: this deploys in audit, the logs say who actually calls, and enforcement is a separate deliberate flip — the staging the TTL reaper shipped with.Also found: the table's
account_base36is not reliably the encoding of itsaws_account_id(theclirow for 435415984226 storesc8s8u, which decodes to 20565246). So ownership questions must derive base36 from the verified account ID, never read it from the registry. Noted in the doc for the next consumer.The grant
One inline policy,
SpawnDNSAccountRegistryRead, scoped to one table, one attribute, anddynamodb:Select = SPECIFIC_ATTRIBUTES. The third is load-bearing:ForAllValues:StringEqualsis satisfied by an empty set, so aScannaming no attributes passes thedynamodb:Attributescondition and reads every field of every item. Same family asForAllValues:StringNotEqualsonaws:TagKeysbeing defeated by one innocuous tag.It follows that the handler sets
Selectexplicitly rather than letting DynamoDB infer it — a condition key the request doesn't carry evaluates as absent, so inferring it would leave the grant denying its own only caller, in production and nowhere else.iam simulate-custom-policy, eight ways:Scan,Select=SPECIFIC_ATTRIBUTES,Attributes=[aws_account_id]allowedScanalso projectingemailimplicitDenyScanwithSelect=ALL_ATTRIBUTESimplicitDenyScanwith no condition context at allimplicitDenyScanof a different tableimplicitDenyGetItem/PutItem/DeleteTableimplicitDeny(The first run of that simulation errored on
--policy-input-listwanting JSON strings. Worth noting because had it silently returnedimplicitDenyfor everything, it would have looked like a flawless deny-all.)The deploy script was unsafe to run
Which is why
spawn-dns-updaterwas last deployed 2026-06-25. Three defects, each reporting success:SpawnDNSLambdaRole, which does not exist in the infra account. The function runs underSpawnDNSLambdaExecutionRole. Every permission the script granted went to a role nothing used — so a grant added here for this feature would simply not have taken effect.--environment Variables={HOSTED_ZONE_ID=…,DOMAIN=…}.--environmentreplaces the whole map, so running it would have deletedDOMAIN_ZONES(the only variable the live function has) and writtenDOMAIN, which the handler never reads. It would also have clearedDNS_AUTHZ_MODE— turning this fix off as a side effect of shipping unrelated code.--region, printed it, then ignored it: most of itsawscalls carried no--region.Plus
--runtimeon the update path, not only on create (#716).Gates
Ten, each watched failing against a revert that compiles:
DNS_AUTHZ_MODEdefaulting to enforce; a failed lookup cached; the not-in-set check disabled; a malformed allowlist entry dropped unreported (two ways); a literal--environmenton an update; thedynamodb:Selectpin removed.Two of my own gates had to be rewritten after they ran, both rule 6:
TestStaticAllowlistEntitlesAndIsValidatedpassed a revert that deleted the validation entirely. A malformed entry can never authorize anything — caller accounts are validated as 12 digits before the set is consulted — so the set contents were a correlate. The real mechanism is that the operator is told their typo was ignored, otherwise a mistyped account ID silently fails to entitle and the request it breaks is denied minutes later pointing nowhere near the typo.extraAllowedAccountsnow returns its rejects and that is what's asserted.TestDeployScriptsDoNotWipeTheEnvironment(already in the tree) matched only the literalVariables={}— the empty map, the memorable half of the bug it was written for.deploy-custom-dns.sh's non-empty literal sailed through and is equally destructive. Generalized to any literal map on an update path, which found the same latent bug in two more scripts:deploy-scheduler-handler.shand the websocket processor'sdeploy.sh. Both verified against their live functions as displacing nothing today, and both now carry an adjacentenv-replace-ok:marker stating the decision, in the style of the existingswallow-ok:. The generalized gate also could not see its own marker at first: the sharedread()helper strips comments on purpose (rule 3), so this one gate reads the raw file.What this does not do
Deploying this does not close the hole. Two live AWS steps remain, written up with snapshot/rollback in
docs/dns-updater-authorization.md:DNS_AUTHZ_MODE=enforceonce the audit logs confirm who calls.Separately: #820's fix is merged but not deployed. The deployed binary contains
aliasDNSNamebut notaliasSubdomainOwneror_spore-owner, so GHSA-q9qq-223w-mqx6's alias-hijack is still live. Filed separately.🤖 Generated with Claude Code