Skip to content

chore(detectors): Add page for Query Injection Issues #14209

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 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/product/issues/issue-details/query-injection-issues/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: "Potential Query Injection Vulnerability Issues"
sidebar_order: 50
description: "Learn more about Potential Query Injection Vulnerability issues and how to diagnose and fix them."
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we capitalize Potential Query Injection Vulnerability in the product?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes - right now all of these detected issues (performance issues for example) are capitalized

---

Potential Query Injection Vulnerability issues are raised when Sentry detects values taken directly from an incoming request being incorporated into a database query. Unsanitized interpolation of user input can lead to [SQL injection](https://owasp.org/www-community/attacks/SQL_Injection) and related attacks.

## Detection Criteria

The detector evaluates each request in **two stages**:

1. **Filter request values** – Discards tokens that are:

- too short,
- SQL keywords, or
- other frequently benign values

2. **Match against queries** – Scans database queries and if **both** a payload key _and_ its value appear in the same query, Sentry creates a Potential Query Injection Vulnerability issue.

### Example

```
Request → GET /api?username=bob
Query → SELECT * FROM users WHERE username = 'bob'
```

Because the value `'bob'` is inserted directly from the `username` parameter into the query, Sentry flags the operation as potentially vulnerable. **An issue indicates a security _risk_, not a confirmation that an exploit has already occurred.**

### False Positives

Some ORMs or query‑builder libraries assemble SQL strings internally before parameterizing them. We automatically suppress many known libraries, but unrecognized ones may still trigger the detector. If you believe an issue is a false positive, leave feedback on the issue page.

## Remediation

- Use **parameterised queries / prepared statements** instead of string concatenation.
- **Validate and sanitise** all external input.
- Avoid **raw queries** when safe ORM APIs are available.