Conversation
…ai.py _fetch_ticket and _fetch_notes built PostgREST filter strings from the request-supplied ticket_id (POST /ai/suggest) without escaping it, the same filter-injection class fixed for main.py's routes in #18/#19. A crafted ticket_id could append extra filter conditions or query parameters to the Supabase request. Reuse escape_filter_value from database.py, matching the pattern already used elsewhere, and add regression tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016pnWcimqFhFgSa4vb1LRet
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI lint check flagged an un-sorted/un-formatted import block; ruff --fix resolves it (removes an extra blank line ruff's isort integration doesn't expect between the import block and the following comment). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016pnWcimqFhFgSa4vb1LRet
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
ai._fetch_ticketandai._fetch_notesbuilt PostgREST filter strings from the request-suppliedticket_id(viaPOST /ai/suggest) without escaping it — the same filter-injection class already fixed formain.py's routes in fix: escape user input before interpolating into PostgREST filters #18 and fix: escape id path parameter before interpolating into PostgREST filters #19, but missed inai.py.ticket_id(e.g. containing&status=eq.Closed) could append extra filter conditions or query parameters to the Supabase REST request.escape_filter_valuefromdatabase.py, the same helper already used everywhere else in the codebase for this purpose.Test plan
backend/test_ai.pywith regression tests asserting_fetch_ticketand_fetch_notesescape a craftedticket_idcontaining&status=eq.Closed, plus a not-found case.python -m pytest -q— 45 passed, 3 new tests pass; 1 pre-existing unrelated failure (test_get_headers_uses_supabase_key) confirmed present on the base branch before this change, unaffected by this diff.🤖 Generated with Claude Code
https://claude.ai/code/session_016pnWcimqFhFgSa4vb1LRet
Generated by Claude Code