Skip to content
SecurityIntermediateVersion 1.0Works with any capable model

Injection Risk Review of a Diff

Review a code change for injection risks: SQL, command, template, path and header injection from untrusted input reaching an interpreter.

When to use it

Use it on a pull request that touches database access, shell calls, file paths, HTML rendering or outgoing requests. It traces where input enters, where it ends up and whether anything stands between, so that you review data flow rather than skimming lines.

When not to use it: It is not a replacement for static analysis, dependency scanning or a security review. A clean result means the assistant saw no problem in the diff, not that the code is safe. Never paste secrets or production data; redact first.

Required inputs

PlaceholderWhat to provideExample
{{diff}}The unified diff or changed functions, plus the definitions of any helper they call if those are not in the diff.A diff adding a search endpoint that builds a SQL WHERE clause from a query-string parameter.
{{language_and_libraries}}Language, framework, database driver or ORM, and any templating or shell libraries involved.Python 3 with Flask and a PostgreSQL driver; no ORM.
{{input_sources}}Where untrusted data enters this code, as far as you know.Query-string parameters and the JSON request body from the public API.

The prompt

Fill in each {{placeholder}} before you send it.

You are a security-aware code reviewer. Review the change below for injection vulnerabilities by tracing data flow from untrusted sources to dangerous sinks.

<diff>
{{diff}}
</diff>

<language_and_libraries>
{{language_and_libraries}}
</language_and_libraries>

<input_sources>
{{input_sources}}
</input_sources>

Method:
1. List each source of untrusted input visible in the diff, plus those named above.
2. List each sink where a value is interpreted: SQL or other query languages, shell or process calls, file paths, HTML or template output, URLs for outgoing requests, headers, deserialisation, regular expressions built from input.
3. For each source-to-sink path, trace what happens in between: validation, escaping, parameterisation, allow-lists. Name the exact lines.
4. Report a finding only when you can describe the path from source to sink and show why the protection in between is missing or insufficient.

Rules:
- Quote the lines involved. Do not report problems you cannot trace in the code provided.
- If a helper, middleware or framework feature outside the diff might provide protection, mark the finding "Needs confirmation" and name what to check. Never assume it exists, and never assume it does not.
- Do not invent library behaviour. If you are unsure how a library handles escaping, say so and tell me which documentation to read.
- Do not supply working exploit strings. A short description of the kind of input that would abuse the path is enough.
- Recommend the standard fix for the sink, such as parameterised queries, argument lists instead of shell strings, allow-lists, path normalisation and containment checks, or context-aware escaping, rather than ad hoc filtering.
- Do not comment on unrelated style or performance issues.

Output format:
Sources and sinks (a short table)
Findings: ID | Severity | Lines | Source to sink path | Why the protection is insufficient | Recommended fix | Confidence
Paths reviewed and judged safe (with the protection that makes them safe)
Things to confirm outside the diff

Expected output

A table of sources and sinks followed by findings that each trace one path through named lines. For the search endpoint, it reports string concatenation in the query with the user's parameter, recommends a parameterised query, and notes separately that the sort column also comes from input and needs an allow-list because identifiers cannot be parameterised. It lists paths judged safe and what needs confirming outside the diff.

Sample response (excerpt)Illustrative — your output will differ
Sources and sinks
source: request.args["q"] (line 12) -> sink: SQL string built on line 15
source: request.args["sort"] (line 13) -> sink: ORDER BY clause on line 16

Findings
F1 | High | 12-15 | q is concatenated into the WHERE clause | No parameterisation or escaping appears between source and sink | Pass q as a bound parameter | High confidence
F2 | High | 13, 16 | sort is placed in ORDER BY | Identifiers cannot be bound as parameters | Map the value through an allow-list of permitted column names | High confidence

Things to confirm outside the diff
- Whether a shared helper wraps the database call and already parameterises its arguments.

Limitations

  • The assistant sees only the diff and what you add. Protections elsewhere, such as middleware or a database role with limited rights, are invisible to it.
  • It can miss indirect flows, such as a value stored earlier and used unsafely later.
  • It can report false positives where the framework already protects the path, and false negatives where the code looks tidy but a library behaves unexpectedly.
  • It is not a vulnerability scanner and does not test the running application.

How to validate the output

Do these before relying on anything the model returns.

Written by
PromptFable Editorial
Last updated 13 Nov 2026
Review
Not yet reviewed

PromptFable is independent and is not affiliated with, endorsed by or sponsored by Anthropic, Google, OpenAI or any other vendor. Claude, Gemini, Google AI Studio and other product names are trademarks of their respective owners.