Limit failed authentication on Cloud's CLI API per client address #3142
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.71) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 502 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.372
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #3142"
general
weight: 0.35
nick-potts
Fixes #2942.
Summary
Failed authentication on Cloud's
ployzAPI (/api/cli/and/api/config/) is now limited per client address: 20 a minute and 100 an hour. A held address gets429 RATE_LIMITEDwithRetry-After, whatever credential it presents, so a guess can't land while the address waits.acquireUseReleasereleases the place even when the request is interrupted while it commits.observedIphonours the configured client IP headers and walksX-Forwarded-Forfrom the right, but only from private or local peers. IPv6 groups by /64.RATE_LIMITEDasUnavailable(cloud_account.rs), so it prints the wait instead of an unknown error.admitWithinWindowsnow counts all windows in one query, returns the reservation id, and treats its occasional prune of stale rows as best-effort. Agent signup, its other caller, keeps its behaviour, except that a failed prune no longer fails a signup.Evidence
failed-authentication.postgres.test.ts: 6 tests, all passing:Retry-After, even with a valid token. Successes never count.serveCli), withRetry-Afterset.COMMITby a deferred trigger leaves no row. Before the fix it left 1.Agent signup tests (18) pass.
pnpm typecheckpasses. The core testa_cloud_rate_limit_reads_as_unavailablepasses.Review: R1 Codex+Opus, then 6 findings fixed. R2 Codex found one BUG (a stranded reservation), which is now fixed. R3 Codex on that fix found no BUG.
Ops
429 RATE_LIMITEDwithRetry-Afteron CLI API calls for up to an hour, including calls with a valid token.X-Forwarded-For(or the configured client IP header), every client shares the proxy's address, so one token guesser can lock out everyployzuser. Caddy andcloudflaredset it.docs/user/self-hosting.mdsays so.rate_limit_eventtable, with no schema change.Out of scope: the enroll, check-in and MCP bearers, and grouping IPv6 by /48.
Bets
None of the Engine bets in
core/DESIGN.mdchange. The core change maps one more Cloud error code. Stable promise: additive.RATE_LIMITEDis a new public error code with a newRetry-Afterheader. No RPC, schema or stored-format change.Merge Danger
Door: two-way. Reverting removes the limit. Leftover
failed-auth:rows age out with the 24 h retention.Blast Radius: CLI auth. If the client address is misconfigured behind a proxy, a guesser can cause a shared lockout. The Ops notes above cover it.