CRITICAL
Fix immediately — active exploitation likely
SQL injection in product search
Identity
#:1
Category:sqli
CWE:CWE-89
CVSS:9.1
Confidence:98%
Status:OPEN
Diff:PERSISTING
Location
URL: https://acme-store.com/search
Field: q
Snippet
GET /search?q=gift' UNION SELECT NULL,version()-- -
Proof
UNION context confirmed (7 columns); database banner extracted read-only: PostgreSQL 15.4 on x86_64-pc-linux-gnu.
Reproduce
curl -H 'Accept: text/html' 'https://acme-store.com/search?q=gift%27%20UNION%20SELECT%20NULL%2Cversion%28%29--%20-'Description
The search endpoint concatenates the q parameter directly into a SQL query, allowing an attacker to read arbitrary tables — including customer credentials and order history.
Remediation Summary
Use parameterized queries for all database access.
Detailed Fix
Replace string concatenation with bound parameters at every call site. The query builder should never see raw user input — validate and type-check q before it reaches the data layer.
Before
const rows = await db.query(`SELECT * FROM products WHERE name ILIKE '%${q}%'`);After
const rows = await db.query('SELECT * FROM products WHERE name ILIKE $1', [`%${q}%`]);References
- https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
- https://cwe.mitre.org/data/definitions/89.html
Compliance Tags
Tags: OWASP ASVS V5, PCI-DSS 6.5.1