Repository navigation
dns-updater: read the account registry with one keyed GetItem (#1611) - #1632
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
hardening/1611-dns-registry-getitem
branch
from
November 14, 2026 20:17
089b605 to
85a9077
Compare
The updater scanned spawn-user-accounts, which is keyed on user_id and cannot be read by account, and the Scan grant was never on the live role, so every registration fell back to DNS_ALLOWED_ACCOUNTS and a newly onboarded account was refused under enforce. It now GetItems the verified account ID in spore-portal-accounts (keyed on accountId; dashboard-api's entitlement source), projecting accountId and status, refusing offboarded rows, caching per account and never caching a failure. scripts/deploy-custom-dns.sh grants exactly that GetItem (attribute- scoped, Null-guarded) plus kms:Decrypt on the table key via DynamoDB, under the same policy name, replacing the Scan. registry_grant_test.go holds the request and the grant together.
scttfrdmn
marked this pull request as ready for review
November 14, 2026 22:16
scttfrdmn
force-pushed
the
hardening/1611-dns-registry-getitem
branch
from
November 14, 2026 22:16
85a9077 to
9a5d305
Compare
Merged
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.
Fixes #1611
What changes
The registry lookup is now a keyed
GetItem, on a table that can be keyed by account. The updater used toScanspawn-user-accounts, which is keyed onuser_id(GSIs oncli_iam_arnandemail), so it cannot be read by account ID. TheScangrant was never on the live role, so every registration since v0.164.0 logged the registry unreadable and fell back toDNS_ALLOWED_ACCOUNTS.The updater now makes one
GetItemby the SigV4-verified account ID onspore-portal-accounts. That table is keyed onaccountId, and dashboard-api already reads it for entitlement (#1605). The read projectsaccountIdandstatus. Anoffboardedrow, or no row, refuses. Answers are cached per account (5 min if entitled, 1 min if refused), failures are not cached, andDNS_ALLOWED_ACCOUNTSis checked first with no DynamoDB call.DNS_ACCOUNTS_TABLEnow defaults tospore-portal-accounts.Why not stay on
spawn-user-accounts: a keyed read there needs a new GSI, which is a live table change. dashboard-api also writes that table on a caller's first request, and before #1605 it did so for any caller, so it is a weaker entitlement source. This changes nothing for the accounts that register today, because live behaviour is alreadyDNS_ALLOWED_ACCOUNTSonly.Where the role policy lives:
scripts/deploy-custom-dns.sh, as inline policies onSpawnDNSLambdaExecutionRole:SpawnDNSAccountRegistryRead(same name, soput-role-policyreplaces the old Scan grant):dynamodb:GetItemontable/spore-portal-accounts,ForAllValues:StringEquals dynamodb:Attributes [accountId, status], plusNull dynamodb:Attributes false. TheNullis needed because ForAllValues passes a no-projection GetItem, which would read the whole row with its onboarding role and ExternalId.dynamodb:Selectis a Query/Scan key only.SpawnDNSAccountRegistryKMS:kms:Decrypton the table's CMK (read fromdescribe-table), withkms:ViaService=dynamodb.us-east-1.amazonaws.comandkms:EncryptionContext:aws:dynamodb:tableName=spore-portal-accounts. This mirrors dashboard-api's grant.Tests
registry_grant_test.go(the test the issue asks for): it parses the script'sSpawnDNSAccountRegistryReadheredoc and requires exactly one statement allowing exactlydynamodb:GetItemon the registry. The granted attribute set must equal the attributesregistryGetItemInputprojects, theNullguard must be present, and the key must be exactlyaccountId.authorize_test.gocovers: no row, an offboarded row, an error, a failure not cached but a success cached, and an allow-listed account making no registry call.dynamodb:GetItemgranted).make checkis clean apart from the known space-in-path failures. Semgrep and shellcheck are clean.Deploy steps (966362334030, us-east-1)
aws iam get-role-policy --role-name SpawnDNSLambdaExecutionRole --policy-name SpawnDNSAccountRegistryRead(expect NoSuchEntity, per the production error) andaws lambda get-function-configuration --function-name spawn-dns-updater --query Environment.Variables(keys only).scripts/deploy-custom-dns.sh --hosted-zone-id Z0341053304H0DQXF6U4X --domain spore.host --region us-east-1, which also redeploys the code and merges env, orput-role-policythe two heredocs by hand.DNS_ACCOUNTS_TABLE: if the live function sets it tospawn-user-accounts, unset it or set it tospore-portal-accounts. KeepDNS_ALLOWED_ACCOUNTSas is (thec0zxr0aoaccount must stay listed).spawn-dns-updater(the script above, or the release's code-only deploy).Simulate (
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::966362334030:role/SpawnDNSLambdaExecutionRole)dynamodb:GetItemontable/spore-portal-accounts,dynamodb:Attributes=accountId,statusdynamodb:Attributes=accountId,status,onboardRoleArndynamodb:Attributescontextdynamodb:Scanontable/spore-portal-accountsdynamodb:Scanontable/spawn-user-accountskms:Decrypton the registry key,kms:ViaService=dynamodb.us-east-1.amazonaws.com, tableName contextspore-portal-accountskms:Decrypton the key, nokms:ViaServiceBoth policies contain no
${aws:...}variables in Resource, and every condition key belongs to its action's service. Still do one realput-role-policy(step 2) before relying on it.Live checks after deploy
DNS_ALLOWED_ACCOUNTS. It should succeed, and the log should have noregistry unreadableorcould not read accountline.warning: account registry unreadablelines stop (count only).spore-portal-accounts.