GeezerVison is showing github.com — projector: read-API limit is never validated — ?limit=-1 returns the whole table and ?limit=2.7 500s the request · Issue #1547 · developing-today/code
projector: read-API limit is never validated — ?limit=-1 returns the whole table and ?limit=2.7 500s the request #1547DescriptionSummary
The projector's read API passes the limit query parameter to SQL LIMIT ? with no validation or clamp anywhere in the chain. ?limit=-1 (any negative) returns the entire table — SQLite treats a negative LIMIT as "no limit" — ?limit=1000000000 does the same in practice, ?limit=2.7 makes the driver throw a datatype-mismatch error (unhandled in the handler, so the request 500s), and ?limit=abc sends NaN to the driver. The defaults (200 / 500) only apply when the parameter is absent.
Evidence (verified this run on main a120b9a9)
pm-stack/projector/src/server.ts:119 — /items: limit: Number(url.searchParams.get("limit") ?? 200). Number("-1") is -1, Number("abc") is NaN, Number("2.7") is 2.7; nothing checks the result.
pm-stack/projector/src/server.ts:128 — /comments: same pattern with default 500, feeding both getCommentsForSubject and getComments.
pm-stack/projector/src/store.ts:188-191 — listItems: const limit = opts.limit ?? 200 — ?? only catches null/undefined, so -1, NaN and 2.7 all pass through into LIMIT ?. Same shape at store.ts:267 (getComments) and store.ts:283 (getCommentsForSubject).
- SQLite semantics verified directly (python
sqlite3, same SQLite core the libsql driver binds): LIMIT ? bound to -1 or -5 returned all 10 test rows; bound to 2.7 raised datatype mismatch; bound to 0 returned 0 rows.
- The
/items and /comments handlers (server.ts:110-141) have no try/catch (unlike /health and the webhook path), so the fractional-limit driver error escapes handleRequest as an unhandled 500 instead of a 400 naming the bad parameter.
- No test covers a hostile
limit: pm-stack/projector/test/ has no limit cases (grep).
These are read endpoints (no bearer token — server.ts only gates writes/reconcile), served on the projector's port and consumed by the aggregator's live source, so any local caller can force a full-table dump of pmp_items / pmp_comments with one parameter.
Why it matters
The limit parameter exists to bound response size; as written it bounds nothing. A negative or huge limit turns a paged read into an unbounded one (memory + payload blowup as the tables grow), and a fractional limit is a one-request 500. Every other numeric/structured input on this server is validated at the boundary (webhook HMAC + bounded body, link ref regex at server.ts:159) — limit is the loose one.
Acceptance criteria
-
limit is parsed once, at the HTTP boundary (or in the store functions), as a positive integer and clamped to a named per-endpoint maximum; absent → the existing defaults (200 items / 500 comments).
-
?limit=-1, ?limit=0, ?limit=2.7, ?limit=abc and ?limit=999999999 can never produce an unbounded result or a 500: they get the default/clamp, or a 400 naming limit.
- Tests at the store or handler level pin: negative → bounded, fractional/non-numeric → bounded or 400, over-max → max, ordinary
?limit=3 still returns exactly 3.
- No behaviour change for well-formed callers (the aggregator's live reads use
refs=, not limit).
Dedup
Searched open + closed issues for projector limit and related terms: no filing covers the projector read-API limit. Adjacent but in another repo/component: openchamber #604 (loose Number parsing in pool-health route — same defect family, different codebase), code #1485/#604-style aggregator sort issues (unrelated). Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane B, slug new-issue-creator-code-b)
- Session / ID: cron job new-issue-creator-code-b, run 2026-10-27 19:57 CDT
- Found via: filed this run
- Task: Filed after verifying on main a120b9a that the projector read API passes Number(searchParams limit) straight to SQL LIMIT ? (server.ts:119,128; store.ts:188-191,267,283 — ?? default only catches null/undefined), and verifying SQLite semantics directly: a negative LIMIT bind returns all rows, a fractional bind (2.7) raises datatype mismatch, and the /items + /comments handlers have no try/catch so that error escapes as a 500. Enqueued as a triage packet to repo-health-code-pilot.
- Expectation: triage (effort s) confirms and routes the fix: parse limit as a positive integer at one layer, clamp to a named per-endpoint max, pin negative/fractional/non-numeric/over-max tests.
- Links: packet hidden_files/packet-1547.json
dezren39 commented on Oct 31, 2026 dezren39 commented on Oct 31, 2026 dezren39 commented on Oct 31, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|