SQL built with % / .format() / + in execute() (Python)
Part of Security, which counts for 30% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.
What it detects
A cursor execute() call builds its SQL string with %-formatting, .format(), or concatenation instead of passing parameters as the second argument.
Why it matters
Building the SQL inside execute() with %-formatting, .format(), or + puts the value into the query text instead of binding it, which is a SQL injection risk. The DB-API second argument exists exactly to avoid this. It is a heuristic because it cannot confirm the formatted value is user-controlled.
How to fix it
Move the values out of the string and into the execute() parameters: cursor.execute("... WHERE name = %s", (name,)). Never use %, .format(), or + to assemble a query. For an IN clause, generate the right number of placeholders and pass a tuple.
The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing
Does your repo trip this check?
Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.
Scan your repo