Skip to content

[HIGH] — GET /campaigns cache key omits page, limit and sortBy, serving identical payloads for vastly different requests #5

@Alqku

Description

@Alqku

Severity: High
Type: Bug
Scope: Campaigns
Labels: bug, Official Campaign

Description

CampaignsController.browseCampaigns (src/campaigns/campaigns.controller.ts, lines ~85–101) determines its cache key via generateCacheKey(query) which only concatenates category, status, and search (lines ~177–187). page, limit, and sortBy are ignored.

Consequences:

  • Two clients requesting page 1 and page 2 of the same filter receive the same first page, with subsequent pages perpetually empty or duplicated.
  • Different sortBy values (mostFunded, endingSoon, newest) collide in the cache, and whichever request writes last wins for the TTL window.
  • Users browsing pagination or experimenting with sort orders repeatedly hammer the database instead of being served from cache; conversely they read stale results.

Recommendation

  • Include every filter, pagination, and sort token in the key — e.g. campaigns:c=foo:s=ACTIVE:q=text:p=2:l=20:sort=mostFunded.
  • Hash the key when the input is unbounded (search string can be 200+ chars) so Redis does not store huge keys.
  • Add an integration test that asserts different page/sortBy values produce distinct cached entries.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignAudit finding under the Official CampaignbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions