Repository navigation
Description
Problem
Onboarding an account is one-way. There is no path by which spore.host ever concludes "this account is gone" — so the state it leaves behind is permanent, and one piece of it is a genuine security hazard.
Three places encode this, all by construction rather than oversight:
- The account registry is append-only.
spore-host/lambda/portal-phone-home/registry.goexposesPutAccountandGetAccountand nothing else — no delete, no status, no last-seen. A registration cannot be retired. - The reaper's account list is static config.
lambda/ttl-reaper/main.go:985derives each sweep subdomain fromr.accounts, populated purely fromREAPER_ROLE_ARNS. An account is swept because a human typed it into a deploy, and stops being swept because a human edited it out. dns-updaterpersists nothing. It writes Route53 and forgets. Route53 is therefore the only durable record that an account ever existed.
Two distinct failure modes
A. Forgotten-but-still-listed. The account goes away; its ARN stays in REAPER_ROLE_ARNS. The reaper burns a failing assume-role every 10 minutes forever, and each failure increments sum.Errors (main.go:416,439) — the field that is supposed to mean investigate this. Permanent expected failures train the operator to ignore the error count.
B. Forgotten-and-never-listed — silent, and live today. Records exist under {base36}.spore.host for an account absent from REAPER_ROLE_ARNS. Nothing sweeps it, nothing errors, nothing reports it.
Concrete instance: win11-test.4zlw3a1t.spore.host → 13.223.189.34. Subdomain 4zlw3a1t decodes to account 390967728545, which is not in REAPER_ROLE_ARNS, has no cross-account role, and appears nowhere in any spore-host repo. The IP is back in the general us-east-1 EC2 pool and no longer responds — so this name will eventually resolve to an unrelated instance once AWS reassigns the address. Stale DNS pointing at a stranger, not merely a dead name. (Found while verifying #438; deliberately left in place.)
What can and cannot be expired
The thing you would most want a TTL on is not ours to expire. deployment/cloudformation/ttl-reaper-cross-account-role.yaml creates spawn-ttl-reaper-ec2 in the customer's account; spore.host holds only the trust relationship. We cannot delete it — only they can. An IAM role with no caller is also inert and free, so no cost pressure forces the issue.
What is ours, ranked by hazard:
| Artifact | Owner | Hazard | Wants |
|---|---|---|---|
Route53 records under {base36}.{domain} |
spore.host | Real — IP returns to the EC2 pool; name resolves to a stranger | Shortest grace period, not the longest |
Registry row (spore-portal-accounts) |
spore.host | None (costs nothing; it is the audit trail) | status + lastSeenAt, not deletion |
REAPER_ROLE_ARNS entry |
spore.host (config) | Noise — poisons Errors |
Auto-quiesce after sustained failure |
spawn-ttl-reaper-ec2 role |
customer | None | Nothing — out of our control |
Note the DNS row inverts the usual instinct: the security consequence argues for expiring records sooner, not keeping them around just in case.
The liveness signal already exists, for free
The reaper assumes every role every 10 minutes. That is already a paid-for liveness probe, and it distinguishes exactly the states that matter:
- assume succeeds, zero managed instances for N days → dormant but reachable
- assume fails, role not found → the customer uninstalled
Role deletion is the natural uninstall gesture. No new API and no customer action beyond what they would already do.
Two traps that make the naive version dangerous
1. Correlated failure is indistinguishable from mass uninstall. The reaper's role ARN is …spawn-ttl-reaper-production-TTLReaperFunctionRole-ZJ84YZ2dCPei — a CloudFormation-generated physical ID. Recreating that stack changes the suffix and breaks every customer's trust policy simultaneously. A TTL that deprovisions on assume-role failure would then forget the entire customer base because we redeployed. Never act on a single failure; explicitly refuse to act when all accounts fail at once. Same instinct as the sweep's existing "never delete against a partial live set" guard (main.go:987-992).
2. We lose the ability to verify at the exact moment we would act. "Only the role is left, no other resources" requires a working assume-role to confirm — DescribeInstances is how we know the account is empty. Once the role is gone that check is impossible, so we would be deciding blind. win11-test is precisely this case: records present, emptiness unverifiable except by the weak inference that the IP stopped responding.
Proposed policy
Grace, then narrow, then never silently delete what cannot be verified.
- Unreachable — assume-role fails for K consecutive runs while other accounts succeed: mark the registry row
unreachable, stop counting it intoErrors. No deletion. - Dormant — assume-role works and zero managed instances for N days: safe to expire that account's DNS records, because emptiness is provable.
- Unmanaged subdomain — records under a
{base36}we hold no credentials for: report, never delete. We cannot distinguish "abandoned" from "someone forgot to add this account toREAPER_ROLE_ARNS," and deleting in the second case breaks a working spore. - Explicit offboard — an operator/customer-initiated deprovision that may delete records, because intent is stated rather than inferred.
K and N are the open decisions. Suggest K=6 (one hour) and N=30 days, both configurable.
Suggested split
Two separable pieces; the first is worth doing regardless of how the policy lands.
- Orphan-subdomain report in the reaper. (shipped in feat(ttl-reaper): report account subdomains with no credentials (#457) #458) One
ListResourceRecordSetsover the zone → distinct{base36}labels → decode (strconv.ParseUint(label, 36, 64), the inverse ofdns.EncodeAccountID) → diff against the configured account set → log + count the unmanaged ones. Report-only, no deletion. Small, safe, and unit-testable without AWS in the same style assweepableRecord. Would have surfaced4zlw3a1tthe day it appeared. - Registry lifecycle fields (shipped in feat(portal-phone-home): account lifecycle state machine (spawn#457) spore-host#490; cross-repo wiring to the reaper still open — see the comments) (
status,lastSeenAt) + the state machine above. Touches the onboarding contract, so it deserves its own decision.
Caveat on liveness tests
Checking AWS Organizations membership is not a general staleness test. BYOA accounts belong to customers and are legitimately outside our org. AccountNotFoundException only proved staleness for 4zlw3a1t because that happened to be one of our own test accounts.
Filed from the #438 verification work; see #438 for the sweep's current safety contract.
Activity
feat(ttl-reaper): report account subdomains with no credentials (#457)
feat(ttl-reaper): report account subdomains with no credentials (#457) (
scttfrdmn commentedon Jul 31, 2026
Checkbox 2 (registry lifecycle + the state machine) is implemented in spore-host/spore-host#490 — all CI green. K=6 / N=30d as suggested here, both configurable on
LifecyclePolicy.Landed in
lambda/portal-phone-home/lifecycle.go(the schema's owner) rather than in the reaper, so the fields and the transitions live next to the table they describe.Both traps from this issue are enforced and mutation-verified:
ApplyProbeschanges nothing when every probe fails. Neutering that guard fails two tests. The sharp edge turned out to be the single-account deployment, where "all probes failed" and "this one account failed" are literally the same observation; the guard resolves it as uninformative, which is the right answer but worth naming since it means a one-account deploy can never auto-transition on failure at all.DNSExpiryEligible()returns true for onlydormant(emptiness proven through a workingDescribeInstances) andoffboarded(stated intent).unreachabledeletes nothing. Unknown/future status strings return false, so a typo can't authorize a deletion.Two things worth flagging beyond the plan:
Mutation testing caught a real bug — the unreachable branch guarded against re-entering its own state but not against overwriting
offboarded. That would have downgraded a stated human decision to a weaker inferred one and stripped the DNS-expiry eligibility offboarding deliberately granted. Fixed, with the reasoning in the code.lambda/portal-phone-homewas absent from the CI test matrix entirely — so its tests had never run, includingTestValidate_SecurityInvariant, which covers the SigV4 verified-principal check that is the whole authorization model for BYOA onboarding. Added in the same PR at a 70% floor (actual 76.8%). Unrelated to this issue, but found on the way through.Schema compatibility: every new field is
omitemptyandAccountStatus()maps""→active, so existing rows need no backfill.Still open — the cross-repo wiring, which is why I'm leaving this issue open:
ApplyProbeshas no production caller. The reaper needs to (a) collect aProbeResultper account per run, (b) getdynamodb:Scan+dynamodb:UpdateItemonspore-portal-accountsin its own execution role, and (c) consultDNSExpiryEligiblebefore expiring records. I deliberately did not add those IAM grants to the phone-home role in #490, since they'd be permissions with no caller.One design question that wiring will force, and I'd rather decide it deliberately: the reaper currently scans accounts from
REAPER_ROLE_ARNSconfig, while the registry is the durable list. Once the reaper reads the table, there are two sources of truth for "which accounts exist". The clean end state is config seeding the registry and the registry driving the sweep — but that changes how an operator adds an account, so it isn't a silent refactor.scttfrdmn commentedon Jul 31, 2026
Filed the wiring as spore-host/spore-host#491, and it lands somewhere different from what this issue proposed — worth recording why here, since the design above says the reaper should do the probing.
The reaper cannot assume the registry's roles. There are two distinct cross-account roles, and onboarding only ever creates one:
spawn-ttl-reaper-ec2spore-portal-onboardspawn onboardspawn-ttl-reaperREAPER_ROLE_ARNSspore-portal-accountsSo every
roleArnthe reaper would read from the registry is one its own trust policy excludes.The failure mode is the interesting part. Config-derived accounts would have kept succeeding while every registry-derived account failed — and the correlated-failure guard only trips when all probes fail, so it would not have fired. Within K=6 runs (one hour), every portal-onboarded account would have been marked
unreachable.The guard cannot catch this by construction: from the inside, "a set of accounts whose role we are not trusted by" is indistinguishable from "a set of customers who uninstalled". That is precisely trap 1 from this issue, arriving through a door the guard does not cover. Good argument for the guard being necessary but not sufficient, and for keeping the probe's trust boundary explicit rather than inherited.
Where it goes instead: a scheduled Lambda in the infra account that assumes the portal onboarding role. The trust already exists (
PortalPhoneHomeLambdaRoleis the trusted principal), the registry already holds the matching ExternalId, andspore-portal-onboardalready grantsec2:DescribeInstances— which is exactly what proving emptiness requires. Works for every already-registered account with no template change and no re-onboarding, and needs only Describe, never Terminate.And the two-sources-of-truth question I raised earlier dissolves rather than needing a decision.
REAPER_ROLE_ARNSis the TTL-enforcement list (who can we terminate in); the registry is the lifecycle list (who onboarded, are they still there). Different roles, different trust, different questions. Treating them as competing was a framing error on my part — nothing needs reconciling.The reaper does still get one small change, tracked in #491: consult
DNSExpiryEligiblebefore expiring a subdomain's records. That is read-only access to a table in its own account — no assume-role, no trust problem.Rejected on the way: adding the reaper's role to the onboarding template. It requires re-onboarding every existing account (a template change doesn't alter deployed stacks) and puts a Terminate-capable role on the portal's onboarding path, collapsing the current split between the portal's launch/manage role and the reaper's out-of-band kill role.
feat(ttl-reaper): expire unmanaged subdomain DNS on registry verdict (#…
feat(ttl-reaper): expire unmanaged subdomain DNS on registry verdict (#…
feat(ttl-reaper): expire unmanaged subdomain DNS on registry verdict (#…
scttfrdmn commentedon Jul 31, 2026
Status after #468 (merged as
a0a6383). Three of the four policy branches now ship; the remaining two gaps are filed separately, so this design issue's own scope is nearly closed.Errors{base36}we hold no credentials forDNSExpiryEligiblereturns true for it; no caller anywhereOn the third row, the policy as written here has been superseded — deliberately. This issue said "report, never delete," and gave the right reason: we cannot distinguish "abandoned" from "someone forgot to add this account to
REAPER_ROLE_ARNS," and deleting in the second case breaks a working spore.What changed is not the risk tolerance but the evidence. The blocker was never caution, it was capability — #458's comment put it exactly: "we cannot tell the two apart precisely because we lack the credentials." The prober assumes
spore-portal-onboard— a role the registry knows about, distinct from the reaper'sspawn-ttl-reaper-ec2— and proves emptiness across every region withDescribeInstances, which is the check this issue identified as the one that matters. So for an account in the registry, the distinction this row declared impossible is now decidable.For an account absent from the registry, the original rule still holds unchanged and unconditionally: report, never delete. The prober has no opinion, so the ambiguity stands in full.
Trap 2 survived intact.
unreachableexpires nothing, for the reason stated here: the moment we would most want to clean up is the moment the role we would have verified through is gone. It needs a human, not a longer wait.Two switches guard the change (
REAPER_DNS_SWEEPand a new default-offREAPER_DNS_EXPIRE) because the sweep is already enabled in production — folding expiry into it would make an existing flag destructive on upgrade for a class of records it has never touched. And the asymmetry this issue flagged in its own table is why:sporedregisters DNS once at boot with no re-registration, so a wrongly deleted A-record never self-heals. The spore keeps running, merely unreachable by name until it reboots.4zlw3a1t(account 390967728545) — the concrete instance filed here — is now reported with its registry verdict on every run. It will only be expired once the prober has independently marked itdormantand an operator sets the second flag.Also worth recording: the reaper's
dynamodbgrant isScanand nothing else — noUpdateItem, noPutItem. That the reaper cannot write the table is what makes it impossible for a reaper bug to manufacture the eligibility it then acts on. The prober owns every write.feat(reaper): make failures observable and alarmable (#469) (#471)
scttfrdmn commentedon Oct 19, 2026
Design is implemented apart from one branch: unreachable (#469 closed + #490), dormant (#466/#468), and unmanaged subdomain (#458/#466) are all shipped. The remaining gap is that explicit offboard has no caller:
Registry.Offboard(spore-hostlambda/accountlifecycle/registry.go:212) is only called from tests. That is now spore-host/spore-host#602.