FormingSkillclaude-codepublished fresh until

My agent builds SQL by gluing strings: how do I make it safe?

Summary OWASP's fix for SQL built by string concatenation is parameterized queries done server-side: bind values separately from SQL syntax. Table and column names need fixed application-owned choices or an allow-list.

Not for wrong totals from joins; see check-ai-written-sql-for-join-fan-out-and-wrong-totals

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
ASkill · v1.0.0SQL bound-value review fixture
How you use itYou ask for it
What it can dowrites files · runs shell
What's inside
ASkill · v1.0.0SQL bound-value review fixture
How you use it
You ask for it
What it can do
writes files · runs shell
What's inside

What this thread does

The symptom

Suppose your coding agent wrote a backend where the SQL text is a template string with the user's value pasted inside, for example SELECT * FROM users WHERE id = ${req.params.id}. OWASP describes SQL injection as untrusted data becoming part of the query's SQL syntax and changing its logic.

What the sources say

  • OWASP's Query Parameterization Cheat Sheet says SQL injection is best prevented with parameterized queries, and that the parameterization must happen on the server side. It warns that many client-side libraries build the query by string concatenation before sending it, so our recommendation is to check that your database API binds values rather than concatenating them into SQL text.

What to do

1. Our recommendation: ask the agent to list every place that builds SQL from a variable. Search the code yourself for SELECT, INSERT, UPDATE, DELETE next to a template literal, an f-string, a + or a .format( as a starting point; also review query construction directly. 2. Our recommendation: rewrite each one with placeholders and pass the values separately. Common forms: $1 with an array in node-postgres, ? in Python's sqlite3, %s with a tuple in psycopg. MySQL Connector/Python uses %s or %(name)s with a tuple or dictionary. Your driver's docs show the exact syntax; OWASP's page shows Java, .NET, Ruby, PHP, Perl and Rust. 3. Table names, column names and ORDER BY direction cannot be value placeholders. OWASP's SQL Injection Prevention Cheat Sheet says to keep these choices fixed in code where possible, or map user choices to a strict allow-list of application-owned values. 4. Our recommendation: if an ORM is in use, check any raw-query escape hatch the same way. ORM query languages also need bound parameters. 5. Our recommendation: add regression tests that send a value containing a single quote and an ' OR '1'='1 string through each endpoint. Assert the intended literal-value behavior or validation error, with no unintended extra rows; also inspect parameter binding.

A prompt to try as a starting point

Our recommendation (untried): "List every database query in this repo that includes a variable in the SQL text. For each, show the file and line, then rewrite it with bound parameters. Do not change behavior. Add a test per endpoint that sends a quote character and an OR 1=1 string."

Common mistakes

Our recommendation: watch for these during review.

  • Escaping quotes by hand instead of using placeholders.
  • Fixing the obvious WHERE clause but leaving ORDER BY ${sort} or LIMIT ${n} open.
  • Trusting validation on the frontend only.
  • Reading the diff for "looks parameterized" without inspecting binding and running regression tests.

Caveats

I have not run these steps myself; the factual guidance comes from OWASP and the linked driver docs, read 2026-11-30. Our recommendation: use quote tests as regression checks alongside inspection of parameter binding; do not treat a passing quote test as proof that every query is safe.

Sources

Read 2026-11-30: OWASP's Query Parameterization Cheat Sheet for server-side parameterization and language examples; OWASP's SQL Injection Prevention Cheat Sheet for bound values, identifier allow-lists and ORM query languages.

Driver syntax: node-postgres queries, Python sqlite3 placeholders, psycopg parameters, and MySQL Connector/Python execute(). No endpoint tests or prompts were run.

Started from a post by @DiscussionHealthy802 (r/vibecoding); OWASP, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# My agent builds SQL by gluing strings: how do I make it safe?
Summary: OWASP's fix for SQL built by string concatenation is parameterized queries done server-side: bind values separately from SQL syntax. Table and column names need fixed application-owned choices or an allow-list.

## Options
- A · SQL bound-value review fixture · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread agent-built-queries-with-string-concatenation-use-parameterized-sql and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-built-queries-with-string-concatenation-use-parameterized-sql

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · SQL bound-value review fixture

Demonstrates server-side value binding and fixed identifier mapping with SQLite quote and injection fixtures.

Format
Skill
Source
—
Pinned
v1.0.0 · sha256:8d5d7
Content hash
8d5d79ef599e9c7a
Audit
scan passed
Can do
writes files · runs shell
Works with
claude-code
Check
Validates installed files and bundled checks locally; does not claim live agent integration.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-sql-bound-values before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp