sql-injection
Skill2 starsChanged 4 months agoMITView on GitHub
SAST detection methodology for SQL injection (CWE-89), including second-order, blind boolean/time-based, ORM raw-query leaks, and JSON/JSONB-path injection. Use when reviewing code that builds or executes SQL against a relational database. Writes confirmed findings to findings/01-sql-injection.md.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- awarexone/AXguardtheir own version, first seen Sep 15, 2026
- emre-guler/websectheir own version, first seen Aug 27, 2026
- conjure-3301/skillstheir own version, first seen Aug 17, 2026
- YepAPI/skillstheir own version, first seen Apr 12, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- awarexone/AXguard★ 17same name
- YepAPI/skills★ 8same name
- emre-guler/websec★ 2same name
- conjure-3301/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- authentication-flawsSkill
- broken-access-control-idorSkill
- business-logic-flawsSkill
- cicd-and-pipeline-injectionSkill
- code-injectionSkill
- command-injectionSkill
- cors-misconfigurationSkill
- crlf-and-header-injectionSkill
- cross-site-scriptingSkill
- csrfSkill
- dependency-and-supply-chainSkill
- dom-clobbering-and-postmessageSkill
- graphql-injection-and-abuseSkill
- hardcoded-secretsSkill
- http-request-smugglingSkill
- iac-misconfigurationSkill
- information-disclosureSkill
- insecure-deserializationSkill
- insecure-randomnessSkill
- jwt-vulnerabilitiesSkill
- ldap-injectionSkill
- llm-and-ai-application-securitySkill
- mass-assignmentSkill
- memory-safetySkill
- mobile-android-securitySkill
- mobile-ios-securitySkill
- nosql-injectionSkill
- oauth-oidc-saml-flawsSkill
- open-redirectSkill
- path-traversal-and-file-inclusionSkill
- prototype-pollutionSkill
- race-conditions-and-toctouSkill
- redosSkill
- sast-final-reportSkill
- sast-finding-validationSkill
- sast-methodologySkill
- security-logging-and-monitoring-failuresSkill
- security-misconfiguration-and-headersSkill
- server-side-template-injectionSkill
- session-managementSkill
- smart-contract-securitySkill
- ssrfSkill
- unrestricted-file-uploadSkill
- unsafe-parsers-and-yamlSkill
- weak-cryptographySkill
- web-cache-poisoning-and-deceptionSkill
- websocket-securitySkill
- xpath-and-xml-injectionSkill
- xxeSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 33
All HTTP inputs (query/body/path/header/cookie), plus second-order: values previously stored in the DB, cache, or config that are re-read …
- Distinctive: line 92
Trace the operand to a source: follow the variable back. Is it request- derived (directly or second-order)?
- Distinctive: line 99
Classify blind vs error-based: if the result isn't returned to the user, it's blind (boolean/time) — still exploitable, note it.
- Distinctive: line 131
Use parameterized queries / prepared statements everywhere.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQL Injection — SAST Methodology
Class: SQL Injection · CWE-89 · OWASP: A03 Injection
Findings file: findings/01-sql-injection.md
1. Overview
SQL injection occurs when attacker-controlled data reaches a SQL execution sink
as part of the query structure rather than as a bound parameter. The core test:
is any part of the query string built by concatenation/interpolation from a
source, and does that value reach execute without parameterization?
2. Where it lives
- Raw string queries in any language (Python, PHP, Java, C#, Go, Node, Ruby).
- ORM escape hatches:
.raw(),.extra(),sequelize.query,createNativeQuery,EntityManager.createQuerywith concatenation,DB::raw,Model.where("… #{x}"). - Dynamic query builders where column/table/
ORDER BY/direction is interpolated (identifiers can't be parameterized — allowlist required). - Stored procedures that internally build dynamic SQL (
EXEC(@sql)).
3. Sources (tainted input)
All HTTP inputs (query/body/path/header/cookie), plus second-order: values previously stored in the DB, cache, or config that are re-read into a new query. Trace stored values back to their original write source.
4. Sinks (dangerous operations)
# Python — dangerous
cursor.execute("SELECT * FROM users WHERE id = " + uid)
cursor.execute(f"... WHERE name = '{name}'")
Model.objects.raw("SELECT ... %s" % val) # % formatting = injection
session.execute(text("... " + val)) # SQLAlchemy text() concat// Java — dangerous
stmt.executeQuery("SELECT ... WHERE id=" + id);
entityManager.createQuery("FROM User WHERE name='" + n + "'");
jdbcTemplate.queryForObject("... " + n, ...); // no bind params// Node — dangerous
db.query(`SELECT * FROM t WHERE id = ${id}`);
sequelize.query("SELECT ... WHERE x = '" + x + "'");
knex.raw(`... ${x}`);// PHP — dangerous
mysqli_query($c, "SELECT ... WHERE id=".$_GET['id']);
$pdo->query("... '".$name."'"); // query() with concat, not prepare()// C# — dangerous
new SqlCommand("SELECT ... WHERE id=" + id, conn);5. Sanitizers / safe patterns
Safe: parameterized/prepared statements with bound values — execute(sql,
(param,)), ?/:name placeholders, PreparedStatement.setX, ORM query methods
that bind (filter(id=uid), where({id})). Identifiers (table/column/order)
cannot be bound → must be validated against a strict allowlist.
Fails / not a real sanitizer:
- Manual quote-escaping (
replace("'", "''")) — bypassable, wrong charset, numeric contexts need no quotes. - Blocklisting keywords (
UNION,--) — trivially bypassed. int()/cast applied on one branch only, or after the concat.addslashes, HTML-escaping, or generic "sanitize" helpers not designed for SQL.- Parameterizing the value but concatenating the column name from input.
6. Detection methodology
- Find sinks: grep for the execution APIs and raw-query escape hatches.
rg -n 'execute\(|executeQuery|createQuery|\.raw\(|\.query\(|DB::raw|jdbcTemplate|text\(' rg -n 'f".*SELECT|f".*INSERT|f".*UPDATE|f".*DELETE|\+\s*\w+\s*\+.*(SELECT|WHERE|FROM)' - Confirm concatenation/interpolation: is any operand of the query a variable,
f-string field, template literal, or
%/.format/+? - Trace the operand to a source: follow the variable back. Is it request- derived (directly or second-order)? Stop when you reach a literal/constant.
- Check for a real sanitizer on the path: parameterization? allowlist for identifiers? If a "sanitizer" exists, verify it's correct for SQL and not bypassable (see §5).
- Confirm reachability: is the enclosing function an exposed route/resolver /job, reachable (pre-auth?)?
- Classify blind vs error-based: if the result isn't returned to the user, it's blind (boolean/time) — still exploitable, note it.
7. Modern & niche variants
- Second-order: input stored safely, then concatenated into a later query on read (e.g. username set at signup, used raw in an admin search). Highest miss rate.
- ORM leaks: safe-looking ORM with a hidden
.raw()/.extra()/whereRaw. - JSON/JSONB path injection: Postgres
->>,jsonb_path_query, MySQLJSON_EXTRACTwith interpolated path. ORDER BY/LIMIT/ direction injection: identifiers/keywords that can't be bound and are taken from input without allowlist.- Batch/stacked queries where the driver allows multiple statements.
- Boolean/time-based blind in filters, counts, and existence checks.
- SQLi via headers/UA in logging-to-DB pipelines (source is a header).
8. Common false positives
- Fully parameterized queries where the variable is only the bound value.
- Constant/enum interpolation not reachable from any source.
- Identifiers interpolated from a hard-coded allowlist/map.
- ORM
filter/wherewith dict/kwarg binding (safe unlessraw).
9. Severity & exploitability
Base High; Critical if it enables RCE (e.g. xp_cmdshell, COPY … PROGRAM,
LOAD_FILE/INTO OUTFILE, stacked queries) or exposes crown-jewel data, or is
pre-auth. Lower if strictly read-only on non-sensitive data behind admin auth.
See references/severity-model.md.
10. Remediation
Use parameterized queries / prepared statements everywhere. For dynamic identifiers, map user input through a strict allowlist. Apply least-privilege DB accounts. Never rely on manual escaping.
11. Output
Append each confirmed finding to findings/01-sql-injection.md using
references/finding-template.md. Set Class: SQL Injection, CWE: CWE-89, and in
Chain potential note primitives such as arbitrary data read (→ leaked
secrets/creds for other chains), file read/write (INTO OUTFILE), or auth
bypass (injected WHERE in a login query).
Primitives (controlled): provides DATA_READ,DATA_WRITE,SECRET_LEAK (and FILE_READ/FILE_WRITE/CODE_EXEC on capable DBs); consumes none
References
- CWE-89; OWASP A03:2021 Injection; OWASP SQLi Prevention Cheat Sheet.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

