← PHP / Laravel · Contents

PHP-006 / Beginner

Missing CSRF protection on state-changing routes

A01:2021 Broken Access Control · CWE-352 CSRF

Why is this a problem?

A logged-in user's browser automatically sends requests from an attacking site, causing actions such as password changes.

How to fix it

blade
<form method="POST" action="/password">@csrf ... </form>
php
// Add only the minimum external webhook paths to VerifyCsrfToken::$except

Further reading