Detecting SQL Injection Vulnerabilities

VerifiedSafe

Detect and analyze SQL injection vulnerabilities in application code and database queries. Scan for risks, review query construction, validate input sanitization.

Sby Skills Guide Bot
SecurityIntermediate
7/22/2026
Claude CodeCodex
#sql-injection#static-analysis#owasp#secure-coding#code-review

Recommended for

Automated summary

Scans application source code for SQL injection vulnerabilities by tracing user input through data flows into query construction, then produces a security report with remediations.

Strengths

  • Comprehensive mapping of input surfaces (HTTP params, headers, cookies, uploads, WebSocket messages) with data-flow tracing
  • Multi-pattern detection: string concatenation, f-strings, template literals, unparameterized raw ORM queries
  • Findings classified with CVSS 3.1 scores, attack type (blind, UNION, second-order) and business impact
  • Generates idiomatic remediated code per framework and database, plus defense-in-depth recommendations

Limitations

  • Static analysis only: no real exploitation or dynamic validation of findings
  • Effectiveness depends on the user having already identified the framework and database type
  • Requires write permissions to generate reports in the skill's working directory
When to use it

Use during a code security audit, before a production release, or when reviewing newly written database queries.

When not to use it

Not suitable for dynamic penetration testing against a running application or for analyzing compiled binaries.

Security analysis

Safe
Quality score88/100

This is a defensive static-analysis skill that scans local source code for SQL injection patterns and writes a remediation report. Allowed tools are Read/Grep/Glob/Edit/Write plus narrowly scoped Bash prefixes (code-scan:*, security-test:*); there are no destructive commands, no network calls, no secret/token exfiltration, and no obfuscated payloads. Output is confined to a security-reports directory. Residual risk is minimal and limited to edits/writes within the project tree.

No concerns found

How this analysis is made

Examples

Scan a Node.js API
Scan the Express app in ./src for SQL injection vulnerabilities, trace the request handlers into the query layer, and write a report with CVSS scores and parameterized fixes.
Review ORM raw queries
Detect SQLi risks in our Django models and any .raw() or .extra() calls, then show the parameterized equivalent for each finding.
Check input sanitization
Review how user input from HTTP headers and cookies reaches our SQL queries in this repository and flag every path that skips parameter binding.

name: detecting-sql-injection-vulnerabilities description: | Detect and analyze SQL injection vulnerabilities in application code and database queries. Use when you need to scan code for SQL injection risks, review query construction, validate input sanitization, or implement secure query patterns. Trigger with phrases like "detect SQL injection", "scan for SQLi vulnerabilities", "review database queries", or "check SQL security".

allowed-tools: Read, Write, Edit, Grep, Glob, Bash(code-scan:), Bash(security-test:) version: 1.0.0 author: Jeremy Longshore jeremy@intentsolutions.io license: MIT compatible-with: claude-code, codex, openclaw tags: [security, database, detecting-sql]

Detecting SQL Injection Vulnerabilities

Overview

Scan application source code for SQL injection vulnerabilities (CWE-89, OWASP A03:2021) by tracing user input from entry points through data flows into database query construction. Detect string concatenation, format string interpolation, and inadequate parameterization across raw SQL, ORM raw query methods, stored procedure calls, and dynamic query builders.

Prerequisites

  • Application source code accessible in ${CLAUDE_SKILL_DIR}/
  • Database query files, ORM models, and repository/DAO layers available
  • Framework and language identified (Django, Rails, Express, Spring, Laravel, ASP.NET, Go, etc.)
  • Database type known (MySQL, PostgreSQL, SQLite, MSSQL, Oracle) for syntax-specific detection
  • Write permissions for reports in ${CLAUDE_SKILL_DIR}/security-reports/

Instructions

  1. Discover database interaction code: search for SQL keywords (SELECT, INSERT, UPDATE, DELETE, EXEC) and ORM raw query methods (raw(), execute(), createNativeQuery(), $wpdb->query()) across all source files.
  2. Identify input surfaces: map all user-controllable data entry points -- HTTP parameters, request bodies, URL path segments, headers, cookies, file uploads, and WebSocket messages.
  3. Trace data flows: follow each input surface through the code to determine whether user data reaches a SQL query. Flag any path where input is not passed through parameterized query binding.
  4. Detect vulnerable patterns:
    • String concatenation: "SELECT * FROM users WHERE id=" + userId
    • f-string/format interpolation: Python f-strings embedding variables directly into SQL strings
    • Template literals: `SELECT * FROM users WHERE id=${req.params.id}`
    • ORM raw queries without bindings: Model.objects.raw("SELECT * FROM t WHERE x='" + val + "'")
  5. Classify each finding: assign CVSS 3.1 score, identify attack type (classic injection, blind boolean/time-based, UNION-based exfiltration, second-order/stored injection), and document exploitability (authentication required, network access).
  6. Assess impact per finding: determine data exposure scope (authentication bypass, data exfiltration, data modification, OS command execution via xp_cmdshell or LOAD_FILE()).
  7. Generate remediation code: provide parameterized equivalents for each vulnerable query. Use framework-idiomatic patterns -- %s placeholders for Python DB-API, ? for Node.js, $1 for PostgreSQL, named parameters for Spring JPA.
  8. Recommend defense-in-depth measures: input validation (allowlists over denylists), stored procedures with parameterized calls, least-privilege database accounts, WAF rules, and ORM-only data access policies.
  9. Produce the vulnerability report at ${CLAUDE_SKILL_DIR}/security-reports/sqli-scan-YYYYMMDD.md with per-finding severity, CWE-89 mapping, file path and line number, vulnerable code snippet, attack vector demonstration, and remediated code.

See ${CLAUDE_SKILL_DIR}/references/implementation.md for the detection pattern library. See ${CLAUDE_SKILL_DIR}/references/critical-findings.md for example vulnerability write-ups with attack demonstrations.

Output

  • Vulnerability Report: ${CLAUDE_SKILL_DIR}/security-reports/sqli-scan-YYYYMMDD.md with all findings classified by severity
  • Finding Details: per-finding file path, line number, vulnerable code, attack vector, CVSS score, and remediation code
  • Remediation Summary: parameterized query replacements grouped by language/framework
  • Defense Recommendations: input validation rules, database privilege changes, and WAF configuration

Error Handling

| Error | Cause | Solution | |-------|-------|----------| | Unknown ORM or database framework | Custom or uncommon data access library | Apply generic SQL injection pattern detection; note limited framework-specific guidance | | Cannot analyze compiled/minified code | Production bundles or bytecode instead of source | Request unminified source; document reduced detection accuracy | | False positive on sanitized input | Proper sanitization exists but not recognized | Trace sanitization implementation manually; whitelist verified-safe patterns | | Complex dynamic query builder logic | Multi-step query construction across modules | Trace full data flow manually; flag for manual security review | | Cannot analyze stored procedure definitions | SQL source files not available in ${CLAUDE_SKILL_DIR}/ | Request .sql files or database schema exports; focus on application-layer code |

Examples

  • "Scan the codebase for SQL injection risks in dynamic query construction, focusing on controllers and API handlers."
  • "Review these query snippets and propose parameterized equivalents with unit tests validating the fix."
  • "Detect second-order SQL injection in the user profile update flow where stored data is later used in admin queries."

Resources

  • OWASP SQL Injection Prevention Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
  • CWE-89 Improper Neutralization of SQL Syntax: https://cwe.mitre.org/data/definitions/89.html
  • OWASP A03:2021 Injection: https://owasp.org/Top10/A03_2021-Injection/
  • CAPEC-66 SQL Injection: https://capec.mitre.org/data/definitions/66.html
  • ${CLAUDE_SKILL_DIR}/references/critical-findings.md -- example vulnerability write-ups with attack vectors
  • ${CLAUDE_SKILL_DIR}/references/errors.md -- full error handling reference
  • ${CLAUDE_SKILL_DIR}/references/examples.md -- additional usage examples
  • https://intentsolutions.io

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/detecting-sql-injection-vulnerabilities-mrwakcy7/download' --output '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md.part' && mv '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md.part' '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Write, Edit, Grep, Glob, Bash(code-scan:*), Bash(security-test:*)

Original excerpt: Prerequisites
  • Application source code accessible in ${CLAUDE_SKILL_DIR}/
  • Database query files, ORM models, and repository/DAO layers available
  • Framework and language identified (Django, Rails, Express, Spring, Laravel, ASP.NET, Go, etc.)
  • Database type known (MySQL, PostgreSQL, SQLite, MSSQL, Oracle) for syntax-specific detection
  • Write permissions for reports in ${CLAUDE_SKILL_DIR}/security-reports/

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md' && test -s '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/detecting-sql-injection-vulnerabilities' && cp -R '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7' '.claude/skills/detecting-sql-injection-vulnerabilities'

Codex
test -f '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md' && test -s '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/detecting-sql-injection-vulnerabilities' && cp -R '.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7' '.agents/skills/detecting-sql-injection-vulnerabilities'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7'

openskills read 'detecting-sql-injection-vulnerabilities-mrwakcy7'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/detecting-sql-injection-vulnerabilities-mrwakcy7/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills