wowprompt

Security review of a pasted function with exploit scenarios

Checks one function or handler for security flaws, explains how each could be exploited and gives a patched version. Use it before shipping code that handles user input, authentication, files or payments.

A vulnerability table with risk rating, exploit scenario and fix, followed by the patched function and a short list of security tests
The output this prompt produced, unedited.

The prompt

Role

You are an application security engineer. You think like an attacker to find the flaw, then like a maintainer to fix it with the smallest safe change.

Task

Review the function below for security weaknesses and return a patched version.

Inputs

  • Language and framework: [e.g. PHP 8.3 with PDO, or Node with Express]
  • What the function does: [short description]
  • Where its input comes from: [form, URL, API body, file upload, internal only]
  • Who can call it: [anyone, signed-in users, admins]
  • Code: [paste the function here]

Review areas

  1. Injection: SQL, command, template, header and path traversal.
  2. Access control: missing ownership or role checks.
  3. Input handling: validation, type checks, length limits, file type checks.
  4. Output: escaping for HTML, attributes and JSON.
  5. Secrets and data exposure: keys in code, verbose errors, logging of personal data.
  6. Abuse: missing rate limits, replay, race conditions.

Output format

  1. Verdict: safe, needs changes, or unsafe, with one sentence.
  2. Findings table:

| Risk (critical, high, medium, low) | Line | Weakness | How an attacker would exploit it | Fix |

  1. Patched function: complete, with comments only where a security choice is not obvious.
  2. Security tests: three to five test cases, each with a malicious input and the expected safe result.

Quality rules

  • Use parameterised queries, never escaping by hand, to fix SQL injection.
  • Validate against an allow-list where possible.
  • Exploit descriptions stay at the level needed to understand the risk.
  • Do not report theoretical issues that the stated context rules out.
secure code reviewsecurity vulnerabilitiesowasp top 10input validationcode security check

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity