agentleFS
jaskirat1616jaskirat1616/grok-skills/skills/secure-code-review/SKILL.md

secure-code-review

Skill22 starsChanged 3 months agoMITView on GitHub

Performs a security-focused review of code or a diff, hunting for injection, broken authentication/authorization, insecure crypto, hardcoded secrets, unsafe deserialization, SSRF, path traversal, and missing input validation, with exploit scenarios and concrete fixes ranked by severity. Use this skill when the user asks to "do a security review", "audit this code for vulnerabilities", "is this code secure", "check for security issues before deploy", "review this auth/crypto code", or wants a security pass on a PR. Complements general code review with a threat-focused lens.

  • Deletes or force-pushes

16 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use threat-modeling and incident-response.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • msewellSkill

    threat-modeling

    Produces structured threat models for software systems using STRIDE on data flow diagrams. Generates DFDs with trust boundaries, identifies threats per element, scores risks, and defines concrete mitigations. Outputs a complete threat model Markdown document through phased, interactive delivery. Use when threat modeling a system, analyzing security threats, identifying attack surfaces, performing STRIDE analysis, assessing security risks in architecture, creating a threat model document, or when the user mentions threat model, attack surface, trust boundaries, STRIDE, or security risk analysis.

    Also in 3 projects that use this

  • AnthropicSkill

    incident-response

    Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Trace tainted data to sinks: Follow each untrusted input to dangerous sinks (SQL, shell, file paths, HTML output, deserializers, redirects, …

    line 18
  2. Distinctive:

    If uncertain it's exploitable, mark "Possible:" and state what would confirm it.

    line 32
  3. Distinctive:

    Fix: use a parameterized query:

    line 43
  4. Distinctive:

    Prefer parameterized queries / prepared statements over string building everywhere.

    line 50
  5. Very specific:

    Use vetted libraries for crypto and auth — never hand-roll.

    line 52
  6. Distinctive:

    Keep secrets in a vault/KMS or env, never in source.

    line 54
  7. Distinctive:

    Add a regression test for each fixed vuln.

    line 55

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Secure Code Review

Overview

Review code through the eyes of an attacker. For each finding, name the vulnerability class, show how it's exploited, rate severity, and give a concrete fix. Scope to the diff/files provided; pull in just enough surrounding code (callers, trust boundaries) to judge exploitability.

Keywords: security review, secure code review, vulnerability, OWASP, injection, SQLi, XSS, command injection, authentication, authorization, IDOR, broken access control, crypto, secrets, hardcoded credentials, deserialization, SSRF, path traversal, input validation, CSRF.

Workflow

  1. Map trust boundaries. Identify where untrusted data enters: HTTP params/body/headers, file uploads, env, message queues, DB rows from other tenants, third-party APIs. Untrusted input is where most bugs live.
  2. Trace tainted data to sinks. Follow each untrusted input to dangerous sinks (SQL, shell, file paths, HTML output, deserializers, redirects, template engines). A flow from source → sink without sanitization is a finding.
  3. Review each vulnerability class using references/vuln-patterns.md: injection, broken access control/authz, auth & session, crypto, secrets, deserialization, SSRF, path traversal, CSRF, security misconfig, sensitive-data exposure.
  4. Check authorization on every sensitive operation. Authentication ≠ authorization. Confirm object-level checks (does this user own this record?) to catch IDOR / broken access control.
  5. Scan for low-hanging fruit with scripts/secret_scan.py (hardcoded secrets, dangerous function calls). Triage hits — it's a starting point, not proof.
  6. Rate severity (Critical/High/Medium/Low) by exploitability × impact, using references/checklist.md.
  7. Write findings with: class, file:line, exploit scenario, severity, and a concrete fix (prefer a diff). End with a verdict and a prioritized fix list.

Decision Heuristics

  • Assume all external input is hostile until validated/escaped at the sink.
  • Escape at the sink, validate at the boundary — parameterized queries beat input filtering.
  • Deny by default for access control; explicit allow per resource and action.
  • Never trust client-side checks — they're UX, not security.
  • Secrets in code = Critical, even in tests or comments, because of git history.
  • If uncertain it's exploitable, mark "Possible:" and state what would confirm it.

Worked Example

# src/api/users.py:88  — VULNERABLE
query = f"SELECT * FROM users WHERE email = '{email}'"
db.execute(query)

Finding — [Critical] SQL Injection — src/api/users.py:88 An attacker submitting email=' OR '1'='1 reads all rows; '; DROP TABLE users;-- can destroy data. Fix: use a parameterized query:

db.execute("SELECT * FROM users WHERE email = %s", (email,))

Best Practices

  • Prefer parameterized queries / prepared statements over string building everywhere.
  • Context-aware output encoding for XSS (HTML, attribute, JS, URL contexts differ).
  • Use vetted libraries for crypto and auth — never hand-roll. Use hmac.compare_digest for secret comparison.
  • Allow-list inputs (paths, redirect targets, file types) rather than block-listing.
  • Keep secrets in a vault/KMS or env, never in source; rotate anything that leaked.
  • Add a regression test for each fixed vuln.

Common Pitfalls

  • Treating authentication as authorization — logged-in users still need per-object checks (IDOR).
  • Block-list validation that attackers trivially bypass; prefer allow-lists and escaping at the sink.
  • Custom crypto (homemade tokens, ECB mode, static IVs, MD5/SHA1 for passwords).
  • eval/pickle/yaml.load/native deserialization on untrusted data → RCE.
  • Verbose error messages / stack traces leaking internals to users.
  • Reflected user input into HTML, headers, or redirects without encoding/allow-listing.
  • Reviewing only the happy path — vulns hide in error handlers and edge cases.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.