Audit a Pull Request Diff for Security Flaws and Auth Bypasses

Get a line-by-line PR security review mapping each flaw to an OWASP category, concrete abuse scenario, and minimal drop-in code patch.

Agent prompt for ChatGPT and Claude

You get: Summary table with columns, numbered finding sections and verification checklist with 2 to 3 targeted tests to…

Prompt

Prompt
Act as a principal application security engineer reviewing a production pull request. I will paste a git diff right after this prompt. Audit the changed lines for authentication bypasses, broken access control, injection flaws, secret leaks, and unsafe deserialization.

Rules:
1. Report only concrete issues visible in the diff; skip generic security checklists and style advice.
2. Map every finding to a specific OWASP Top 10 category and cite the exact file path and line number from the diff.
3. Explain the realistic abuse scenario in two sentences so a developer understands the business impact without guesswork.
4. Provide a minimal drop-in code patch for each finding that preserves existing behavior for authorized users.
5. Rank findings from Critical to Low severity; if no real security flaw exists, state that clearly instead of inventing one.

Output format:
- Summary table with columns: Severity, File and Line, OWASP Category, Issue.
- Numbered finding sections, each containing: Impact and Abuse Scenario, and Minimal Patch in a fenced code block.
- Verification checklist with 2 to 3 targeted tests to confirm the fixes.

End with one short paragraph noting any security assumptions that depend on unseen middleware, database rules, or gateway configs.

Example output

Security flaws found in the invoice export PRTwo findings, each mapped to an OWASP category
ItemMissing tenant checkUnsanitized format
SeverityCriticalHigh
Locationapi/invoices.py:42api/invoices.py:51
OWASP categoryA01 Broken Access ControlA03 Injection
Expected response after fix404 for other org400 for bad format

Example for: a Python FastAPI billing service PR adding an invoice export endpoint.

SeverityFile and LineOWASP CategoryIssue
Criticalapi/invoices.py:42A01 Broken Access ControlMissing tenant ownership check on invoice lookup
Highapi/invoices.py:51A03 InjectionUnsanitized format query parameter passed to subprocess
1. Missing Tenant Ownership Check on Invoice Lookup

Impact and Abuse Scenario: Any authenticated user can pass another organization's numeric invoice ID to the export route and download their private billing PDF. Because the query filters only by invoice ID, tenant isolation is completely bypassed.

Minimal Patch:

invoice = db.query(Invoice).filter(
    Invoice.id == invoice_id,
    Invoice.org_id == current_user.org_id,
).first()
if not invoice:
    raise HTTPException(status_code=404, detail="Invoice not found")
2. Unsanitized Format Parameter Passed to Subprocess

Impact and Abuse Scenario: The route passes the user-supplied format string directly into a shell command string for the PDF converter. A crafted query parameter can execute arbitrary commands under the API container's permissions.

Minimal Patch:

ALLOWED_FORMATS = ("pdf", "csv")
if export_format not in ALLOWED_FORMATS:
    raise HTTPException(status_code=400, detail="Unsupported format")
subprocess.run(
    ("invoice-cli", "--format", export_format, str(invoice.id)),
    check=True,
)
Verification Checklist
  1. Send a request for invoice 402 using a token from a different organization and confirm a 404 response.
  2. Request the export route with an unsupported format string and confirm a 400 response before any subprocess runs.
  3. Confirm an authorized org member still receives a valid PDF for their own invoice.

Assumptions and Missing Context: This review assumes the auth dependency already validates JWT signatures and expiration, and that database row-level security is not enforced at the Postgres layer.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Requiring exact file paths, line numbers, and OWASP categories prevents vague, generic security checklists.
  • Pairing a two-sentence abuse scenario with a minimal drop-in patch makes each finding immediately actionable in PR comments.
  • Explicitly allowing a clean pass stops the model from hallucinating minor style nitpicks as security bugs.

Paste this into GitHub Copilot Chat, Claude, or ChatGPT right before your git diff when reviewing auth, billing, or API pull requests. Include surrounding route middleware if available.

Common edits

  • Add a rule to flag compliance-specific risks like PII logging or missing audit trails for HIPAA or SOC 2 repos.
  • Specify your test framework, such as pytest or Jest, in the verification checklist so the model outputs ready-to-run test cases.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

AI Coding AgentsClaude Code

Pre-Merge Self-Review of a Git Diff: Correctness, Security, and Test Gaps

Has Claude Code review a branch diff like a skeptical maintainer, producing severity-ranked findings with evidence and a clear merge, fix, or block recommendation. Use it before opening or approving a pull request.

Codex Pre-Merge Diff Review with Severity-Ranked Findings

Has Codex review a branch diff against a base ref in read-only mode. It checks correctness, tests, security, and maintainability, and returns evidence-backed findings with severity and a merge recommendation.

Audit a Pull Request Diff for Breaking API Changes

Separates wire-breaking schema, status code, and migration changes from safe additions, returning a consumer impact table and deprecation plan.

Coding

Security Review of a Code Snippet: Ranked Findings With Exploit Path and Fix

Reviews pasted code for injection, broken authorization, secrets, SSRF and similar flaws, and returns only real findings ranked by severity, each with a one-line exploit path and fixed code.

Coding

Pull Request Review with Merge Recommendation

Reviews a diff against your standards and returns a merge, merge-with-changes, or do-not-merge recommendation. Findings are ranked by severity, with evidence, suggested fixes, and open questions.

Pre-PR Self-Review and Pull Request Description from a Git Diff

Has GitHub Copilot review your branch diff against the base branch, flag defects and missing tests, and draft a PR description with evidence. Use it to decide whether to open the PR or fix issues first.