From 4b568b59a28d6fc466671b92ecd68fc45d1c075e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 25 Nov 2026 09:19:49 -0700 Subject: names: POST /admin/forget-key removes everything a key holds, as Delete my account does for its own signer. For the 528 @coinos.io names an attacker took on 2026-11-24 through the old site's /migrate hole (its grant trusted the form's username), all held by one key: the names go back to unclaimed with their grants and DNS records. Refused while sats are owed to the key's names; dryRun reports what would go; the removed records come back for the operator's file. Approved by Adam 2026-11-25 ("Yes to all 3"). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg --- names/server.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'names/server.js') diff --git a/names/server.js b/names/server.js index 600b12a..553377e 100644 --- a/names/server.js +++ b/names/server.js @@ -2136,6 +2136,34 @@ Bun.serve({ return json({ error: 'action is deliver or writeoff' }, 400); } + // Remove everything a key holds here, as "Delete my account" does for its + // own signer, for a key an operator names: the 528 @coinos.io names an + // attacker took through the old site's /migrate hole on 2026-11-24 (the + // grant trusted the form's username), all held by one key. The names go + // back to unclaimed, their grants and DNS records with them. Refused + // while sats are owed to the key's names (blockers), as for a user. + // { pubkey, dryRun } → the records removed, for the operator's file. + if (url.pathname === '/admin/forget-key' && req.method === 'POST') { + if (!CFG.adminToken || req.headers.get('x-admin-token') !== CFG.adminToken) return json({ error: 'unauthorized' }, 401); + let b; try { b = await req.json(); } catch { return json({ error: 'bad body' }, 400); } + const pubkey = String(b.pubkey || '').toLowerCase(); + if (!/^[0-9a-f]{64}$/.test(pubkey)) return json({ error: 'pubkey is 64 hex' }, 400); + const acct = accountOf(state, pubkey); + const hold = accountBlockers(state, acct); + const grants = Object.entries(state.migrations || {}).filter(([k, g]) => acct.names.includes(k) || g?.pubkey === pubkey || g?.manager === pubkey); + const snapshot = { names: Object.fromEntries(acct.names.map((k) => [k, state.names[k]])), migrations: Object.fromEntries(grants) }; + if (b.dryRun || hold.any) { + return json({ dryRun: !!b.dryRun, names: acct.names.length, grants: grants.length, keys: [...acct.keys], blockers: hold, snapshot }, hold.any && !b.dryRun ? 409 : 200); + } + const out = forgetAccount(state, acct); + persist(); + let dnsFailed = 0; + for (const d of out.dns) await cfDelete(d.domain, d.recordId, d.name).catch((e) => { dnsFailed++; log(`forget-key: dns record for ${d.name} stayed: ${e.message}`); }); + if (ln) for (const id of out.offers) await ln.call('disableoffer', { offer_id: id }).catch(() => {}); + log(`forget-key ${pubkey.slice(0, 12)}…: ${acct.names.length} names released ${JSON.stringify(out.removed)}${dnsFailed ? `, ${dnsFailed} dns records stayed` : ''}${b.note ? ` — ${String(b.note).slice(0, 200)}` : ''}`); + return json({ ok: true, removed: out.removed, dnsRecords: out.dns.length, dnsFailed, snapshot }); + } + if (url.pathname === '/admin/topup' && req.method === 'POST') { if (!CFG.adminToken || req.headers.get('x-admin-token') !== CFG.adminToken) { return json({ error: 'unauthorized' }, 401); -- cgit v1.2.3