aboutsummaryrefslogtreecommitdiffstats
path: root/names
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-25 09:19:49 -0700
committerAdam Soltys <[email protected]>2026-11-25 09:19:49 -0700
commit4b568b59a28d6fc466671b92ecd68fc45d1c075e (patch)
tree691ede8e303d5f1f62367330c881d0200f87d074 /names
parente780c27a4449f7db03a117e39e2cd5c8ec9e73a1 (diff)
downloadcoinosv3-server-4b568b59a28d6fc466671b92ecd68fc45d1c075e.tar.gz
coinosv3-server-4b568b59a28d6fc466671b92ecd68fc45d1c075e.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg
Diffstat (limited to 'names')
-rw-r--r--names/server.js28
1 files changed, 28 insertions, 0 deletions
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);