security-review-owasp-cross-site-request-forgery-prevention

Review code and configurations for cross-site request forgery weaknesses.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/sjinks/ai-owasp-skillset --skill security-review-owasp-cross-site-request-forgery-prevention
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: security-review-owasp-cross-site-request-forgery-prevention
Source: https://github.com/sjinks/ai-owasp-skillset/tree/main/.github/skills/security-review-owasp-cross-site-request-forgery-prevention
Command: npx skills add https://github.com/sjinks/ai-owasp-skillset --skill security-review-owasp-cross-site-request-forgery-prevention

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps reviewers find cross-site request forgery weaknesses in authenticated workflows before attackers can abuse them to trigger unwanted state changes.

Core Features & Use Cases

  • Token and Session Review: Checks synchronizer tokens, double-submit cookie patterns, session binding, and token validation coverage.
  • Browser-Signal Validation: Evaluates SameSite cookies, Origin and Referer checks, and Fetch Metadata enforcement for sensitive endpoints.
  • API and Client-Side Protection: Reviews AJAX requests, CORS exposure, custom headers, login flows, and client-side request construction for CSRF bypasses.
  • Use Case: A reviewer can inspect a checkout flow, admin action, or webhook receiver and determine whether it can be triggered cross-site without trustworthy request-origin proof.

Quick Start

Use the security-review-owasp-cross-site-request-forgery-prevention skill to inspect the selected flow or files and report any confirmed CSRF weaknesses with evidence.

Frequently Asked Questions about security-review-owasp-cross-site-request-forgery-prevention

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review code for CSRF vulnerabilities in authenticated workflows?

To review code for CSRF vulnerabilities, inspect token generation, session binding, and validation coverage across form posts and AJAX requests. Evaluate SameSite cookies, Origin and Referer checks, and Fetch Metadata enforcement to confirm whether state-changing endpoints require trustworthy request-origin proof.

What is the best way to check if SameSite cookies and Origin validation prevent CSRF attacks?

Checking SameSite cookies and Origin validation involves evaluating browser-signal enforcement on sensitive endpoints. Review SameSite policy attributes, verify Origin and Referer headers against trusted domains, and test Fetch Metadata headers to ensure untrusted cross-site requests are blocked before state changes occur.

How does CSRF token validation work for AJAX requests and APIs?

CSRF token validation for AJAX requests and APIs works by requiring synchronizer tokens or custom headers for state-changing operations. Review CORS exposure, client-side request construction, and double-submit cookie patterns to ensure attackers cannot forge authenticated API calls from external domains.

Can I use Fetch Metadata headers to protect login flows from CSRF bypasses?

You can use Fetch Metadata headers to protect login flows by enforcing strict Sec-Fetch-Site, Sec-Fetch-Mode, and Sec-Fetch-Dest values. Combine Fetch Metadata enforcement with Origin checks and SameSite cookies to prevent cross-site requests from bypassing CSRF protections on authentication endpoints.

When do I need to review CORS settings for CSRF weaknesses?

Review CORS settings for CSRF weaknesses whenever APIs or AJAX endpoints accept authenticated state-changing requests. Check whether permissive Access-Control-Allow-Origin headers expose sensitive endpoints to cross-origin requests, and verify that custom header requirements and Origin validation prevent unauthorized cross-site access.

Why does my CSRF token validation fail to protect webhook receivers?

CSRF token validation may fail for webhook receivers when endpoints lack Origin or Referer verification and accept unauthenticated state changes. Review whether synchronizer tokens or double-submit cookies apply to webhook flows, and enforce Fetch Metadata or trusted-IP restrictions to prevent forged cross-site requests.