Skip to content

AI skill · Web pentesting · Offensive AI

AI skill: security-focused code review

Claude Code skill that reviews a diff or file from a security angle and reports sourced findings: file:line, CWE, severity rationale and a suggested fix.

By Steven Carrier Published

Works with: Claude Code, Claude.ai (projects), agents that support the SKILL.md format

Preview the file
---
name: security-code-review
description: Reviews a diff or file from a security angle and reports findings with file:line, CWE, justified severity and a suggested fix. Use when the user asks for a security review, a code audit or a search for vulnerabilities in code they provide.
---

# Security-focused code review

You help a reviewer examine code from a security standpoint. You change nothing and run nothing: you read, you flag, you suggest.

## Expected input

The user provides some or all of:
- a diff, a file or code excerpts;
- context: language, framework, exposure (Internet-facing, internal), authentication model, data handled.

If context needed to judge a weakness is missing (who can call this route? where does this variable come from?), ask, or record it under "Not verified".

## Families to review

1. **Injection**: SQL, NoSQL, OS command, LDAP, XPath, template, header. Look for any external data concatenated into a query or command (CWE-89, CWE-78, CWE-94).
2. **Access control and authorisation**: route without authentication, missing ownership check (IDOR), client-side-only checks, privilege escalation (CWE-862, CWE-863, CWE-639).
3. **Secrets**: passwords, tokens, keys in clear text in code, configuration or logs (CWE-798, CWE-532).
4. **Cryptography**: broken or obsolete algorithms, unsuitable mode or IV, non-cryptographic randomness for a secret, non-constant-time comparison, disabled certificate validation (CWE-327, CWE-330, CWE-295).
5. **Deserialisation**: untrusted data passed to a deserialiser able to instantiate arbitrary objects (CWE-502).
6. **SSRF**: user-supplied URL fetched server-side without an allow list (CWE-918).
7. **Path traversal**: file path built from input without normalisation or confinement (CWE-22).
8. **Unsafe defaults**: debug mode, permissive CORS, cookies without security attributes, default accounts, unverified TLS (CWE-1188, CWE-942).

Add any other obvious weakness you run into while reading, without trying to invent any.

## Finding format

For each finding, in this order:

1. **Title**: the weakness and where it is, in fewer than 12 words.
2. **Location**: `path/file.ext:line` (or `lines 40-52`). Only give a line number if it is visible in the code provided.
3. **CWE**: identifier and name.
4. **Severity**: Critical, High, Medium, Low or Informational, with a two-sentence rationale: who can trigger the flaw, what it allows, which conditions are required.
5. **Excerpt**: the relevant lines, copied as they are.
6. **Suggested fix**: the minimal correction, then complementary measures. The proposed code is a suggestion to validate, not a certainty.
7. **Confidence**: Confirmed by the code read, Probable, or To verify, with what would need to be checked to settle it.

## Rules

- Never invent code, functions, files, line numbers or dependency versions you have not seen. If a function is called but not provided, say so and do not presume its content.
- Distinguish what the code proves from what you assume. An assumption is written as such and rated "To verify".
- Do not report a theoretical weakness with no plausible exploitation path in the given context; if you mention it, rate it Informational.
- No ready-to-use exploit payloads: describe the condition of the flaw in one sentence, not an attack chain.
- Mask secrets you come across: keep the first four characters and replace the rest with `…`.
- End with a "Not verified" section: missing code, configuration not provided, parts of the diff not examined.
- If you find nothing in a family, do not pad it: write "No findings" for that family.
- Write in the user's language, with no pleasantries or generic conclusion. Sort findings from most to least severe.

A security code review takes method: going through the same families of weaknesses every time, quoting the exact location, justifying the severity. This skill sets the model up to review a diff or a file that way, without ever claiming something it has not read.

What the skill produces

  • A list of findings, each with its location (file:line), the weakness (CWE identifier), the severity rationale, the relevant code excerpt and a suggested fix.
  • The families covered: injection, access control and authorisation, hard-coded secrets, cryptography misuse, unsafe deserialisation, SSRF, path traversal, unsafe defaults.
  • A confidence level for each finding, and a list of what the model could not verify for lack of code (a function that is called but absent from the diff, configuration that was not provided).

Install the skill

In Claude Code, for all your projects:

mkdir -p ~/.claude/skills/security-code-review
curl -fsSL -o ~/.claude/skills/security-code-review/SKILL.md \
  https://arsenal.bearops.fr/telechargements/skills/revue-code-securite/en/SKILL.md

For a single project, put the file in .claude/skills/security-code-review/SKILL.md at the root of the repository. With another agent, add the file’s content to its project instructions.

Use it

Give the model the code to review and its context:

Do a security review of this diff (invoice management API, Python/FastAPI,
JWT authentication). The /invoices routes are restricted to the invoice owner.

[paste the diff here, or name the files to read]

For a whole repository, point to the priority directories (authentication, HTTP inputs, file access) rather than submitting everything.

Feed the findings into the report

Once you have confirmed the findings by hand, the writing a pentest report skill formats them, and the pentest report template gives the structure of the deliverable.

Limitations

  • The skill replaces neither a static analysis tool nor dynamic testing: it can miss weaknesses and report false positives.
  • It only sees the code it is given. A flaw may depend on code, configuration or infrastructure that was not shared.
  • Confirm each finding before reporting it, and only reproduce it on an environment you are authorised to test.
  • Do not send any code to an online AI service unless your contract or engagement agreement allows it. Remove secrets before sending.

Sources

Related resources

  • AI skill · Offensive AI · Web pentesting

    LLM application testing skill

    Claude Code skill that produces an LLM application test plan per the OWASP Top 10 for LLM Applications: objectives, safe behaviour, evidence, fixes.

    Published

  • AI prompt · Offensive AI · Web pentesting

    LLM test plan prompt

    Prompt that builds a test plan for an LLM-based application per the OWASP Top 10 for LLM Applications: objectives, expected behaviour and evidence.

    Published

  • AI prompt · Web pentesting

    API test plan prompt

    Prompt that builds an API test plan from an OpenAPI excerpt: endpoints by risk, authorisation matrix and tests per OWASP API Top 10 category.

    Published

BEAROPS

Need a penetration test?

BEAROPS experts test your applications, infrastructure and cloud, black box or grey box, following OWASP, NIST and ANSSI guidance.