Skip to content
Back to skills

Sql Injection Prevention

ASecurity

Finds queries built from strings and rewrites them as parameterized statements, with allowlists for column names, sort order and other identifiers.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agentssqldatabase

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill sql-injection-prevention --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sql Injection Prevention?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sql Injection Prevention
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-sql-injection-prevention/badge)](https://www.skillsdirectory.com/skills/workspace-templates-sql-injection-prevention)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sql-injection-prevention
description: Finds queries built from strings and rewrites them as parameterized statements, with allowlists for column names, sort order and other identifiers.
---

# SQL injection prevention

Find every query that mixes text and input, and make the input unable to change the query shape.

## Steps

1. Search for query construction with dynamic parts: template strings or `+` near `SELECT`, `INSERT`, `UPDATE`, `DELETE`, `WHERE`, `ORDER BY`, `LIMIT`; ORM escape hatches (`raw()`, `queryRawUnsafe`, `extra()`, `text()`, `literal()`); stored procedures called with built strings.
2. For each hit, trace where every interpolated value comes from. Skip values that are constants.
3. Values: replace with bound parameters and pass them separately (`?`, `$1`, `:name`, tagged-template helpers). Do not hand-escape quotes.
4. `IN` lists: generate one bound slot per item, or use `= ANY($1)` with an array. Guard against empty lists.
5. Identifiers and keywords cannot be bound. Map input to a fixed object, such as `{ price: "price", newest: "created_at" }`, and reject unknown keys. Direction is `asc` or `desc` only. Cast `LIMIT` and `OFFSET` to bounded integers.
6. `LIKE` patterns: bind the value and escape `%` and `_` when the user should not control wildcards.
7. Check the database account: does the app user need DDL or access to other schemas? Recommend least privilege.
8. Add a test per fixed query using inputs like `' OR 1=1 --` and `1; DROP TABLE x` that must return no extra rows or an error, never a changed result.

## Rules

- Do not rely on input filtering or on stripping quotes.
- Keep behaviour identical for valid input.

## Report

Each query fixed (`path:line`, before, after), identifiers allowlisted, tests, and any query left because it needs a design change.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.