-
-
Notifications
You must be signed in to change notification settings - Fork 63
Bug: City API can pass NaN pagination values to Supabase #372
Copy link
Copy link
Open
Labels
Gssoc 26Part of GirlScript Summer of Code 2026Part of GirlScript Summer of Code 2026backendBackend/API relatedBackend/API relatedgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved GSSoC contributionApproved GSSoC contributionlevel:beginnerBeginner difficulty levelBeginner difficulty leveltype:bugSomething isn't working as expectedSomething isn't working as expected
Metadata
Metadata
Assignees
Labels
Gssoc 26Part of GirlScript Summer of Code 2026Part of GirlScript Summer of Code 2026backendBackend/API relatedBackend/API relatedgood first issueGood for newcomersGood for newcomersgssoc:approvedApproved GSSoC contributionApproved GSSoC contributionlevel:beginnerBeginner difficulty levelBeginner difficulty leveltype:bugSomething isn't working as expectedSomething isn't working as expected
Describe the bug
GET /api/citydoes not guard against non-numericfromortoquery parameters. Invalid values can becomeNaNand then flow into the Supabase range call.Source proof
In
src/app/api/city/route.ts:fromis calculated asMath.max(0, parseInt(searchParams.get("from") ?? "0", 10)).tois calculated withMath.min(from + 1000, parseInt(searchParams.get("to") ?? "500", 10)).from=abc,parseInt("abc", 10)isNaN, andMath.max(0, NaN)is alsoNaN..range(from, to - 1)with invalid numeric values.A malformed request like
/api/city?from=abc&to=500should not be able to pushNaNinto the database query layer.Expected behavior
Invalid pagination values should either default to safe bounds or return a 400 response before building the Supabase query.
Why this does not need screenshots
The bug is fully reproducible from the query parsing and range call in the API route.