Skip to content

spawn launch --dns posts to a nonexistent endpoint with the auth scheme #173 removed #872

Closed

Description

@scttfrdmn

Found while fixing #870. Separate defect, in live CLI code rather than a script.

Three things wrong at once

spawn launch --dns <name> calls registerDNS (cmd/launch_posthook.go), reached from cmd/launch_single.go:1011 whenever --dns is set and SSH is reachable. It:

1. Posts to an endpoint that does not exist. The endpoint comes from DNSConfig.APIEndpoint, whose compiled-in default is:

// pkg/config/config.go:17
defaultAPIEndpoint = "https://f4gm19tl70.execute-api.us-east-1.amazonaws.com/prod/update-dns"
$ aws apigateway get-rest-api --rest-api-id f4gm19tl70 --region us-east-1
An error occurred (NotFoundException): Invalid API identifier specified 966362334030:f4gm19tl70

There are zero REST APIs in the infra account. Precedence is flag → config file → SSM → default, and neither /spawn/dns/domain nor /spawn/dns/api_endpoint is set in SSM, so the default is what gets used.

2. Sends the authentication scheme #173 removed. The request body carries instance_identity_document and instance_identity_signature — the PKCS#7 identity-document fields. lambda/dns-updater/main.go records them as gone: "instance_identity_document / _signature were removed — the caller is now authenticated by SigV4 … Older clients may still send those keys; unknown JSON fields are ignored."

3. Posts unsigned. It shells into the instance over SSH and runs a bare curl -X POST. The Function URL is AuthType: AWS_IAM, so even with the endpoint corrected this returns 403. The code's own comment anticipates it — "e.g. 403 from the IAM-auth'd updater when this account isn't authorized" — which reads as an account-permissions problem rather than the client never signing at all.

The error message blames the user's account

preflightDNSEndpoint short-circuits on NXDOMAIN, so the user sees:

⚠️  DNS registration failed (non-fatal — use the public IP or `spawn connect <name>`):
   DNS API endpoint hostname "f4gm19tl70.execute-api.us-east-1.amazonaws.com" does not
   resolve (...) — this is expected in accounts not wired for spore.host DNS

That attribution is wrong. The hostname does not resolve because spawn's own default points at a deleted API Gateway, so this fails identically in the spore.host accounts that are wired for DNS. A graceful non-fatal message that misattributes the cause is worse than a crash here: it tells the user to stop looking.

Why DNS still appears to work

Two registration paths exist and only one was migrated by #173:

path transport auth status
spored, in-instance Function URL …lambda-url.us-east-1.on.aws SigV4, SPORE_DNS_SIGV4=1 works — this is what produced the 5k0zfnmq and c0zxr0ao records
CLI --dns, over SSH hardcoded API Gateway unsigned + PKCS#7 body broken on all three counts

So the feature looks healthy because spored does the real work.

Decide, then fix

This is finish-or-withdraw again, and I have not guessed at it:

  • Withdraw: delete registerDNS, the --dns-api-endpoint flag, DNSConfig.APIEndpoint and the SSM api_endpoint lookup, and let spored be the only registrar. spawn dns register (which the skip-path message already recommends) would need checking for the same defect.
  • Finish: sign the request. That means doing SigV4 from the CLI against the Function URL rather than curl inside the instance — which also removes the SSH dependency and the retry loop, and would make --dns work on keyless SSM-only instances (related to spawn plugin install requires SSH, so it cannot work on a keyless SSM-only instance #855).

Either way, pkg/config.defaultAPIEndpoint must stop naming a deleted resource, and preflightDNSEndpoint's message must stop attributing a spawn-side default to the user's account.

Not attempted: I did not change the default to the Function URL. That would convert an honest NXDOMAIN into a 403 — still broken, but harder to diagnose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions