High severityGoInjectionHIGH confidence
SQL Injection String Build
SQL statement is assembled with fmt.Sprintf or string concatenation and passed to database/sql, enabling SQL injection (CWE-89).
Standards mapping
- OWASP Top 10
- A03:2021 - Injection
- OWASP ASVS
- V5.3.4 (L1)
Vulnerable vs. safe
Flagged by this check
_, _ = db.Query(fmt.Sprintf("SELECT * FROM users WHERE id = %s", id))Passes - the safe pattern
_, _ = db.Query("SELECT * FROM users WHERE id = ?", id)Why it matters & how to fix it
SQL statement is assembled with fmt.Sprintf or string concatenation and passed to database/sql, enabling SQL injection (CWE-89). Use parameterized queries: keep the SQL text static and pass values as placeholder arguments (`?` for MySQL/SQLite, `$1` for lib/pq) — e.g. db.Query("SELECT * FROM users WHERE id = ?", id). Never interpolate input into the query string.
References
Rule ID integsec-go-sql-injection-string-build - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - InjectionCode Injection Tainted Input
- JavaScript / TypeScript - InjectionEval Dynamic Argument
- JavaScript / TypeScript - InjectionNoSQL Query From Request
- JavaScript / TypeScript - InjectionNoSQL Where Operator
- JavaScript / TypeScript - InjectionOS Command Injection Tainted Input
- JavaScript / TypeScript - InjectionSQL Injection String Concatenation