Skip to content

spored DNS registration not reaching the DNS Lambda after AuthType: AWS_IAM cutover #435

Closed

Description

@scttfrdmn

Symptom

Instances launched into the dev account (435415984226) with a running spored (SPORE_DNS_SIGV4=1 in the systemd unit, the default) do not get a resolvable {name}.{base36(account)}.spore.host record, and the DNS Lambda shows zero invocations while they're alive.

Evidence (2026-07-23, us-east-1)

  • Two t4g.nano instances launched, reached running with public IPs, ran their full 5-min TTL, and self-terminated correctly (so spored was alive and healthy — TTL enforcement worked).
  • direct-e2e.5k0zfnmq.spore.host never resolved via public DoH during the instances' lifetime (polled repeatedly).
  • aws lambda get-function-url-config --function-name spawn-dns-updater → AuthType: AWS_IAM (the [HIGH] dns-updater accepts unsigned identity docs + default-allows cross-account → Route53 spoofing #173 cutover has landed on the infra side).
  • aws logs filter-log-events on /aws/lambda/spawn-dns-updater → 0 events in a 30-minute window covering both instances. So the requests are being rejected at the Function URL auth layer before invocation, not failing inside the Lambda.
  • The instance role (spored-instance-role) DOES grant lambda:InvokeFunctionUrl on arn:aws:lambda:*:966362334030:function:spawn-dns-updater (verified), so the IAM grant is present.
  • spored binary in spawn-binaries-us-east-1 (spawn/spored-linux-arm64) LastModified 2026-07-22.

Likely cause

The Function URL is now AWS_IAM, but the SigV4-signed requests from spored are being rejected (403 → no invocation logged). Candidate reasons:

  • the installed spored build predates / doesn't actually emit the SigV4 signature (the [HIGH] dns-updater accepts unsigned identity docs + default-allows cross-account → Route53 spoofing #173 rollout comment in pkg/launcher/bootstrap.go anticipates old non-signing instances aging out — but a freshly-installed binary should sign);
  • a mismatch in the signed request (host/payload-hash/session-token header) so the signature is rejected;
  • the instance role's lambda:InvokeFunctionUrl grant not actually being honored for the FunctionUrlAuthType.

Impact

The self-termination guarantee is unaffected (proven — both self-terminated). But DNS registration is silently broken post-cutover: no error surfaces to the user; the name just never appears. Worth confirming the current spored build signs correctly against the AWS_IAM Function URL and adding a visible spored-side log line on registration failure.

Found while building a spawn-ts BYOA demo that resolves the spore.host name to confirm registration end-to-end.

Activity

  1. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Investigation update + partial fix (PR #436)

    Dug into this. Splitting it into visibility (fixed) and root cause (still open).

    Ruled out: it is NOT a missing/incorrect infra-side policy

    Verified read-only against the live function (AWS_PROFILE=spore-host-infra, us-east-1):

    • get-function-url-config → AuthType: AWS_IAM ✅ (cutover landed, as you found)
    • get-policy → statement FunctionURLAllowIAMAccess, Action: lambda:InvokeFunctionUrl, Principal: "*", condition lambda:FunctionUrlAuthType = AWS_IAM

    That resource policy is the standard "any IAM-authorized principal" form, and Principal: * does permit cross-account callers as long as their own IAM allows it — which the dev instance role does (lambda:InvokeFunctionUrl on the dns-updater ARN, confirmed in pkg/aws/iam.go). So my initial hypothesis (missing cross-account resource policy) is wrong — this is not it.

    The client's signing path (pkg/dns/client.go signRequest: SigV4 lambda service, instance-role creds from the ambient chain, hex SHA-256 payload hash; SDK auto-adds X-Amz-Security-Token) also looks correct and already has passing unit tests (TestCallAPI_SignedWhenEnabled). So the 403 is signature/credential-level, not authorization-model-level.

    Remaining root-cause candidates (still open)

    1. Region mismatch in the signature. The signer uses cfg.Region (falling back to us-east-1). If an instance in another region signs for its own region while the Function URL is verified as us-east-1, the SigV4 scope won't match → 403. Worth checking what region the failing dev instances signed for.
    2. Session-token / creds staleness at signing time (IMDS creds not yet populated, or a clock skew).
    3. A signed header the Function URL doesn't expect (host vs. the lambda-url host, or an unsigned header being added after signing by the transport).

    Next concrete step: capture the actual 403 body/headers from a live signed request (the PR below now surfaces it), and/or add temporary debug logging of the signed canonical request on one dev instance.

    What PR #436 fixes now (visibility)

    The bigger immediate problem was that this failure was completely silent:

    • callAPI didn't check the HTTP status — it parsed the 403 body ({"Message":"Forbidden"}) as a normal response → empty DNS API error:. Fixed: surfaces HTTP 403: <body>.
    • spored only logged the warning to its on-instance journal. Fixed: it now records spawn:dns-status / spawn:dns-error tags…
    • …and spawn status now prints a clear warning when registration failed, so the "FQDN never resolves" symptom is diagnosable from the launch account without SSHing in.

    So after #436 merges, re-running your BYOA repro will show the actual 403 body in spawn status / the tags, which should pin down which of the candidates above is the cause. Leaving this issue open for that root-cause work; #436 also folds in the #434 doc fix.

  2. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Root cause narrowed to "signed with empty/anonymous credentials" — with live proof

    Ran a decisive experiment: hit the live prod DNS Function URL with an intentionally-invalid body (can't create a record) both unsigned and SigV4-signed (same signing path as pkg/dns/client.go), from two accounts. A 403 {"Message":"Forbidden"} = rejected at the auth layer (no invocation); any other status = the request reached the Lambda.

    Caller Request Result
    infra 966362334030 (same-account) unsigned 403 {"Message":"Forbidden"}
    infra 966362334030 SigV4-signed (lambda, us-east-1) 400 Missing required field: record_name → reached Lambda ✅
    dev 435415984226 (cross-account) unsigned 403 {"Message":"Forbidden"}
    dev 435415984226 (cross-account) SigV4-signed 400 → reached Lambda ✅

    What this proves

    • The cross-account signed path works end-to-end: a correctly-signed request from the dev account does reach the Lambda through the AWS_IAM Function URL.
    • Every static element is confirmed correct (all read-only):
      • Function URL AuthType: AWS_IAM ✅
      • Lambda resource policy FunctionURLAllowIAMAccess (Principal:*, FunctionUrlAuthType: AWS_IAM) — allows cross-account IAM ✅
      • dev spored-instance-role inline spored-policy grants lambda:InvokeFunctionUrl on arn:aws:lambda:*:966362334030:function:spawn-dns-updater ✅
      • region (us-east-1), SigV4 service (lambda), payload hash — all match ✅
    • The only way to reproduce the reporter's exact symptom (403 {"Message":"Forbidden"} + 0 invocations) with all of the above correct is a request that arrives effectively unsigned — i.e. spored signed with an empty/anonymous credential.

    Why that happens silently

    config.LoadDefaultConfig → credsProvider.Retrieve() can return a blank credential without an error when the instance role isn't reachable via IMDS yet (agent starts, tries DNS registration before IMDS creds are available). SignHTTP with an empty AccessKeyID does not error client-side — it produces a signature with an empty credential scope, which the Function URL rejects as a bare 403. So spored "signs", sends, and gets a silent 403, exactly as observed.

    (Corroborating smell: the DNS client is the only spored AWS caller using bare LoadDefaultConfig(ctx) with no WithRegion — every other call in pkg/agent/agent.go passes WithRegion(identity.Region). Not the cause on its own since signing falls back to us-east-1, but it reflects the DNS-client credential/region setup being the odd one out.)

    Fix in PR #436 (updated)

    Added a fail-closed guard: if signing is enabled but the resolved credential is empty, signRequest returns a clear, actionable error and sends nothing — instead of emitting an unsigned-effectively request that dies as a silent 403. Combined with the visibility fixes (HTTP-status surfacing + spawn:dns-status tag + spawn status warning), a future occurrence will say "credentials empty / instance role not reachable via IMDS" rather than vanishing.

    Still to confirm on a live instance (the last mile)

    This is a strong inference, not yet a live capture. To close definitively, re-run the BYOA repro with PR #436's build and check spawn status / the spawn:dns-error tag:

    • If it shows the new "credentials are empty" error → confirmed; the real fix is to make spored retry DNS registration until IMDS creds resolve (or block registration on a credential-ready check), which I'd do as a follow-up.
    • If it shows a 403 with non-empty creds → the creds resolved but are still rejected, and we look at request-time details (clock skew, a header mutated post-signing). The surfaced body will tell us which.

    Leaving open for that live confirmation + the retry follow-up.

  3. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Live repro (gated t4g.nano, 20m TTL, terminated + leak-checked, ~$0.00) — my empty-creds hypothesis is WRONG

    Launched a real instance to confirm. It reproduced the symptom and then disproved my previous comment's conclusion. Correcting the record.

    Reproduced the exact symptom

    spored status on the live box (spored v0.92.0, SPORE_DNS_SIGV4=1):

    Registering DNS: dns-repro-435 -> 54.224.97.146
    Warning: Failed to register DNS: DNS API error:        ← empty message = the swallowed 403 (#435)
    

    The decisive control — same box, same instance role, same minute

    Signer Result
    spored (Go v4.SignHTTP) DNS API error: (empty) — i.e. 403, rejected
    curl --aws-sigv4 aws:amz:us-east-1:lambda with the instance role's IMDS creds HTTP 400 Missing required field: record_name → reached the Lambda ✅

    IMDS creds were present (AccessKeyId length 20), so credentials are NOT empty. curl signs with the very same instance-role creds and gets through.

    Corrected conclusion

    • ❌ Not empty/anonymous creds (my prior comment) — disproven; curl with those exact creds works.
    • ❌ Not the resource policy, cross-account grant, region, or auth model (all previously verified, and curl confirms end-to-end).
    • ✅ The bug is specific to how spored's Go code constructs/signs the request — curl --aws-sigv4 from the same box with the same role succeeds where spored's v4.Signer.SignHTTP path fails.

    Puzzle to resolve: a standalone Go program using the same v4.SignHTTP did reach the Lambda in my earlier off-box probes (from both infra and dev creds). So the delta is something in spored's actual request that my minimal probe didn't replicate — candidates now:

    1. A header added after signing that isn't in the signed set (e.g. transport-added Accept-Encoding, or Content-Length handling), causing a signature mismatch.
    2. Missing x-amz-content-sha256 header — curl --aws-sigv4 sends it; Go's SignHTTP uses the payload hash in the string-to-sign but doesn't add the header to the request. Function URL IAM verification may require it. (Why my minimal probe still passed is unexplained — needs the on-box Go-vs-curl comparison with creds held constant.)
    3. Something environment-specific to the instance-role session token via Go vs curl.

    Status of PR #436

    The visibility fixes stand and are valuable (the empty DNS API error: → now surfaces HTTP 403: {...}; spawn status warning; dns-status tags). The fail-closed-on-empty-creds guard is a reasonable safety net but does NOT fix this — creds aren't empty. Not reverting it (still correct defensively), but it should not be described as the #435 fix.

    Next diagnostic (needs one more gated launch)

    Run my exact standalone Go SignHTTP probe on the instance with the instance role (curl-vs-Go, creds held constant), and/or add temporary spored logging of the signed canonical request + response headers. That will pin candidate 1/2/3. Holding for a go-ahead before spending on another instance.

    (Cost note: repro instance i-0227e06cdbed64ed8 terminated explicitly and independently leak-checked — dev account clean, ~$0.00.)

  4. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    RESOLVED — spored's DNS registration works; the original report was a measurement artifact

    Ran this to ground with gated live instances (all terminated + leak-checked, ~$0.00 total). The released v0.92.0 daemon registers DNS correctly and the name resolves publicly. There is no signing/credential/policy bug.

    The daemon's own log (/var/log/spored.log) on a fresh instance

    spored v0.92.0 starting...
    Running on provider: ec2
    Agent initialized for instance i-03a44f994711b4ea7 ...
    Registering DNS: dns-final-435 -> 54.163.81.188
    ✓ DNS registered: dns-final-435.5k0zfnmq.spore.host -> 54.163.81.188 (change: /change/C06252102BY2PMSVLB86U)
    Monitoring started
    

    And it resolves via public DoH:

    dns-final-435.5k0zfnmq.spore.host  ->  54.163.81.188   (Cloudflare DNS Status 0)
    

    Confirmed twice, on two independent instances.

    Where every earlier "finding" went wrong (measurement artifacts, not bugs)

    1. My SSM spored status returned the empty DNS API error: — because a manual spored status invocation over SSM does not inherit the systemd unit's Environment=SPORE_DNS_SIGV4=1. So it signed nothing and got a legitimate 403. Running the same binary on-box with SPORE_DNS_SIGV4=1 set explicitly → ✓ DNS registered. (I verified both side by side.)
    2. "The daemon logged nothing / never registered" — wrong: spored's runDaemon() calls log.SetOutput(/var/log/spored.log), so its logs go to that file, not the journal. journalctl only ever shows systemd's "Started" line by design. The registration was in /var/log/spored.log the whole time.
    3. My off-box "Go signing fails" vs "curl works" table — both were actually correct-and-working; the only failing cell was the unsigned SSM status run from Feature request: --tag / --tags flag for custom EC2 instance tags #1.

    So what about the ORIGINAL report (0 invocations, name never resolved)?

    That was against the dev account (435415984226) during/around the AuthType: AWS_IAM cutover. Given that the current released daemon works end-to-end in that same account today, the original symptom was almost certainly transient/timing relative to the cutover — e.g. the instances in the report ran while the Function URL flip and the instance-role lambda:InvokeFunctionUrl grant weren't yet both in place, or before the signing spored build was the one installed. It is not reproducible now.

    What actually shipped from this investigation (all still valid)

    PR #436 (merged) hardens the observability that made this so hard to diagnose in the first place — every one of these would have short-circuited the confusion:

    • callAPI now surfaces the real HTTP status/body (no more empty DNS API error:).
    • spored records spawn:dns-status/spawn:dns-error tags; spawn status shows a clear warning on failure.
    • signing fails closed on empty credentials.

    Plus the #434 base36 doc fix.

    Recommendation

    Closing-eligible: not reproducible; released daemon verified working end-to-end incl. public resolution. Leaving the final call to the maintainer, but I'd close as resolved-by-#436 (observability) + not-reproducible (the underlying registration). If anyone hits a fresh occurrence, PR #436's changes mean it will now show the actual error in spawn status / the spawn:dns-error tag rather than vanishing.

    (Cost: 3 gated t4g.nano launches, each explicitly terminated + independently leak-checked; dev account confirmed clean; ~$0.00. No production artifacts or infra modified; diagnostic build was throwaway and read-only.)

  5. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Retested with a fresh instance and got to the real root cause — my original diagnosis (AuthType: AWS_IAM rejecting spored's requests) was wrong. Correcting the record:

    What I actually found

    Launched a fresh t4g.nano (spored 0.92.0, SPORE_DNS_SIGV4=1 set) and inspected it live over SSM:

    • spored is active and running, but its journal shows only the systemd start line — no DNS attempt, no error, and no TTL/tag lines.
    • The DNS Lambda saw zero invocations in the instance's lifetime.
    • The name never resolves.

    The reason isn't auth — it's that spored is correctly skipping registration. Per pkg/agent/agent.go:203:

    if config.DNSName != "" && identity.PublicIP != "" && identity.Provider == "ec2" {

    DNS registration is gated on a non-empty config.DNSName, which is populated from the spawn:dns-name tag (pkg/aws/tags.go:91-92 writes it; pkg/provider/ec2.go:513 reads it). Confirmed my instance's tags: spawn:managed, spawn:ttl, spawn:ttl-deadline, spawn:price-per-hour, spawn:spored-version, … but no spawn:dns-name. So config.DNSName == "" → the whole registration block is skipped. spored is behaving exactly as written.

    So the earlier "0 invocations / AWS_IAM" observation was a red herring

    That was from an instance in a different state; there was never an auth rejection to see, because a signed request was never sent — no DNS name was configured, so spored never called the Lambda.

    Implications

    1. This is launcher-side, not spored-side: a box only gets a spore.host name if the launcher sets spawn:dns-name. (My spawn-ts browser launcher doesn't set it — that's on me; I'll add it. But worth confirming the Go spawn launch default: does it always set spawn:dns-name — e.g. defaulting to the instance name — or only when --dns-name is passed? If the latter, "no DNS by default" may be expected behavior rather than a bug.)
    2. Observability gap worth fixing regardless: when config.DNSName == "", spored logs nothing about DNS. A single log.Printf("DNS registration skipped: no spawn:dns-name configured") (or an info line when it is attempting) would have made this a 30-second diagnosis instead of a live-instance investigation. Right now a silent skip is indistinguishable from a silent failure.

    Whether #435 stays open probably depends on (1): if spawn launch is supposed to set spawn:dns-name by default and doesn't, that's the real bug; if DNS is opt-in via --dns-name, then the only actionable item is the logging in (2).

    (Found while dogfooding a browser SSM terminal — being able to read the spored journal live on the box is how I nailed this down.)

  6. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Answered my own open question by reading cmd/launch_config.go:195-201:

    if dnsName == "" && name != "" {
        dnsName = name          // --dns defaults to --name
    }
    ...
    if dnsName != "" {
        config.DNSName = dnsName
    }

    --name is required, and --dns defaults to it — so the Go spawn launch always sets config.DNSName, hence always emits spawn:dns-name, hence spored always registers. DNS-by-default is the intended behavior.

    Conclusion: this is a spawn-ts (my browser launcher) bug, not a spored or infra bug. spawn-ts collects a name but never maps it into the spawn:dns-name tag, so config.DNSName is empty on the instance and spored correctly skips registration. Nothing wrong on the daemon/Lambda side. I'll fix it in spawn-ts (emit spawn:dns-name defaulting to the launch name, matching the Go contract).

    Leaving the observability suggestion from my previous comment as the only spawn-side follow-up (a log line when DNS is skipped/attempted). Feel free to close #435 as "not a spawn bug" — happy to move the fix entirely to spawn-ts.

  7. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    ✅ Fixed on the spawn-ts side and validated live — root cause was the missing spawn:dns-name tag, nothing wrong with spored or the infra Lambda.

    Fix: spawn-ts now emits spawn:dns-name at launch (defaulting to a slugified launch name, mirroring the Go launcher's --dns = --name).

    Proof: launched a fresh t4g.nano with the tag present (spawn:dns-name=dnsfix-435) → dnsfix-435.5k0zfnmq.spore.host resolved to the instance's public IP 54.198.111.130 via public DoH within ~30s of boot. So the AuthType: AWS_IAM + SigV4 data path works end-to-end — my very first diagnosis on this issue (auth rejection) was a red herring; the requests simply were never sent because no DNS name was configured.

    Net for this repo: no spawn/spored code change required. The only optional spawn-side follow-up remains the observability nit — a log line when spored skips DNS for an empty config.DNSName, so a genuinely-missing name is distinguishable from a silent failure. Otherwise this can be closed as "not a spawn bug" (fix lived in the browser launcher).

  8. scttfrdmn commented on Jul 23, 2026

    @scttfrdmn
    ContributorAuthor

    Resolved — root cause was client-side (spawn-ts), spawn-side observability added

    Confirming your root-cause and closing.

    Root cause (yours): spawn-ts never mapped its launch name into the spawn:dns-name tag, so config.DNSName was empty on the instance and spored correctly skipped registration. The Go spawn launch always sets it (--dns defaults to the required --name, per launch_config.go:195-201). Nothing wrong with spored, the DNS Lambda, SigV4 signing, the IAM grant, or the infra — all verified working end-to-end on live instances (registered + publicly resolved). The DNS-registration fix belongs entirely in spawn-ts.

    Spawn-side follow-up shipped (your suggestion): PR #437 (merged). The agent's DNS if/else chain had no branch for the most common case (config.DNSName == ""), so a missing spawn:dns-name tag skipped registration with zero log output — which is precisely why a launcher bug masqueraded as a broken registration path. spored now logs:

    DNS registration skipped: no DNS name configured (no spawn:dns-name tag on the instance)
    

    Together with PR #436 (surfaced HTTP status, spawn:dns-status/spawn:dns-error tags, spawn status warning, fail-closed on empty creds) and the #434 doc fix, a future occurrence of this class is diagnosable at a glance.

    Closing as root-caused to spawn-ts; spawn-side observability added (#436, #437). The spawn-ts tag-mapping fix is tracked on that repo.

    (Full disclosure: my intermediate comments on this issue proposed several wrong spawn-side root causes — all measurement artifacts of how I was probing, not real defects. The daemon/Lambda/infra path was correct throughout; you identified the actual client-side cause. Cost: gated t4g.nano repros, all terminated + leak-checked, dev account clean, ~$0.00.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions