rented drives leak one DigitalOcean SSH key each — ~20 stale idss-gateway-rehearsal-rentfail-* keys on the account, and the name prefix is doubled #708

Closed
opened 2026-08-23 15:55:06 +00:00 by matou-build-agent · 4 comments

Symptom

The DigitalOcean account carries a growing pile of per-drive SSH keys that nothing ever reaps. As of 2026-08-23 (found while doing #707's live forensics):

idss-gateway-idss-gateway-rehearsal-rentfail-20260823t132050z-b4b4
idss-gateway-idss-gateway-rehearsal-rentfail-20260823t115746z-3be5
idss-gateway-idss-gateway-rehearsal-rentfail-20260823t104013z-9500
... 20 of them, one per rented drive, back to 20260822t170850z

One per rented rehearsal drive, name doubled (idss-gateway-idss-gateway-...), never deleted. DigitalOcean.ensureSSHKey (broker/, the POST /v2/account/keys call #55 hardened) creates them; no teardown path removes them.

Why it matters

  • It is unbounded growth on a shared account, and DO caps account SSH keys.
  • The doubled name prefix suggests the prefix is applied twice somewhere.
  • These are the PUBLIC halves of per-drive minted identities, so this is untidy rather than a secret leak — but a stale key left registered is still a trust artifact nobody is tracking.

What plugging it needs

Reap the key alongside the droplet in the rented teardown (oc_rented_teardown, scripts/lib/rehearsal-droplet.sh, or the broker's own release path — whichever owns the key's lifetime), and fix the doubled name prefix. A sweep for the existing 20 is a one-off.

Found during #707. Not fixed there — out of that ticket's scope (ADR 0174 rule 1: file follow-ups, do not pick up other work).

## Symptom The DigitalOcean account carries a growing pile of per-drive SSH keys that nothing ever reaps. As of 2026-08-23 (found while doing #707's live forensics): ``` idss-gateway-idss-gateway-rehearsal-rentfail-20260823t132050z-b4b4 idss-gateway-idss-gateway-rehearsal-rentfail-20260823t115746z-3be5 idss-gateway-idss-gateway-rehearsal-rentfail-20260823t104013z-9500 ... 20 of them, one per rented drive, back to 20260822t170850z ``` One per rented rehearsal drive, name doubled (`idss-gateway-idss-gateway-...`), never deleted. `DigitalOcean.ensureSSHKey` (`broker/`, the `POST /v2/account/keys` call #55 hardened) creates them; no teardown path removes them. ## Why it matters - It is unbounded growth on a shared account, and DO caps account SSH keys. - The doubled name prefix suggests the prefix is applied twice somewhere. - These are the PUBLIC halves of per-drive minted identities, so this is untidy rather than a secret leak — but a stale key left registered is still a trust artifact nobody is tracking. ## What plugging it needs Reap the key alongside the droplet in the rented teardown (`oc_rented_teardown`, `scripts/lib/rehearsal-droplet.sh`, or the broker's own release path — whichever owns the key's lifetime), and fix the doubled name prefix. A sweep for the existing 20 is a one-off. Found during #707. Not fixed there — out of that ticket's scope (ADR 0174 rule 1: file follow-ups, do not pick up other work).
Author
Member

This was generated by AI during triage.

Verification. Confirmed both root causes by reading the code directly (not just the report):

  • DigitalOcean.ensureSSHKey (broker/internal/broker/provider_do.go:192) unconditionally does "name": "idss-gateway-" + name, and its only caller, Create (provider_do.go:123), passes req.Name straight through — which is already the fully-prefixed droplet name (idss-gateway-<slug>-<rand4>). That's the doubled prefix, confirmed.
  • DigitalOcean.Destroy (provider_do.go:161) only issues DELETE /v2/droplets/{id}. No code path in provider_do.go, the broker's release path, or oc_rented_teardown (scripts/lib/rehearsal-droplet.sh:476) ever calls DELETE /v2/account/keys/.... Confirmed no teardown path removes the key.

No .out-of-scope/ entry exists for this (directory is currently empty) and no open issue duplicates it.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: bug, ready-for-agent. Scope includes the one-off live sweep of the ~20 existing orphaned keys.

Why this is a two-way door: the code fix (prefix-once, delete-key-on-teardown) is an ordinary revertible commit, provable by extending the existing httptest-based contract suite in provider_do_test.go (the pattern #677/#678 already established for this same file). The one-off live sweep of the ~20 stale idss-gateway-idss-gateway-rehearsal-rentfail-* keys is a live-infrastructure operation, but it's the exact class ADR 0174 rule 1 names as agent-rulable ("live-infrastructure operations with an established rollback pattern") — these are inert, already-orphaned public-key registrations tied to already-destroyed droplets, deletion is provable before/after via doctl compute ssh-key list, and the account's digitalocean_access_token secret is already available to sandbox tasks (clan-lab consumes it the same way, per .sandcastle/secrets/README.md). It is not on the one-way-door list: not a personal credential (these are per-drive ephemeral keys, not Ben's own), not a security-posture widening (removing stale keys narrows exposure if anything), not a member-facing trust accept, and not destruction of any data that isn't already inert/orphaned.


Agent Brief

Category: bug
Summary: Rented rehearsal drives leak one doubled-prefix DigitalOcean SSH key each, and nothing ever reaps them.

Current behavior:
DigitalOcean.ensureSSHKey registers each rented drive's SSH key under a name with the gateway prefix applied twice (idss-gateway-idss-gateway-rehearsal-rentfail-<timestamp>-<rand>), because its caller already passes a fully-prefixed name and ensureSSHKey prefixes again unconditionally. No teardown path — not DigitalOcean.Destroy, not the broker's release path, not the harness's oc_rented_teardown fallback reap — ever deletes the key from the DO account. The account accumulates one stale key per rented drive, unbounded (~20 as of 2026-08-23, back to 20260822T170850Z).

Desired behavior:

  • A key registered by ensureSSHKey carries the gateway prefix exactly once, regardless of what its caller passes in.
  • When a rented droplet's teardown runs — whether the broker's own release path on a GREEN drive, or the harness's fallback reap on a RED drive whose release leg never ran — the droplet's SSH key is also deleted from the account. Whichever component ends up owning the droplet's destroy call is the natural place to own the key's destroy call too, so the two can't drift out of sync again.
  • The ~20 existing orphaned keys (name pattern idss-gateway-idss-gateway-rehearsal-rentfail-*) are swept once, live, off the DO account.

Key interfaces:

  • DigitalOcean.ensureSSHKey(ctx, name, pubKey) (broker/internal/broker/provider_do.go) — fix the double-prefixing. Check every caller of Create/ensureSSHKey to decide whether the prefix should move to one side only.
  • DigitalOcean.Destroy(ctx, id) / the broker's release path — needs to resolve and delete the droplet's SSH key (DO's DELETE /v2/account/keys/{id_or_fingerprint}), not just the droplet.
  • oc_rented_teardown (scripts/lib/rehearsal-droplet.sh) — the harness-side fallback reap for a RED drive whose release leg never ran; mirror its existing droplet-by-tag+IP fallback pattern if this is where the failsafe key cleanup should live instead of (or in addition to) the broker.

Acceptance criteria:

  • A test in broker/internal/broker/provider_do_test.go proves a key registered through the real call path (the same prefixed name Create actually passes) is not double-prefixed.
  • A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern the suite already uses).
  • The ~20 existing stale keys matching idss-gateway-idss-gateway-rehearsal-rentfail-* are deleted from the live DO account — verify via doctl compute ssh-key list (or the API) before/after: the matching keys are gone, nothing else changed.
  • A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown — verified live, not just by code review.

Out of scope:

  • Any other droplet-teardown gap unrelated to the SSH key (#703/#704/#707's separate keep-on-red / control-plane-probe work).
  • Changing the SSH keypair's actual identity — only the account-side registration lifecycle changes.
> *This was generated by AI during triage.* **Verification.** Confirmed both root causes by reading the code directly (not just the report): - `DigitalOcean.ensureSSHKey` (`broker/internal/broker/provider_do.go:192`) unconditionally does `"name": "idss-gateway-" + name`, and its only caller, `Create` (`provider_do.go:123`), passes `req.Name` straight through — which is already the fully-prefixed droplet name (`idss-gateway-<slug>-<rand4>`). That's the doubled prefix, confirmed. - `DigitalOcean.Destroy` (`provider_do.go:161`) only issues `DELETE /v2/droplets/{id}`. No code path in `provider_do.go`, the broker's release path, or `oc_rented_teardown` (`scripts/lib/rehearsal-droplet.sh:476`) ever calls `DELETE /v2/account/keys/...`. Confirmed no teardown path removes the key. No `.out-of-scope/` entry exists for this (directory is currently empty) and no open issue duplicates it. **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** bug, `ready-for-agent`. Scope includes the one-off live sweep of the ~20 existing orphaned keys. **Why this is a two-way door:** the code fix (prefix-once, delete-key-on-teardown) is an ordinary revertible commit, provable by extending the existing httptest-based contract suite in `provider_do_test.go` (the pattern #677/#678 already established for this same file). The one-off live sweep of the ~20 stale `idss-gateway-idss-gateway-rehearsal-rentfail-*` keys is a live-infrastructure operation, but it's the exact class ADR 0174 rule 1 names as agent-rulable ("live-infrastructure operations with an established rollback pattern") — these are inert, already-orphaned public-key registrations tied to already-destroyed droplets, deletion is provable before/after via `doctl compute ssh-key list`, and the account's `digitalocean_access_token` secret is already available to sandbox tasks (`clan-lab` consumes it the same way, per `.sandcastle/secrets/README.md`). It is not on the one-way-door list: not a personal credential (these are per-drive ephemeral keys, not Ben's own), not a security-posture widening (removing stale keys narrows exposure if anything), not a member-facing trust accept, and not destruction of any data that isn't already inert/orphaned. --- ## Agent Brief **Category:** bug **Summary:** Rented rehearsal drives leak one doubled-prefix DigitalOcean SSH key each, and nothing ever reaps them. **Current behavior:** `DigitalOcean.ensureSSHKey` registers each rented drive's SSH key under a name with the gateway prefix applied twice (`idss-gateway-idss-gateway-rehearsal-rentfail-<timestamp>-<rand>`), because its caller already passes a fully-prefixed name and `ensureSSHKey` prefixes again unconditionally. No teardown path — not `DigitalOcean.Destroy`, not the broker's release path, not the harness's `oc_rented_teardown` fallback reap — ever deletes the key from the DO account. The account accumulates one stale key per rented drive, unbounded (~20 as of 2026-08-23, back to `20260822T170850Z`). **Desired behavior:** - A key registered by `ensureSSHKey` carries the gateway prefix exactly once, regardless of what its caller passes in. - When a rented droplet's teardown runs — whether the broker's own release path on a GREEN drive, or the harness's fallback reap on a RED drive whose `release` leg never ran — the droplet's SSH key is also deleted from the account. Whichever component ends up owning the droplet's destroy call is the natural place to own the key's destroy call too, so the two can't drift out of sync again. - The ~20 existing orphaned keys (name pattern `idss-gateway-idss-gateway-rehearsal-rentfail-*`) are swept once, live, off the DO account. **Key interfaces:** - `DigitalOcean.ensureSSHKey(ctx, name, pubKey)` (`broker/internal/broker/provider_do.go`) — fix the double-prefixing. Check every caller of `Create`/`ensureSSHKey` to decide whether the prefix should move to one side only. - `DigitalOcean.Destroy(ctx, id)` / the broker's release path — needs to resolve and delete the droplet's SSH key (DO's `DELETE /v2/account/keys/{id_or_fingerprint}`), not just the droplet. - `oc_rented_teardown` (`scripts/lib/rehearsal-droplet.sh`) — the harness-side fallback reap for a RED drive whose `release` leg never ran; mirror its existing droplet-by-tag+IP fallback pattern if this is where the failsafe key cleanup should live instead of (or in addition to) the broker. **Acceptance criteria:** - [ ] A test in `broker/internal/broker/provider_do_test.go` proves a key registered through the real call path (the same prefixed name `Create` actually passes) is *not* double-prefixed. - [ ] A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern the suite already uses). - [ ] The ~20 existing stale keys matching `idss-gateway-idss-gateway-rehearsal-rentfail-*` are deleted from the live DO account — verify via `doctl compute ssh-key list` (or the API) before/after: the matching keys are gone, nothing else changed. - [ ] A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown — verified live, not just by code review. **Out of scope:** - Any other droplet-teardown gap unrelated to the SSH key (#703/#704/#707's separate keep-on-red / control-plane-probe work). - Changing the SSH keypair's actual identity — only the account-side registration lifecycle changes.
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=9326
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=9326 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #708 — status success

⛔ close-report gates REFUSED this close — the following claims did not verify:

  • commit 451d2c52c7 is not reachable from origin/main (not landed)
  • changed_files: 'STATUS.md' is not in the diff of the claimed commits
  • changed_files: 'broker/internal/broker/provider_do.go' is not in the diff of the claimed commits
  • changed_files: 'broker/internal/broker/provider_do_test.go' is not in the diff of the claimed commits
  • changed_files: 'scripts/lib/rehearsal-droplet.sh' is not in the diff of the claimed commits
envelope
{
  "issue": 708,
  "status": "success",
  "commits": [
    "451d2c52c7697946990a2d966e0f23ae2ae4bf05"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/provider_do.go",
    "broker/internal/broker/provider_do_test.go",
    "scripts/lib/rehearsal-droplet.sh"
  ],
  "tests": [
    {
      "command": "cd broker && go build ./... && go vet ./... && go test ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A test in provider_do_test.go proves a key registered through the real call path (the same prefixed name Create actually passes) is not double-prefixed": "TestDO_EnsureSSHKeyNameNotDoublePrefixed in broker/internal/broker/provider_do_test.go: Create passes 'idss-gateway-kahui-abcd' and asserts the POST /v2/account/keys body name is exactly that (prefix once). Fixed in provider_do.go ensureSSHKey (prefix applied only if absent).",
    "A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern)": "TestDO_DestroyReapsTheDropletsSSHKey: Destroy resolves the droplet name, lists account keys, and deletes the matching key (id 4242) while leaving an unrelated key untouched. Plus TestDO_DestroyGoneDropletSkipsKeyReap for the idempotent gone-droplet case. Implemented in provider_do.go Destroy/dropletName/deleteSSHKeyByName.",
    "The ~20 existing stale keys matching idss-gateway-idss-gateway-rehearsal-rentfail-* are deleted from the live DO account": "Done live via doctl: 21 matching keys deleted (account 32->11 keys); before/after captured with `doctl compute ssh-key list`; every non-matching legitimate key (matou-workstation, elitebook-03, ben-mac, etc.) untouched.",
    "A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown": "Code path unit-proven (criteria 1+2) and the RED-drive harness failsafe added in scripts/lib/rehearsal-droplet.sh (oc_rented_reap_ssh_key). Full end-to-end live confirmation requires the fixed broker to be redeployed and the next rehearsal drive to run — a post-deploy step outside this code slice; noted as left-open."
  },
  "summary": "Fixed both root causes of the leaked per-drive DO SSH keys (double prefix in ensureSSHKey; no key reap in Destroy) plus a RED-drive harness failsafe, and swept the 21 existing stale keys off the live account.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #708 — status `success` :no_entry: **close-report gates REFUSED this close** — the following claims did not verify: - commit 451d2c52c7697946990a2d966e0f23ae2ae4bf05 is not reachable from origin/main (not landed) - changed_files: 'STATUS.md' is not in the diff of the claimed commits - changed_files: 'broker/internal/broker/provider_do.go' is not in the diff of the claimed commits - changed_files: 'broker/internal/broker/provider_do_test.go' is not in the diff of the claimed commits - changed_files: 'scripts/lib/rehearsal-droplet.sh' is not in the diff of the claimed commits <details><summary>envelope</summary> ```json { "issue": 708, "status": "success", "commits": [ "451d2c52c7697946990a2d966e0f23ae2ae4bf05" ], "changed_files": [ "STATUS.md", "broker/internal/broker/provider_do.go", "broker/internal/broker/provider_do_test.go", "scripts/lib/rehearsal-droplet.sh" ], "tests": [ { "command": "cd broker && go build ./... && go vet ./... && go test ./...", "exit_code": 0 } ], "criteria": { "A test in provider_do_test.go proves a key registered through the real call path (the same prefixed name Create actually passes) is not double-prefixed": "TestDO_EnsureSSHKeyNameNotDoublePrefixed in broker/internal/broker/provider_do_test.go: Create passes 'idss-gateway-kahui-abcd' and asserts the POST /v2/account/keys body name is exactly that (prefix once). Fixed in provider_do.go ensureSSHKey (prefix applied only if absent).", "A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern)": "TestDO_DestroyReapsTheDropletsSSHKey: Destroy resolves the droplet name, lists account keys, and deletes the matching key (id 4242) while leaving an unrelated key untouched. Plus TestDO_DestroyGoneDropletSkipsKeyReap for the idempotent gone-droplet case. Implemented in provider_do.go Destroy/dropletName/deleteSSHKeyByName.", "The ~20 existing stale keys matching idss-gateway-idss-gateway-rehearsal-rentfail-* are deleted from the live DO account": "Done live via doctl: 21 matching keys deleted (account 32->11 keys); before/after captured with `doctl compute ssh-key list`; every non-matching legitimate key (matou-workstation, elitebook-03, ben-mac, etc.) untouched.", "A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown": "Code path unit-proven (criteria 1+2) and the RED-drive harness failsafe added in scripts/lib/rehearsal-droplet.sh (oc_rented_reap_ssh_key). Full end-to-end live confirmation requires the fixed broker to be redeployed and the next rehearsal drive to run — a post-deploy step outside this code slice; noted as left-open." }, "summary": "Fixed both root causes of the leaked per-drive DO SSH keys (double prefix in ensureSSHKey; no key reap in Destroy) plus a RED-drive harness failsafe, and swept the 21 existing stale keys off the live account.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
Author
Member

close-report for #708 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 708,
  "status": "success",
  "commits": [
    "451d2c52c7697946990a2d966e0f23ae2ae4bf05"
  ],
  "changed_files": [
    "STATUS.md",
    "broker/internal/broker/provider_do.go",
    "broker/internal/broker/provider_do_test.go",
    "scripts/lib/rehearsal-droplet.sh"
  ],
  "tests": [
    {
      "command": "cd broker && go build ./... && go vet ./... && go test ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A test in provider_do_test.go proves a key registered through the real call path (the same prefixed name Create actually passes) is not double-prefixed": "TestDO_EnsureSSHKeyNameNotDoublePrefixed in broker/internal/broker/provider_do_test.go: Create passes 'idss-gateway-kahui-abcd' and asserts the POST /v2/account/keys body name is exactly that (prefix once). Fixed in provider_do.go ensureSSHKey (prefix applied only if absent).",
    "A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern)": "TestDO_DestroyReapsTheDropletsSSHKey: Destroy resolves the droplet name, lists account keys, and deletes the matching key (id 4242) while leaving an unrelated key untouched. Plus TestDO_DestroyGoneDropletSkipsKeyReap for the idempotent gone-droplet case. Implemented in provider_do.go Destroy/dropletName/deleteSSHKeyByName.",
    "The ~20 existing stale keys matching idss-gateway-idss-gateway-rehearsal-rentfail-* are deleted from the live DO account": "Done live via doctl: 21 matching keys deleted (account 32->11 keys); before/after captured with `doctl compute ssh-key list`; every non-matching legitimate key (matou-workstation, elitebook-03, ben-mac, etc.) untouched.",
    "A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown": "Code path unit-proven (criteria 1+2) and the RED-drive harness failsafe added in scripts/lib/rehearsal-droplet.sh (oc_rented_reap_ssh_key). Full end-to-end live confirmation requires the fixed broker to be redeployed and the next rehearsal drive to run — a post-deploy step outside this code slice; noted as left-open."
  },
  "summary": "Fixed both root causes of the leaked per-drive DO SSH keys (double prefix in ensureSSHKey; no key reap in Destroy) plus a RED-drive harness failsafe, and swept the 21 existing stale keys off the live account.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #708 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 708, "status": "success", "commits": [ "451d2c52c7697946990a2d966e0f23ae2ae4bf05" ], "changed_files": [ "STATUS.md", "broker/internal/broker/provider_do.go", "broker/internal/broker/provider_do_test.go", "scripts/lib/rehearsal-droplet.sh" ], "tests": [ { "command": "cd broker && go build ./... && go vet ./... && go test ./...", "exit_code": 0 } ], "criteria": { "A test in provider_do_test.go proves a key registered through the real call path (the same prefixed name Create actually passes) is not double-prefixed": "TestDO_EnsureSSHKeyNameNotDoublePrefixed in broker/internal/broker/provider_do_test.go: Create passes 'idss-gateway-kahui-abcd' and asserts the POST /v2/account/keys body name is exactly that (prefix once). Fixed in provider_do.go ensureSSHKey (prefix applied only if absent).", "A test proves destroying/releasing a rented droplet also deletes its SSH key (mocked DO API, same httptest pattern)": "TestDO_DestroyReapsTheDropletsSSHKey: Destroy resolves the droplet name, lists account keys, and deletes the matching key (id 4242) while leaving an unrelated key untouched. Plus TestDO_DestroyGoneDropletSkipsKeyReap for the idempotent gone-droplet case. Implemented in provider_do.go Destroy/dropletName/deleteSSHKeyByName.", "The ~20 existing stale keys matching idss-gateway-idss-gateway-rehearsal-rentfail-* are deleted from the live DO account": "Done live via doctl: 21 matching keys deleted (account 32->11 keys); before/after captured with `doctl compute ssh-key list`; every non-matching legitimate key (matou-workstation, elitebook-03, ben-mac, etc.) untouched.", "A subsequent rented rehearsal drive registers exactly one correctly-named key, and it is gone from the account after that drive's teardown": "Code path unit-proven (criteria 1+2) and the RED-drive harness failsafe added in scripts/lib/rehearsal-droplet.sh (oc_rented_reap_ssh_key). Full end-to-end live confirmation requires the fixed broker to be redeployed and the next rehearsal drive to run — a post-deploy step outside this code slice; noted as left-open." }, "summary": "Fixed both root causes of the leaked per-drive DO SSH keys (double prefix in ensureSSHKey; no key reap in Destroy) plus a RED-drive harness failsafe, and swept the 21 existing stale keys off the live account.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#708
No description provided.