fix: escape user input before interpolating into PostgREST filters - #18
Merged
Merged
Conversation
search_tickets (GET /tickets/search) and filter_tickets (GET /tickets/filter) interpolated user-supplied values (q, status, priority, assigned_user_id) directly into PostgREST filter strings. Comma and parentheses are structural in PostgREST or() syntax and nothing encoded & or =, so a value such as "x),status.eq.Closed&limit=1" could close the or() group, append extra conditions, and inject additional query parameters. Add database.escape_filter_value, which backslash-escapes PostgREST's reserved characters (\ , ( )) and then percent-encodes the result with safe="", and route every interpolated value through it. The surrounding template (wildcards, operators, &order=) is left untouched. Tests cover plain-text passthrough, that reserved characters never survive unescaped, the exact escape-then-encode output, and end-to-end injection attempts against both endpoints. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6wR9fK3YEMMKDwEAwr5Ju
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
sonnymay
commented
Sep 10, 2026
sonnymay
left a comment
Owner
Author
There was a problem hiding this comment.
Implementation review: PASS after 1993164. The full logical ilike operand is now quoted per PostgREST grammar, embedded backslashes and quotes are escaped, query delimiters are percent-encoded, template structure remains trusted, and all required checks pass.
sonnymay
marked this pull request as ready for review
September 10, 2026 18:04
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /tickets/searchandGET /tickets/filterinterpolated rawq,status,priority, andassigned_user_idinto PostgREST filter strings. Commas and parentheses are structural inor()expressions, while&and=delimit query parameters.database.escape_filter_value. Ordinary values are percent-encoded; search patterns are wrapped in PostgREST double quotes with embedded backslashes and quotes escaped, so logical delimiters remain data.&order=untouched.Testing
pytest -q— 37 passedruff check .,ruff format --check .,mypy ..,pre-commit run --all-files— all cleanNotes
### Fixedentry under[Unreleased].🤖 Generated with Claude Code