Corroborate deposit credits, not just external spends (B-59)
A candidate external spend has needed a quorum since B-29, but `value` and `height` for a *credit* came from the single active connection and went straight into utxo_events. One hostile or broken server could therefore inflate a user's displayed balance with outpoints that don't exist. It never spends anyone else's coins — a bet or withdrawal built on a phantom UTXO is refused at broadcast and rolled back — but it wedges the balance display and burns build attempts, and on a custodial platform a balance that isn't real is a support incident either way. Balances move in both directions; both directions now need the same quorum. corroborate_utxo_credit asks the other configured servers whether they report the same outpoint, for the same amount, confirmed. The height itself isn't compared: a server still catching up reports height 0 and simply doesn't agree, which is the same answer, while two honest servers can't disagree on the height of a genuinely confirmed outpoint. refresh_user gains the phase that shape already implied: find_new_credit_ candidates (new, confirmed, not already held) inside the first session, corroboration outside any session, then credit_confirmed_utxos over what survived. Only new outpoints are corroborated — re-checking what we already hold would open a connection to every other server on every refresh for an answer that can no longer change anything. A failed corroboration delays a credit, it never loses one: the next scripthash notification or DepositReconciler sweep (300s) re-offers the same outpoint, and the withholding is logged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0aac73e557
commit
6246b13247
6 files changed
+223
-24
No files matched your search
@@ -40,21 +40,6 @@ remains the last prerequisite for running unattended.
|
||||
|
||||
## High — security
|
||||
|
||||
### B-59 — deposit crediting is not corroborated, unlike external-spend detection
|
||||
|
||||
`app/deposits/service.py:31-45`, `app/electrum/listener.py:401-433`.
|
||||
|
||||
A candidate external spend is corroborated across the other configured servers
|
||||
before it can reduce a balance (B-29), but `value` and `height` for a *credit*
|
||||
are taken from the single active connection with no cross-check. A hostile or
|
||||
broken server can inflate a user's displayed balance with outpoints that do not
|
||||
exist. The blast radius is bounded — a bet or withdrawal built on a phantom UTXO
|
||||
is refused at broadcast and the rollback releases it — but it wedges the user's
|
||||
balance display and burns build attempts.
|
||||
|
||||
Fix: either corroborate credits the same way (symmetry with B-29), or record the
|
||||
asymmetry explicitly as an accepted risk in CLAUDE.md with its bound stated.
|
||||
|
||||
### B-60 — `POST /admin/bug-reports/{id}/status` writes no audit entry
|
||||
|
||||
`app/api/routes/admin.py:404-419`.
|
||||
|
||||
Reference in new issue
Block a user