Repository navigation
docs(audits): triage the CodeQL js/missing-rate-limiting backlog (TASK-097) - #1832
Conversation
|
Recut at What changed
The other five ( The 429-body gap, written down with its reason. The existing limiter bodies in One thing I would put in front of the (A) budget before it is set: the fleet's seats run on one host under the launchd supervisor, so they share a single egress IP — an IP-tier-only bucket is a fleet-aggregate bucket, not a per-seat one. 3000/60s is 50/s against ~30 seats reconnecting long-polls on the order of once per 30s, so the headroom is large; but that is headroom, not the per-token measurement (A) is gated on. TASK-108 filed for (B) with the route list and a budget each. Structure re-run on |
|
Head moved 1. The probes ruling ( 2. The instrument's recorded shape ( |
…K-097) Reconciles the two disagreeing counts and separates the defect from its instances, then frames the enforcement choice for Wren + Sam. Measured at 58232e6: - 349 open alerts = 200 distinct sites in 33 files (3 of them test-file apps). The ref=refs/heads/main filter is a no-op: filtered and repo-wide both return 349, because every alert's most-recent instance is already on main. - 322 of the 349 were created in 2026-04 (3 in September) — a five-month-old backlog that re-attributes to any PR touching a shared dataflow node, which is why none of it may be dismissed per-PR. - They are TRUE POSITIVES, not indirection: walking from each flagged line back to its enclosing registration shows 0 of 200 sites carry a limiter anywhere in the chain, while the 7 phase4RateLimit routes in agentsRuntime.ts are absent from the alert set entirely. The query recognises our inline limiter shape. - The repo already owns a burn-down list for this surface: the route rate-limit guard's baseline, 232 registrations (204 limited, 0 fresh violations). - Exemption candidates are narrow and named: 3 test-file apps, 6 health/status reads, 3 third-party-triggered callbacks, 2 long-poll reads. The enforcement choice is not mine to take — a limiter on the agent-runtime family changes behaviour for every seat — so the doc ends with four options and a recommendation, plus the one count I could not reproduce (Vera's 78). Docs-only: no version slot.
…097 triage
Recut per wren 71373/71374:
- Status is no longer "open": (D) was ruled, and the split is the point — (B)
per-route on the public/anon surface is now a builder's row under this task,
(A) mount-level on /api/agents/runtime is Sam's own order, gated on the
per-token steady state being measured against the existing 120/60s and on a
runtime 429 reading as a NAMED refusal in one seat's tool path.
- Callbacks and long-polls are NOT exemptions: they carry the IP tier with the
token tier off, because a retry storm from a third party is still an IP.
Registering phase4IpRateLimit alone is exactly that shape.
- Scope of (B), measured: public/anon means no auth/token/member/scope
middleware in the registration chain with string literals stripped, so a path
like /invite/:token cannot masquerade as a guard. 9 of 200 sites qualify, one
of them a test-file app, so 8 production sites, all GET — and only 3 of those
are actionable (the OAuth redirect target, /registration-policy,
/verify-email); five are liveness/meta and stay exemption candidates.
- The 429-body requirement is written down with its gap: the existing bodies in
agentsRuntime.ts are {message, code} with no status and no named reason, so
the current shape is not enough for #1823's reader, and the name has to
separate a PLATFORM 429 from an UPSTREAM one, which is a different fact.
- Flagged for the (A) budget: the fleet's seats share one egress IP (one host,
launchd supervisor), so an IP-tier-only bucket is a FLEET-Aggregate bucket,
not a per-seat one. 3000/60s is 50/s against ~30 seats reconnecting long-polls
on the order of once per 30s, but that is headroom, not the measurement (A)
needs.
- The 78 is reconciled and it was a page, not a population: vera's query was the
alerts call without --paginate — the first 100 open alerts of all rules, 78 of
which happened to be this one; with --paginate it is 349. Her "38 in one file"
comes from the same page and is unmeasured.
Docs-only: no version slot.
Per wren 71383/71384/71385: - §7 closes with both figures re-run today and the explicit statement that nothing about the list narrows: 349 records, 200 sites, 33 files, and the 232-registration burn-down baseline all stand. - §6 gains the two constraints (A) inherits. The store is in-memory and the backend runs replicaCount: 1 today, so the existing 120/60s budget is coherent only because there is one replica — at >1 it multiplies per replica unless the store is shared, and nothing in the config says so. And the derived floor of 12 requests/min per seat (daemon intervalMs default 5000, agent.js:850, before claims/renewals/heartbeats/tool calls) is labelled derived from source, which is why (A) waits on the sampled req.rateLimit.used instrument rather than on the derivation. Docs-only: no version slot.
… scope (TASK-097) Four changes, three of them other people's findings landing in the doc: - §6 gains the trusted-proxy precondition (0) verbatim (vera 71399, TASK-110). Both tiers assume an IP key the caller cannot choose, and cf-connecting-ip is caller-supplied, so every "per IP" figure in the doc reads as "per key the caller may be able to choose" until that row lands. - The three per-route budgets are labelled threat-model numbers (vera 71390): the ingress access log holds 5,417 requests over 24h with zero hits on /verify-email and /registration-policy, so nothing exists to confirm or contradict them. They stay. - §6 records that nothing persists a per-token rate today (vera 71378) and that the counter instrument's shape is vera's scope while the build is Kai's under TASK-109, including her quoted scope: a watermark log registered immediately after phase4RateLimit, reading req.rateLimit, emitting only at used >= RATE_LIMIT_OBSERVE_WATERMARK (default 60). - §7 credits the 78's reconciliation to vera (71371, restated 71385) rather than leaving it unattributed. Docs-only: no version slot.
…al (TASK-097 §6) The §6 entry for the instrument (built as TASK-109) now records what it actually emits and what it deliberately does not: - the line: key shortened to prefix + first 12 chars, route taken from `req.route.path` (pattern only, never `req.originalUrl`), `used`, `resetInSeconds`, `replica`; `limit` and `remaining` dropped because one restates the constant 120 and the other is arithmetic on the rest; - that it measures the TOKEN tier alone, because it is mounted last and last wins in a stack, with the IP tier explicitly not observed (vera 71402, recorded rather than implied per wren 71410); - that every count is per backend replica, the store being in-memory and per-process (vera 71406); - that it is a lower bound by construction — the limiter answers the request that crosses the ceiling, so the observer never runs for it; - that the row names its own removal (vera 71402).
…r (§5, §6) wren 71392, carried as the outstanding fold on this PR (71409/71422). The rule, stated so the next probe is decided rather than re-litigated: a probe qualifies for exemption on "does an anonymous hit do database work". health.ts (x2), pg-status.ts (x2) and docs.ts (a file read) stay exempt — a limiter on a liveness probe can be the outage. GET /stats/public runs three `countDocuments` per hit with no cache, so it does not qualify and takes the IP tier at 600/60s, beside the OAuth callback. §5's class row no longer calls the whole class an exemption candidate, and §6 lists GET /public with its budget instead of as a candidate, which moves (B)'s actionable surface from 3 routes to 4.
d47ed3f to
5bb891a
Compare
Triage for TASK-097 — docs-only, one file:
docs/audits/codeql-missing-rate-limiting-triage.md.The row asked for two things: reconcile the disagreeing counts, then say which routes need a limiter and which get a documented exemption. This measures the first and frames the second; it does not touch a route.
Measurement (at
58232e6a)js/missing-rate-limiting,ref=refs/heads/main(path, start_line)sitesThe finding that matters: these are true positives, not indirection. Walking from each flagged line back to its enclosing registration (
runtimeRouter/templatesRouterincluded) shows 0 of the 200 sites carry a limiter anywhere in the chain — while the 7phase4RateLimitroutes inagentsRuntime.tsare absent from the alert set entirely. So CodeQL does recognise our inline limiter shape, and the alert set is the burn-down list the repo already keeps, not a false-positive cloud. 349 is an instance count; the defect count is ~232 registrations, 197 of which the query also sees.Instrument note, because a first pass was wrong: testing only the flagged line reported two
auth.tssites as limited and missed every registration under a non-routervariable name. Its two hits were the next route's limiter, one line below. The chain walk is the measurement above.Not mine to decide (Wren + Sam): a limiter on the agent-runtime family changes behaviour for every seat. The doc names four options with the existing budget (IP 3000/60s, token 120/60s), the blast radius, and the parameter the decision needs — the fleet's real per-token steady-state — and recommends per-route on the public surface first, then the mount-level stack once that rate is measured.
One count I could not reproduce: the row's "Vera counted 78 repo-wide". None of my shapes produce it; §7 asks for the query rather than guessing, because the answer decides whether the list is 232 or narrower.
No version slot: docs-only.