detecting-sql-injection

Detect SQL Injection vulnerabilities in Spring Boot and JSP/Servlet codebases using Semgrep rules and AI context verification.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/bs-koo/gx-security --skill detecting-sql-injection-bs-koo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: detecting-sql-injection
Source: https://github.com/bs-koo/gx-security/tree/main/skills/detecting-sql-injection
Command: npx skills add https://github.com/bs-koo/gx-security --skill detecting-sql-injection-bs-koo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Static scanners flood you with false positives when hunting SQL Injection in Java web applications, especially when MyBatis ${} interpolation looks identical to safe #{} binding. This Skill finds SQLi candidates across both modern Spring Boot and legacy JSP/Servlet stacks, then verifies each finding against actual code context so only confirmed vulnerabilities reach your report. ## Core Features & Use Cases - Stack-aware scanning: Automatically detects spring-modern vs jsp-legacy project layouts and applies the matching Semgrep ruleset, with a grep fallback when Semgrep is not installed. - AI context verification: Distinguishes dangerous MyBatis ${param} string substitution from safe #{param} binding, traces user input sources, and checks ORDER BY allowlist validation before confirming a finding. - Standardized 4-element reports: Every confirmed vulnerability documents what is vulnerable, why, how it is exploited (concept PoC), and the fix, sorted by severity. - Use Case: Before releasing a Spring Boot board application, run the scan to catch a JdbcTemplate.query("... '" + name + "'") concatenation and receive a ready-made fix using ? placeholders. ## Quick Start Ask the AI to check the project at a given source path for SQL Injection vulnerabilities and produce a severity-ranked report.

Frequently Asked Questions about detecting-sql-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect SQL Injection in Java Spring Boot code?▼

Run the scan_sqli.py script against your source directory; it applies Semgrep rules for JdbcTemplate string concatenation, JPA createQuery concatenation, and MyBatis ${} interpolation. Each candidate is then verified in context to confirm whether user input actually reaches the query.

What is the difference between MyBatis #{} and ${} for SQL Injection?▼

#{} uses PreparedStatement parameter binding and is safe against SQL Injection. ${} performs raw string substitution into the SQL, so it is dangerous when the value comes from user input; it is only acceptable for identifiers like ORDER BY columns after allowlist validation.

Does the SQL Injection scanner work without Semgrep installed?▼

Yes, the scanner falls back to regex-based grep detection when Semgrep is unavailable. The fallback has lower precision and recall, so it prints a warning and the AI verification step becomes more important to filter false positives.

Can this detect SQL Injection in legacy JSP and Servlet applications?▼

Yes, the jsp-legacy ruleset covers JSP scriptlet Statement string concatenation, prepareStatement inline concatenation, and MyBatis or iBATIS mapper XML under sqlmap directories. Stack detection uses signals like web.xml, .jsp files, and pom.xml.

Why does the scanner report findings that turn out to be false positives?▼

The scanner intentionally casts a wide net, flagging patterns like ${} that may use safe internal configuration values rather than user input. The second-stage AI verification traces input sources and allowlist checks, and excluded items are documented in the report's false-positive section.

When should I not use this SQL Injection detection skill?▼

Skip it for vulnerability classes other than SQLi such as XSS or CSRF, which have their own skills, and for batch queries or hardcoded SQL with no user input. It performs static analysis only, so confirming live exploitability requires the separate penetration testing skill.