Skip to content

fix(dns): refuse on unreadable /spawn/dns/*; grant invoke on the resolved updater (#1121, #1158) - #1218

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1121-1158-dns-correctness
Oct 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1121-1158-dns-correctness

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Two DNS correctness fixes for custom DNS deployments (#891).

#1121: an unreadable /spawn/dns/* setting now refuses the launch. config.ResolveDNSTarget treated every SSM error as "not set", so a launcher without ssm:GetParameter, in an account that publishes a custom deployment, was silently registered under spore.host's updater. Now only ParameterNotFound (matched by type, errors.As(*ssmtypes.ParameterNotFound)) means "not set". Any other error returns a *config.DNSSettingUnreadableError. That error names the parameter and ssm:GetParameter, and lists the flag, env and config key that skip the lookup. It refuses spawn launch, and also spawn dns register and spawn 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:GetParameter on /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 by dns.ValidateFunctionARN: one function, no wildcards and no policy variables (#1069), in the endpoint's own region.

  • Default endpoint: unchanged. Both spored policies (the dynamic sporedSelfManagementStatements and the static sporedDCVRolePolicy) now render the grant from one constant, config.DefaultDNSFunctionARN.
  • Custom endpoint: ensureIAMProfile calls the new aws.Client.EnsureDNSInvokeGrant, which writes a separate inline policy, spored-dns-invoke-<sha256[:4]>, on the role. It doesn't edit the baseline because spored-instance-role and spawn-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.
  • A custom endpoint with no function ARN is refused before anything is launched, rather than launched into a guaranteed 403. The exception is --instance-profile (a role spawn doesn't manage). There spawn writes nothing and prints a warning.
  • --dry-run shows DNS grant: …, and -o json carries dns_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 a DNSSettingUnreadableError naming the path and ssm:GetParameter, with an empty target. Revert || true on the ParameterNotFound branch: FAIL.
  • cmd TestLaunchRefusedWhenTheAccountsDNSSettingIsUnreadable: runs through the real SDK against a fake SSM JSON API answering AccessDeniedException, so resolveLaunchDNSTarget refuses on what the SDK actually deserialises. The same revert: FAIL. TestLaunchUsesSporeHostWhenTheDNSParametersDoNotExist checks that ParameterNotFound gives spore.host's target with no error.
  • cmd TestLaunchGrantsTheInstanceRoleInvokeOnTheResolvedUpdater: runs ensureIAMProfile against a recording IAM on both role paths (shared spored role = static DCV policy; --iam-policy role = dynamic baseline), with the default and a custom function. Every lambda:InvokeFunctionUrl grant is discovered from the stored documents and must be exactly DefaultDNSFunctionARN, 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) and pkg/dns TestValidateFunctionARN.

Checks

make check passes every step except check-build-tags, which fails identically on unmodified origin/main on this machine (/private/tmp path coverage). make check-docs and semgrep scan --config=auto --error . are clean. make api-snapshot was 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

@scttfrdmn scttfrdmn added this to the v0.137.0 milestone Oct 20, 2026
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

…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
scttfrdmn force-pushed the fix/1121-1158-dns-correctness branch from ef67a60 to a96a9c6 Compare October 20, 2026 08:07
@scttfrdmn
scttfrdmn merged commit a478195 into main Oct 20, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1121-1158-dns-correctness branch October 20, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant