Skip to content

projector: GET /items and /comments accept an uncapped refs list that bypasses the pagination limits #10595

Closed

Description

@dezren39

Problem

GET /items?refs= and GET /comments?refs= split the query param into an unbounded array and hand it straight to the store, where it becomes one SQL placeholder per ref. Both routes are unauthenticated reads, and the refs path bypasses the limit pagination cap that the same routes enforce on their list path. Additionally, the by-refs items query has no row LIMIT at all.

Evidence (origin/main ec68de7f)

pm-stack/projector/src/server.ts:292-309 — GET /items: no auth gate (first bearerAuthorized in the file is at :336 for POST /links), no count cap on refs:

if (path === "/items" && method === "GET") {
  const refsParam = url.searchParams.get("refs");
  if (refsParam) {
    const refs = refsParam
      .split(",")
      .map((s) => s.trim())
      .filter(Boolean);
    const rows = await store.getItems(db, refs);
    return jsonResponse(200, { items: rows });
  }
  ... limit: parseLimit(..., DEFAULT_ITEMS_LIMIT, MAX_ITEMS_LIMIT),

pm-stack/projector/src/server.ts:312-325 — GET /comments: same uncapped split, passed to store.getComments(db, refs, { limit }).

pm-stack/projector/src/store.ts:247-254 — getItems builds IN (?, ?, ...) with one placeholder per ref and has no LIMIT clause:

export async function getItems(db: Client, refs: string[]): Promise<ItemRow[]> {
  if (refs.length === 0) return [];
  const placeholders = refs.map(() => "?").join(",");
  const r = await db.execute({
    sql: `SELECT * FROM pmp_items WHERE ref IN (${placeholders}) ORDER BY updated_at DESC`,
    args: refs,
  });

pm-stack/projector/src/store.ts:427-441 — getComments caps returned rows via LIMIT ? but still builds an unbounded placeholder list.

The sibling read routes cap page size (MAX_ITEMS_LIMIT = MAX_COMMENTS_LIMIT = 1000, server.ts:78-81, enforced by parseLimit), so a caller paging normally can never pull more than 1000 rows — but the refs path on the same endpoints has no equivalent bound.

Why it matters

An unauthenticated caller can request an arbitrarily large ref list (hundreds of short refs fit in a normal URL) and force a giant IN query returning up to one full row per ref on /items with no row cap — response bloat and DB load on the shared projector store. At very high counts it also risks hitting the SQLite host-variable limit, which would surface through the unguarded-store-call path already tracked in #10540 as an unstructured 500.

Suggested fix shape

Activity

  1. developing-today commented on Nov 16, 2026

    @developing-today
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions