Skip to content

chore(detectors): Prevent Query Injection detector from running on SQL queries #96690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roggenkemper
Copy link
Member

fixes an edge case where some oddly formed SQL requests were getting picked up by the query injection detector (not the sql injection one)

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 29, 2025
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...mance_issues/detectors/query_injection_detector.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #96690       +/-   ##
===========================================
+ Coverage   66.12%   80.14%   +14.01%     
===========================================
  Files        8465     8483       +18     
  Lines      372806   379892     +7086     
  Branches    24205    24205               
===========================================
+ Hits       246521   304452    +57931     
+ Misses     125912    75067    -50845     
  Partials      373      373               

@roggenkemper roggenkemper marked this pull request as ready for review July 29, 2025 23:22
@roggenkemper roggenkemper requested review from a team as code owners July 29, 2025 23:22

sql_keywords = ("SELECT", "UPDATE", "INSERT")
if any(description.upper().startswith(keyword) for keyword in sql_keywords):
return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SQL Exclusion Flaws: DELETE Missing, Whitespace Ignored

The sql_keywords tuple, intended to exclude common SQL queries from query injection detection, is missing "DELETE", a fundamental DML operation. This omission means "DELETE" queries are not excluded, leading to inconsistent behavior. Additionally, the keyword check does not account for leading whitespace in the span description, allowing queries like " SELECT * FROM users" to bypass the exclusion filter and still be processed by the detector, defeating its purpose of preventing false positives for common SQL operations.

Locations (1)
Fix in Cursor Fix in Web

Copy link
Member

@JoshFerge JoshFerge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth adding a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants