Backend: assets list endpoint has no LIMIT cap — ?limit=999999999 OOMs the API #119

Closed
opened 2026-05-26 18:21:13 -04:00 by zgaetano · 1 comment
Owner

Fixed in 04ce096. GET /api/v1/assets clamps limit to MAX_LIMIT = 500 and sanitises both limit / offset to integers, defaulting to 50 / 0 on bogus input.

Fixed in 04ce096. `GET /api/v1/assets` clamps `limit` to `MAX_LIMIT = 500` and sanitises both `limit` / `offset` to integers, defaulting to 50 / 0 on bogus input.
Author
Owner

Fix Plan — #119 Assets list endpoint has no LIMIT cap

Root cause: assets.js:92-93 passes req.query.limit directly into SQL LIMIT without max cap. ?limit=999999999 → PG allocates gigantic result set → OOM.

Fix — clamp on all list endpoints:

// before:
const limit = parseInt(req.query.limit, 10) || 50;

// after:
const limit = Math.min(parseInt(req.query.limit, 10) || 50, 200);

Apply to: assets.js, recorders.js, projects.js, bins.js, schedules.js, groups.js, users.js — every endpoint accepting ?limit.

Files: All route files with list endpoints
Effort: ~30min
**Priority: P2 — DoS vector

## Fix Plan — #119 Assets list endpoint has no LIMIT cap **Root cause:** `assets.js:92-93` passes `req.query.limit` directly into SQL `LIMIT` without max cap. `?limit=999999999` → PG allocates gigantic result set → OOM. **Fix — clamp on all list endpoints:** ```js // before: const limit = parseInt(req.query.limit, 10) || 50; // after: const limit = Math.min(parseInt(req.query.limit, 10) || 50, 200); ``` Apply to: `assets.js`, `recorders.js`, `projects.js`, `bins.js`, `schedules.js`, `groups.js`, `users.js` — every endpoint accepting `?limit`. **Files:** All route files with list endpoints **Effort:** ~30min **Priority: P2 — DoS vector
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: WildDragonLLC/dragonflight#119
No description provided.