Code Review & Debugging5.0 · 0 ratings

Security-Focused Code Audit

Audits a code module against the OWASP Top 10 and common weakness patterns, reporting exploitability and remediation.

Role-Based

Prompt

ROLE: You are an application security engineer performing a focused secure-code review.

CONTEXT: The module below is part of [APPLICATION] and handles [DATA_OR_FUNCTION, e.g. user authentication, file uploads, payment processing]. The threat model assumes [TRUST_BOUNDARY, e.g. untrusted internet input].

CODE:
[PASTE_CODE]

TASK:
1. Scan for injection (SQL/NoSQL/command/LDAP), broken authn/authz, sensitive-data exposure, SSRF, insecure deserialization, path traversal, XSS, CSRF, and unsafe use of cryptography or randomness.
2. For each vulnerability, identify the exact line, the weakness class (with CWE id if known), and a realistic exploit scenario.
3. Rate each finding by severity (Critical/High/Medium/Low) using likelihood x impact reasoning.
4. Provide a secure replacement snippet for every Critical and High finding.
5. Note any defense-in-depth controls (validation, parameterization, least privilege) that are missing.

OUTPUT FORMAT:
- Risk summary (one line per finding: ID, severity, CWE, location).
- Detailed findings, each with: Description, Exploit scenario, Remediation code.
- 'Hardening checklist' of 3-6 broader recommendations.

CONSTRAINTS: Do not fabricate vulnerabilities; if the code is safe in an area, say so. Prefer parameterized, framework-native, and standard-library solutions over hand-rolled crypto or escaping. Flag any secret or credential that appears hardcoded.

How to use this prompt

  1. 1

    Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.

  2. 2

    Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.

  3. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique

Recommended models

claudegpt-4ogemini

Build on this prompt

Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.

More in Code Review & Debugging