Skip to content

[Audit] Unbounded findMany queries with no pagination on hot paths #1246

Description

@K1NGD4VID

Filed from the second-wave repository audit (issue 44/100). See the audit summary for full category context.

  • Location: backend/src/controllers/stream.controller.ts:592-626 (getUserStreamSummary), backend/src/controllers/sse.controller.ts:51-54 (subscribe)
  • Problem: Both fetch all of a wallet's streams via findMany with no take/limit — getUserStreamSummary then runs an unbounded per-stream claimable-amount computation loop on every cache-miss, and subscribe re-runs the same unbounded query on every SSE (re)connection, which happens frequently on network blips.
  • Evidence: Neither findMany call includes take/cursor pagination.
  • Suggested implementation: Add a reasonable take cap (with a documented "power user" pagination path if needed) to both queries.
  • Acceptance criteria: Both endpoints/handlers cap the number of streams fetched per call, verified by a test with a wallet owning more than the cap.
  • Difficulty: S
  • Expected impact: Bounds per-request cost for high-volume wallets, protecting both request latency and DB load.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksenhancementNew feature or requestsecond-wave-auditFiled from the second-wave repo audit (100 issues)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions