docs(opds): clarify accepted bcrypt-amplification baseline (bookshelf-2dcn3) #1400
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-2dcn3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #1195 (6tq2k.1). Two review MINORs:
opdsClientIPduplicatinginternal/usersclientIP— verified already resolved by bookshelf-9snmz.3.2 (commit21f133f99), which extracted the sharedaudit.ExtractIPWithPolicyhelper now used by both packages. No code change needed here.authenticate()ininternal/opds/handler.godocumenting this as a reviewed, accepted baseline (bounded at burst, requires valid auth, matches /login's reserve/refund pattern) so future reviewers don't re-flag it.Docs: N/A — internal code-comment clarification only, no user-facing behavior change.
Test plan:
go build ./...andgo vet ./internal/opds/...pass.go test ./internal/opds/...passes (comment-only change, no behavior/coverage impact).Closes bead bookshelf-2dcn3 on merge.
Security review — PR #1400 (bd-bookshelf-2dcn3)
Diff is doc-comment-only (8 lines added to
internal/opds/handler.go, no code changes). Verified the claim the new comment makes against the actual wiring, not just trusting the prose.Verification performed:
authenticate()(internal/opds/handler.go:489-546): confirmed the reserve-then-refund sequence is real —loginReserve(ip)is called beforeverifyCredentials(the bcrypt call), refund only fires on success (line 541-543), and on failure the token stays consumed. This matches the comment's description exactly.LoginReserveis wired ininternal/app/app.go:478tologinLimiter.ReserveToken, the same*users.LoginRateLimiterinstance used by the standard/loginpath (LoginAllow: loginLimiter.Allowon the adjacent line) — confirms "same baseline as /login" is literally true, not just similar.internal/users/ratelimiter.go: burst = 10 (loginRateLimiterBurst), sustained rate 10/min, per-IPrate.Limiter.ReserveTokenusesReserveN+CancelAt, correctly bounding concurrent in-flight reservations to burst size before any refund can occur — so "up to ~burst concurrent bcrypt verifications per IP" is an accurate upper bound, not an understatement.opdsClientIP()(handler.go:648-657) mirrorsusers.clientIP(): uses onlyr.RemoteAddr, never trustsX-Forwarded-For, so the per-IP bucket keying can't be trivially bypassed by a spoofed header — consistent with the documented baseline being enforced per real IP, not attacker-controlled.No BLOCKER/MAJOR/MINOR findings — the comment's claims are accurate and the underlying rate-limit behavior is unchanged (doc-only diff).
REVIEW VERDICT: 0 blocker, 0 major, 0 minor
Diff-review of PR #1400 (bd-bookshelf-2dcn3) — comment-only follow-up to bookshelf-6tq2k.1.
Phase 1 — spec compliance
MINOR #2 claim verified:
opdsClientIPno longer exists anywhere onorigin/mainas a function;internal/opds/handler.go:559already calls the sharedaudit.ExtractIPWithPolicy(r, false), same helperinternal/users/*uses (device_handler.go,handler.go,oidc_handler.go). Only remaining references to the old name are inhandler_test.gocomments (stale text, not code) — no action needed there, consistent with the bead's claim that bookshelf-9snmz.3.2 already consolidated this.MINOR #1 (bcrypt-amplification doc comment): added, matches the bead ask — an 8-line addition to the
authenticate()doc comment, no behavior change. Confirmed genuinely comment-only viagit diff origin/main...origin/bd-bookshelf-2dcn3(single hunk, all+lines, no code).Phase 2 — accuracy of the new comment
[MINOR] internal/opds/handler.go:527-533 — "matches the same reserve/refund baseline used by the standard /login rate limiter" is imprecise.
Checked
internal/app/app.go:378-389on main:LoginReserve: loginLimiter.ReserveToken(OPDS, reserve-then-refund) vsLoginAllow: loginLimiter.Allow(web/login, consume-before-bcrypt with no refund — see the adjacent app.go comment: "LoginAllow is the consuming check used by the web /login handler (consume before bcrypt, no refund)"). Both share the same limiter instance and both cap concurrent bcrypt calls at burst size (which is the actual point being defended), but /login does not "refund" — so calling it the "same reserve/refund baseline" slightly mischaracterizes /login's mechanism to a future reader. Suggest: "matches the same pre-bcrypt consume-before-verify baseline used by the standard /login rate limiter (which consumes but does not refund)." Non-blocking — doc-only, doesn't change any assessment of risk.No other findings. Change is exactly what the bead describes: comment-only, no logic/behavior touched.
REVIEW VERDICT: 0 blocker, 0 major, 1 minor