Throttle login and registration with exponential backoff (B-33)
POST /auth/login had no rate limiting, no lockout, no delay — a patient distributed attack could brute-force a password against an enumerable username list on a custodial wallet, where a guessed password means withdrawing someone's funds. Add per-username and per-IP throttling with exponential backoff (app/auth/rate_limit.py), keyed on app.state like UserLocks rather than a module global so each app instance gets isolated throttle state. Unknown-user and wrong-password already shared one response path, so no enumeration oracle there. Registration is throttled per-IP too, which also bounds how many accounts one IP can spin up (B-31). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
17c557b8a3
commit
16802cafb6
5 files changed
+278
-22
No files matched your search
@@ -1,11 +1,11 @@
|
||||
# Known bugs
|
||||
|
||||
A second full-codebase audit on 2026-07-27 found **25 further issues** (4 critical, 6 high,
|
||||
7 medium, 8 low), listed below as B-33 … B-49. B-25 through B-32 are fixed (see "Previously
|
||||
fixed" below) — no Critical-severity finding remains open; the other 17 are High/Medium/Low.
|
||||
7 medium, 8 low), listed below as B-33 … B-49. B-25 through B-33 are fixed (see "Previously
|
||||
fixed" below) — no Critical-severity finding remains open; the other 16 are High/Medium/Low.
|
||||
The 139-test suite was green at the time of the audit, so none of these were caught by existing
|
||||
coverage — every fix lands with a regression test (the eight fixes so far brought the suite
|
||||
from 139 to 187).
|
||||
coverage — every fix lands with a regression test (the nine fixes so far brought the suite
|
||||
from 139 to 192).
|
||||
|
||||
The recurring pattern across the open findings is worth stating once: the code is rigorous
|
||||
about the failure modes that have actually been hit, and silent about the ones that have not.
|
||||
@@ -20,22 +20,6 @@ single-process assumptions, no user-facing history, etc.), see "Known gaps / TOD
|
||||
|
||||
## High
|
||||
|
||||
### B-33 — No brute-force protection on a custodial wallet
|
||||
|
||||
`POST /auth/login` (`auth/routes.py:83`) has no rate limiting, no lockout, no delay and no
|
||||
CAPTCHA, and the password minimum is 8 characters. Argon2 slows a single attempt but not a
|
||||
patient distributed attack against an enumerable username list — and `409 username_taken` on
|
||||
registration is a perfect enumeration oracle.
|
||||
|
||||
"No rate limiting" is listed as a generic known gap; on a system where guessing a password
|
||||
means **withdrawing someone's funds**, it deserves to be tracked separately and treated as a
|
||||
blocker.
|
||||
|
||||
**Proposed fix.** Per-username *and* per-IP throttling with exponential backoff on failed
|
||||
logins (`slowapi`, or a small DB-backed counter — but note the in-process caveat if workers
|
||||
are ever scaled). Return an identical response for unknown-user and wrong-password. Rate-limit
|
||||
registration too, which also bounds B-31's attacker-controlled user count.
|
||||
|
||||
### B-34 — Password change and admin reset do not invalidate existing sessions
|
||||
|
||||
Neither `/users/me/change-password` nor `/admin/users/{id}/reset-password` invalidates
|
||||
@@ -227,9 +211,10 @@ already does.
|
||||
- **B-30** — a lost scripthash subscription meant a user's deposits were never credited, with no periodic safety net
|
||||
- **B-31** — resubscribing on reconnect ran serially before anything else started, freezing the chain tip (and so an in-flight draw) for the whole sweep
|
||||
- **B-32** — an RBF bump's fee delta could fall below BIP125's relay-mandated minimum, so the node rejected it and the same tick retried identically forever; also had no ceiling on how high the fee rate could climb
|
||||
- **B-33** — `POST /auth/login` had no rate limiting on a custodial wallet, so a patient distributed attack could brute-force a password against an enumerable username list; fixed with per-username *and* per-IP exponential backoff (`app/auth/rate_limit.py`), registration throttled per-IP too (also bounds B-31's attacker-controlled user count)
|
||||
|
||||
See git history for the fix-by-fix breakdown (commits `f13f685`, `50a43ae`, `933760e`, and the
|
||||
B-28/B-29/B-30/B-31/B-32 fixes). Suite grew from 139 to 187 tests over the eight.
|
||||
B-28/B-29/B-30/B-31/B-32/B-33 fixes). Suite grew from 139 to 192 tests over the nine.
|
||||
|
||||
A full-codebase audit on 2026-07-26 (commit `d4e0974`) found 24 bugs across every Python
|
||||
module under `app/`, both static frontends, and the Docker/Caddy deployment — 5 critical,
|
||||
|
||||
Reference in new issue
Block a user