Conversation
…ai.py
_fetch_ticket and _fetch_notes built PostgREST filter strings with raw
f-string interpolation ("id=eq.{ticket_id}", "ticket_id=eq.{ticket_id}"),
reachable from POST /ai/suggest via AISuggestRequest.ticket_id. This is
the same injection class already fixed in main.py/database.py (comma,
parentheses, and query-string delimiters are structural in PostgREST and
were never escaped), just missed in ai.py.
Route both values through database.escape_filter_value, already used by
the other id-based lookups. Add test_ai.py covering that a crafted
ticket_id is escaped rather than passed through.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JBr5TgDKjyVGFYCtdKAEJn
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
_fetch_ticketand_fetch_notesinbackend/ai.pybuilt PostgREST filter strings with raw f-string interpolation (id=eq.{ticket_id},ticket_id=eq.{ticket_id}), reachable fromPOST /ai/suggestviaAISuggestRequest.ticket_id.{id}-based ticket routes anddb_patch/db_deletein fix: escape user input before interpolating into PostgREST filters #18/fix: escape id path parameter before interpolating into PostgREST filters #19 —ai.pywas missed.database.escape_filter_valuehelper.Test plan
backend/test_ai.pycovering that a craftedticket_id(with&,),,) is percent-encoded before reachingdb_get, for both_fetch_ticketand_fetch_notes.python -m pytest(46 passed)python -m ruff check ./ruff format --check .cleanNote for maintainer
This repo already has several open draft PRs (#20–#26) proposing the identical fix for this same file, none merged. Recommend merging this one (or the earliest of that batch) and closing the rest as duplicates.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JBr5TgDKjyVGFYCtdKAEJn
Generated by Claude Code