Repository navigation
fix(dns): refuse on unreadable /spawn/dns/*; grant invoke on the resolved updater (#1121, #1158) - #1218
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ke on the resolved updater An SSM read of the account's DNS setting that fails for any reason but ParameterNotFound now refuses the launch (and spawn dns register/delete), naming the parameter and ssm:GetParameter, instead of silently falling back to spore.host's updater (#1121). The instance role's lambda:InvokeFunctionUrl grant was pinned to spore.host's function. A custom endpoint now needs its function ARN (--dns-function-arn / SPAWN_DNS_FUNCTION_ARN / dns.function_arn / SSM /spawn/dns/function_arn), and the launch grants it in a separate per-function inline policy, so grants on shared roles accumulate rather than replace each other (#1158). Fixes #1121 Fixes #1158
scttfrdmn
force-pushed
the
fix/1121-1158-dns-correctness
branch
from
October 20, 2026 08:07
ef67a60 to
a96a9c6
Compare
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.
Two DNS correctness fixes for custom DNS deployments (#891).
#1121: an unreadable
/spawn/dns/*setting now refuses the launch.config.ResolveDNSTargettreated every SSM error as "not set", so a launcher withoutssm:GetParameter, in an account that publishes a custom deployment, was silently registered under spore.host's updater. Now onlyParameterNotFound(matched by type,errors.As(*ssmtypes.ParameterNotFound)) means "not set". Any other error returns a*config.DNSSettingUnreadableError. That error names the parameter andssm:GetParameter, and lists the flag, env and config key that skip the lookup. It refusesspawn launch, and alsospawn dns registerandspawn dns delete, where the message names--domain/--endpoint. This follows the owner's decision on the issue.Behaviour change: an account whose launchers lack
ssm:GetParameteron/spawn/dns/*will now have every DNS-registering launch refused, even if it publishes nothing. Before, they defaulted silently. IAM checks permission before existence, so AccessDenied comes back either way. The escape is to set the value another way (e.g.SPAWN_DNS_DOMAIN=spore.host). This is listed under Changed.#1158: the instance role's invoke grant follows the resolved updater. A Function URL hostname is
<opaque-id>.lambda-url.<region>.on.aws, so it carries neither the function name nor the account, and the ARN can't be derived from it. This adds a function-ARN value, resolved through the same chain as the other two:--dns-function-arn,SPAWN_DNS_FUNCTION_ARN,dns.function_arn, SSM/spawn/dns/function_arn. It's only looked up when an endpoint was found. The value is validated bydns.ValidateFunctionARN: one function, no wildcards and no policy variables (#1069), in the endpoint's own region.sporedSelfManagementStatementsand the staticsporedDCVRolePolicy) now render the grant from one constant,config.DefaultDNSFunctionARN.ensureIAMProfilecalls the newaws.Client.EnsureDNSInvokeGrant, which writes a separate inline policy,spored-dns-invoke-<sha256[:4]>, on the role. It doesn't edit the baseline becausespored-instance-roleandspawn-instance-<hash>are shared and their baselines are rewritten on every launch. A launch-specific Resource there would be overwritten by the next launch through a different updater, cutting off running spores' lease renewals.--instance-profile(a role spawn doesn't manage). There spawn writes nothing and prints a warning.--dry-runshowsDNS grant: …, and-o jsoncarriesdns_function_arn.Deviation from the brief, flagged: "defaulting to spore.host's" applies only to spore.host's endpoint. For a custom endpoint, defaulting to spore.host's ARN is the exact 403 the issue describes, so it's refused instead.
docs/custom-dns.md documents the third column, the SSM read permission and refusal, and the grant mechanism. The Windows flag table also fixes the stale "deprecated" reason on
--dns-domain/--dns-api-endpoint.Gates (each watched failing against a compiling revert)
pkg/config TestResolveDNSTarget_UnreadableSSMIsAnError: AccessDenied, throttling and network errors on each of the three parameters must produce aDNSSettingUnreadableErrornaming the path andssm:GetParameter, with an empty target. Revert|| trueon the ParameterNotFound branch: FAIL.cmd TestLaunchRefusedWhenTheAccountsDNSSettingIsUnreadable: runs through the real SDK against a fake SSM JSON API answeringAccessDeniedException, soresolveLaunchDNSTargetrefuses on what the SDK actually deserialises. The same revert: FAIL.TestLaunchUsesSporeHostWhenTheDNSParametersDoNotExistchecks thatParameterNotFoundgives spore.host's target with no error.cmd TestLaunchGrantsTheInstanceRoleInvokeOnTheResolvedUpdater: runsensureIAMProfileagainst a recording IAM on both role paths (shared spored role = static DCV policy;--iam-policyrole = dynamic baseline), with the default and a custom function. Everylambda:InvokeFunctionUrlgrant is discovered from the stored documents and must be exactlyDefaultDNSFunctionARN, except the per-function policy, which must be exactly the custom ARN and must exist. Reverts: no grant call: FAIL. A wildcard-account Resource in the DCV template: FAIL.arn:aws:lambda:*:*:function:*in the dynamic baseline: FAIL.cmd TestLaunchResolvesTheCustomUpdatersFunction: a custom endpoint without an ARN is refused, naming the flag and the SSM path, and an ARN in the wrong region is refused. Revert (accept without ARN): FAIL.pkg/aws TestEnsureDNSInvokeGrantIsWrittenBesideTheBaseline(Substrate PutRolePolicy round-trip) andpkg/dns TestValidateFunctionARN.Checks
make checkpasses every step exceptcheck-build-tags, which fails identically on unmodified origin/main on this machine (/private/tmppath coverage).make check-docsandsemgrep scan --config=auto --error .are clean.make api-snapshotwas regenerated:ResolveDNSTarget's signature change is noted in the CHANGELOG.Not verified
Nothing was run on AWS. A real PutRolePolicy for the new
spored-dns-invoke-*document was not done; it has no policy variables or placeholders, and Substrate accepts it. A cross-account Function URL call with both halves granted is also unproven live.Fixes #1121
Fixes #1158