← Back to Pull requests

fix: count an IPv6 client by its /64 in the per-IP rate limiters #819

Closed
unknown closed this pull request without merging on Dec 01, 2026 05:12 UTC
View on GitHub
unknown unknown commented on Dec 01, 2026 02:05 UTC
Author

The login, refresh and rider registration limiters count attempts per address and fail closed once they track 10,000 addresses, so an auth endpoint never goes unlimited under memory pressure; their comments say that is meant to stop one client filling the map. An IPv6 client holds a whole /64, though, and counted as that many clients. POST /api/v1/auth/refresh needs no account and costs one indexed lookup, so under a hundred junk refreshes a second, each from another address of one /64, keep the refresh limiter full. Every address not already counted then gets a 429 on sign-in and on refresh, phones let their access tokens run out, and their reports stop being accepted for as long as it goes on.

The three limiters now count an IPv6 address by its /64, the block a phone on a mobile network or a single server is given, so one client is one key however many of its addresses it uses. An IPv4 address counts by itself as before, and so does one written as IPv6 (::ffff:203.0.113.7). The audit log, the failed sign-in notes and the logs keep the whole address. A depot's IPv6 network shares one budget, as its drivers share one public IPv4 address behind NAT today, and a success still hands its attempt back. docs/deployment.md says so next to the paragraph on which address the limiters count.

This raises the cost from one /64 to a /48: someone routing 10,000 different /64s could still fill a limiter. Going further means evicting at capacity rather than refusing, which the limiters chose against on purpose, so I left that alone.

Tests: the key for IPv4, IPv4 written as IPv6, IPv6 in two blocks, a zone and junk; 10,000 addresses of one /64 leave room in the login and refresh limiters for a new address; addresses of one /64 share one login budget and a success from one refunds it; registering from 100 addresses of one /64 gets one address's budget. All of them fail on main. The suite passes with the database tests, and the limiter tests pass with -race.

Diff: 247 lines (+185 / -62) across 3 files Reviewer: aaronbrethorst Review duration: 187m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 247 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.330
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #819"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.9% (MEDIUM) · Higher = larger blast radius
38.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.8% · Safe to merge
16.8%