OWASP security audit of a code snippet
Review a code snippet for OWASP Top 10 vulnerabilities: findings with severity, abuse scenario, fixed code and tests that prove the issue stays fixed. Designed for ChatGPT, Claude, Gemini and Microsoft Copilot. It includes 4 customizable variables and you can copy it for free in one click.
Advanced · Code · Pending editorial review
Prompt
Act as an application security engineer specializing in secure code review and the OWASP Top 10.
Context:
- Language and framework: {{language}}
- What this code does and where it runs: {{context}}
- Exposure: {{exposure}}
- Code to review:
```
{{code}}
```
Deliverables:
1. A 3-line executive summary: overall risk level and the most urgent finding.
2. A findings table: ID, affected line or snippet, OWASP Top 10 category and CWE where applicable, severity (critical, high, medium, low) justified by the exposure, and confidence level.
3. For each finding: why it is vulnerable and an abuse scenario described conceptually, without ready-to-use exploit payloads.
4. Complete fixed code using the idiomatic defenses of {{language}} (parameterized queries, contextual output encoding, allow-list validation, server-side access control, safe secret handling).
5. Automated tests proving the fix works, including typical malicious inputs.
6. Defense-in-depth measures outside the code (headers, least privilege, logging and alerting).
Constraints:
- Do not flag something as vulnerable unless you can justify it; if it depends on code I have not shown, mark it [FILL IN: confirm] and explain what to check.
- Also point out what is done well so it is not broken during the fix.
- If key context is missing (authentication, where the input comes from), ask me first.
- This review is guidance only: for production systems handling sensitive data, recommend a professional audit or penetration test.
Format: summary, table, per-finding detail, fixed code and tests.How to use it
Paste the whole function or endpoint, not just the suspicious line, and explain where the input comes from. Fix critical findings first and run the suggested tests before merging.
Usage example
Language: PHP 8, no framework · Context: endpoint that looks up orders by customer email · Exposure: public internet · Code: SQL query built by concatenating $_GET.
Sample output
1. Summary
Critical risk. The id is concatenated into the SQL (injection) and nothing checks that the invoice belongs to the user (IDOR). Both are exploitable from the internet.
2. Findings
| ID | Snippet | Category | Severity | Confidence |
|---|---|---|---|---|
| F1 | '... WHERE id = ' + req.params.id | A03 Injection · CWE-89 | Critical | High |
| F2 | No per-user filter | A01 Broken Access Control · CWE-639 | High | High |
| F3 | SELECT * | A01 · data exposure | Medium | Medium |
| F4 | Promise without catch | A09 · unhandled errors | Low | High |
4. Fixed code
app.get('/invoices/:id', requireAuth, async (req, res, next) => {
// Allow-list: positive integers only
if (!/^[1-9]\d{0,9}$/.test(req.params.id)) {
return res.status(400).json({ error: 'invalid_id' });
}
try {
// Parameterized query (node-postgres syntax: [FILL IN: confirm driver])
const { rows } = await db.query(
'SELECT id, number, issued_at, total, status FROM invoices WHERE id = $1 AND user_id = $2',
[req.params.id, req.user.id],
);
// 404 whether it is missing or someone else's: does not reveal which ids exist
if (rows.length === 0) return res.status(404).json({ error: 'not_found' });
return res.json(rows[0]);
} catch (err) {
return next(err);
}
});
The column list is an example: trim it to what the customer actually needs to see. This review is guidance only; before going to production with billing data, get a professional audit…
Key facts
- Category
- Programming & development · Debugging
- Output type
- Code
- Level
- Advanced
- Designed for
- ChatGPT, Claude, Gemini and Microsoft Copilot
- Verified in
- Pending editorial verification
- Variables
- Language and framework, What it does and where it runs, Exposure and Code
- Language
- English
- Price
- Free, no sign-up
- Updated
- Nov 7, 2026
Frequently asked questions
Can AI replace a SAST tool or a penetration test?
No. It is useful as a first pass and for understanding issues, but it can miss things or raise false positives. Combine it with static analysis, human review and, for critical systems, professional penetration testing.
Is it safe to paste my code into a chatbot?
Remove keys, passwords, tokens and personal data first, and check your company policy on AI tools. For confidential code, use an enterprise plan with privacy guarantees.
What is this prompt for?
Review a code snippet for OWASP Top 10 vulnerabilities: findings with severity, abuse scenario, fixed code and tests that prove the issue stays fixed.
Which AI tools does it work with?
It is designed for ChatGPT, Claude, Gemini and Microsoft Copilot. We have not verified it in these tools yet, so results may vary between them.
How do I customize the prompt?
Click “Customize” and fill in the variables (Language and framework, What it does and where it runs, Exposure and Code). The text updates instantly and you can then copy it in one click. Values are stored only in your browser.
Do I need experience to use it?
It is advanced: it is meant for people with experience in the topic who can evaluate and adjust the result.
Is this prompt free?
Yes. Every HomeCasa Prompts prompt is free, with no sign-up or subscription. You can also use them in professional projects.
Can I trust the AI output?
Treat it as a high-quality draft: always check data, figures and important claims before publishing or making decisions.