detecting-sql-injection-vulnerabilities

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".

1,868 stars

Best use case

detecting-sql-injection-vulnerabilities is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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".

Teams using detecting-sql-injection-vulnerabilities should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/detecting-sql-injection-vulnerabilities/SKILL.md --create-dirs "https://raw.githubusercontent.com/jeremylongshore/claude-code-plugins-plus-skills/main/plugins/security/sql-injection-detector/skills/detecting-sql-injection-vulnerabilities/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/detecting-sql-injection-vulnerabilities/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How detecting-sql-injection-vulnerabilities Compares

Feature / Agentdetecting-sql-injection-vulnerabilitiesStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 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

Related Skills

scanning-for-xss-vulnerabilities

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill enables AI assistant to automatically scan for xss (cross-site scripting) vulnerabilities in code. it is triggered when the user requests to "scan for xss vulnerabilities", "check for xss", or uses the command "/xss". the skill identifies ref... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

scanning-for-vulnerabilities

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill enables comprehensive vulnerability scanning using the vulnerability-scanner plugin. it identifies security vulnerabilities in code, dependencies, and configurations, including cve detection. use this skill when the user asks to scan fo... Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

detecting-performance-regressions

1868
from jeremylongshore/claude-code-plugins-plus-skills

Automatically detect performance regressions in CI/CD pipelines by comparing metrics against baselines. Use when validating builds or analyzing performance trends. Trigger with phrases like "detect performance regression", "compare performance metrics", or "analyze performance degradation".

detecting-memory-leaks

1868
from jeremylongshore/claude-code-plugins-plus-skills

Detect potential memory leaks and analyze memory usage patterns in code. Use when troubleshooting performance issues related to memory growth or identifying leak sources. Trigger with phrases like "detect memory leaks", "analyze memory usage", or "find memory issues".

detecting-performance-bottlenecks

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute this skill enables AI assistant to detect and resolve performance bottlenecks in applications. it analyzes cpu, memory, i/o, and database performance to identify areas of concern. use this skill when you need to diagnose slow application performance, op... Use when optimizing performance. Trigger with phrases like 'optimize', 'performance', or 'speed up'.

detecting-infrastructure-drift

1868
from jeremylongshore/claude-code-plugins-plus-skills

Execute use when detecting infrastructure drift from desired state. Trigger with phrases like "check for drift", "infrastructure drift detection", "compare actual vs desired state", or "detect configuration changes". Identifies discrepancies between current infrastructure and IaC definitions using terraform plan, cloudformation drift detection, or manual comparison.

detecting-database-deadlocks

1868
from jeremylongshore/claude-code-plugins-plus-skills

Process use when you need to work with deadlock detection. This skill provides deadlock detection and resolution with comprehensive guidance and automation. Trigger with phrases like "detect deadlocks", "resolve deadlocks", or "prevent deadlocks".

detecting-data-anomalies

1868
from jeremylongshore/claude-code-plugins-plus-skills

Process identify anomalies and outliers in datasets using machine learning algorithms. Use when analyzing data for unusual patterns, outliers, or unexpected deviations from normal behavior. Trigger with phrases like "detect anomalies", "find outliers", or "identify unusual patterns".

code-injection-detector

1868
from jeremylongshore/claude-code-plugins-plus-skills

Code Injection Detector - Auto-activating skill for Security Fundamentals. Triggers on: code injection detector, code injection detector Part of the Security Fundamentals skill category.

schema-optimization-orchestrator

1868
from jeremylongshore/claude-code-plugins-plus-skills

Multi-phase schema optimization workflow orchestrator. Creates session directories, spawns phase agents sequentially, validates outputs, aggregates results. Trigger: "run schema optimization", "optimize schema workflow", "execute schema phases"

test-skill

1868
from jeremylongshore/claude-code-plugins-plus-skills

Test skill for E2E validation. Trigger with "run test skill" or "execute test". Use this skill when testing skill activation and tool permissions.

example-skill

1868
from jeremylongshore/claude-code-plugins-plus-skills

Brief description of what this skill does and when the model should activate it. Use when [describe the user's intent or situation]. Trigger with "example phrase", "another trigger", "/example-skill".