agentleFS
thejefflarsonthejefflarson/soundcheck/.claude/skills/csrf/SKILL.md

csrf

Skill20 starsChanged 4 months agoMITView on GitHub

Detects forms and state-changing endpoints missing CSRF protection. Use when

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use deserialization, ssti and 1 more.

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.
  • langbyyiSkill

    deserialization

    Insecure deserialization playbook. Use when Java, PHP, or Python applications deserialize untrusted data via ObjectInputStream, unserialize, pickle, or similar mechanisms that may lead to RCE, file access, or privilege escalation.

    Also in 3 projects that use this

  • SubhiSecSkill

    ssti

    Hunt Server-Side Template Injection (SSTI) in Jinja2, Twig, Freemarker, Velocity, Smarty, ERB, Handlebars, Mustache, and Spring (SpEL). Use when input is reflected in a way that suggests template rendering — error pages, email templates, PDF generators, dynamic content systems.

    Also in 3 projects that use this

  • SubhiSecSkill

    xss

    Hunt reflected, stored, and DOM-based Cross-Site Scripting (XSS) including CSP bypass, polyglot payloads, mutation XSS (mXSS), markdown XSS, and template XSS. Use when the user has identified a parameter or input that reflects to the page, or wants to test for XSS in a specific input.

    Also in 3 projects that use this

The file

Files
SKILL.md

Cross-Site Request Forgery Check (A01:2025)

What this checks

Protects against cross-site request forgery, where an attacker tricks an authenticated user's browser into submitting a state-changing request the user did not intend. Exploitation leads to unauthorized fund transfers, account takeover, or privilege escalation.

Vulnerable patterns

  • HTML form posting a state-changing request with no CSRF token hidden field
  • Framework CSRF protection explicitly disabled or exempted on a state-changing endpoint
  • Session cookie issued without a SameSite attribute (Lax or Strict)
  • Web app with no CSRF middleware registered for cookie-authenticated state-changing routes
  • Cookie-authenticated API endpoint accepting POST/PUT/PATCH/DELETE with no token check

Fix immediately

Flag the vulnerable code and explain the risk. Then suggest a fix that establishes these properties:

  1. Every state-changing endpoint (POST/PUT/PATCH/DELETE) validates a per-session or per-request CSRF token server-side before any mutation. Use the framework's documented CSRF middleware — do not roll your own.
  2. Framework CSRF protection is never disabled or exempted on a state-changing route. If a route legitimately needs to opt out (a pure JSON API authenticated by Authorization: Bearer headers, not cookies), the opt-out must be explicit and the cookie-auth path must remain protected.
  3. Session cookies carry SameSite=Lax at minimum, or SameSite=Strict for sensitive flows, plus Secure and HttpOnly. This blocks cross-origin cookie attachment on top-level navigations or subrequests that don't need it.
  4. CSRF tokens are not exposed in URLs, logs, or Referer headers — they live in a hidden form field or a dedicated request header, never in the query string.
  5. Forms include the token via the framework's template helper, so the token binds to the session and is rotated as the framework intends.

Translate these principles to the audited file's language and framework. Use the documented CSRF middleware and template helpers for that stack — do not hand-build token comparison logic.

Verification

Confirm the following properties hold (language-agnostic):

  • Every state-changing endpoint (POST/PUT/PATCH/DELETE) is protected by a CSRF token validated server-side
  • No framework CSRF middleware is disabled or bypassed on a cookie-authenticated state-changing route
  • Session cookies include SameSite=Lax or SameSite=Strict attribute
  • CSRF tokens are not leaked in URLs, logs, or Referer headers
  • API-only endpoints using token-based auth (Bearer header) may skip CSRF tokens, but cookie-authenticated endpoints must not

References

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.