- Home
- Skills
- Data & Databases
- SQL Injection Vulnerability Patcher
Works with the AI Agents you already use
SQL Injection Vulnerability Patcher
Detects and refactors SQL injection vulnerabilities by replacing raw string interpolation with parameterized queries.
$15
SQL Injection Vulnerability Patcher
Example session with this skill installed
Audit this Python function for SQL injection and fix it: cursor.execute(f"SELECT * FROM logs WHERE user_id = '{uid}' AND action = '{action}'")
- Read your context and instructions
- Compiled the sql injection vulnerability
I have audited the provided Python snippet and identified two SQL injection vulnerabilities stemming from f-string interpolation. I have refactored the code to use parameterized queries and added basic type validation.
SQL Security Remediation
# Refactored Code: Parameterized Query Implementation
import logging
def get_user_logs(cursor, uid: str, action: str):
"""
Fetches user logs using parameterized queries to prevent SQL injection.
Validation ensures uid is alphanumeric to prevent control character injection.
"""
# 1. Defensive Validation: Ensure inputs meet basic criteria
if not uid.isalnum():
logging.error(f"Invalid UID format: {uid}")
return []
# 2. Parameterized Execution: Values are passed separately from the SQL command
# This ensures the DB driver handles escaping and prevents command injection.
query = "SELECT * FROM logs WHERE user_id = %s AND action = %s"
params = (uid, action)
cursor.execute(query, params)
return cursor.fetchall()
Next steps
- Update your unit tests to verify the function correctly handles the new parameter tuple format.
- Review other instances of
cursor.executein your data access layer for similar f-string patterns. - Verify that your specific database driver (e.g.,
psycopg2,mysql-connector) uses%sor?as the placeholder token and adjust if necessary.
Connects securely to your tools. The creator never sees your data.
About this skill
Hardcoded string interpolation in database queries is a critical security flaw that leads to data breaches. This skill audits your backend code to identify SQL injection vulnerabilities and automatically refactors them into secure, parameterized statements.
What it does
- Vulnerability detection scans source code for direct string interpolation and f-strings inside SQL queries.
- Code refactoring converts vulnerable raw string concatenations into safe, parameterized
executecalls. - ORM audit identifies dangerous bypasses like
Sequelize.literal(),SQLAlchemy.text(), or Djangoextra(). - Input validation implements strict typing and whitelisting for dynamic elements like
ORDER BYcolumns. - Secure defaults enforces query parameterization across polyglot backend environments.
How it works
- Scan the project workspace to detect dynamic SQL string assembly and unsafe ORM patterns.
- Generate refactored code snippets using parameterized query syntax specific to your database driver.
- Apply defensive validation rules to ensure dynamic inputs are typed and whitelisted.
- Verify that no raw secrets or hardcoded credentials are leaked during the remediation process.
Frameworks & tools
Works with Python (SQLAlchemy, Django), JavaScript/TypeScript (Sequelize, TypeORM), and raw SQL drivers using standard parameterization patterns.
Why this beats prompting it yourself
Generic prompts often miss subtle ORM bypasses or fail to handle complex dynamic clauses like LIMIT or ORDER BY. This skill follows a deterministic security workflow to ensure every identified vulnerability is closed using industry-standard defensive patterns rather than just escaping strings.
Use cases
- Auditing legacy Express or Flask apps for raw SQL concatenation.
- Securing ORM implementations that use unsafe raw text escapes.
- Refactoring internal tools to meet security compliance standards.
- Implementing strict input whitelisting for dynamic sorting features.
Known limitations
Restricted to project workspace files. Does not perform runtime traffic analysis or active penetration testing.
Restricted to project workspace (./). Does not perform active penetration testing or dynamic runtime analysis. Scope limited to static code analysis and refactoring.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 days ago
Requires
Permissions
Target Use Cases: - Fix SQL injection in raw database query. - Refactor vulnerable string concatenation into parameterized SQL. - Audit ORM code for SQL injection bypasses.