Sort Column Allowlist
Medium About 20 min Katabench Pro
Build an ORDER BY clause from a user-chosen column without opening a SQL injection hole.
The full brief is part of Katabench Pro
Pro opens this kata's brief, its starter code and its grader. To see how the track works first, try Filename Sanitizer, which is free.
How it is graded
Functional tests and adversarial payloads both have to pass before the solution is accepted.
What it practices
- SQL injection
- Keep untrusted input out of SQL grammar with parameters, quoting and allowlisted identifiers.
- Allowlist validation
- Accept only known-good values, fields and types instead of chasing bad ones.
Related katas
- Filename Sanitizer Easy Free Reduce an uploaded filename to a safe, single path segment.
- Mass Assignment Guard Easy Free Decide which submitted fields may be applied to a record using an allowlist, not a blocklist.
- CORS Origin Reflection Medium Pro Decide the Access-Control-Allow-Origin value by exact allowlist, not a suffix match an attacker can satisfy.
- Quote SQL Identifier Medium Pro Quote a dynamic SQL identifier so an embedded quote cannot break out of it.