← Java / Spring · Contents

JAVA-090 / Intermediate

Mixing CSRF tokens with state-changing GET requests

A01:2021 · CWE-352 CSRF

Why is this a problem?

A state-changing GET such as /users/delete?id= can execute through an image tag.

How to fix it

java
@DeleteMapping("/users/{id}") void del(@PathVariable Long id) { ... }   // With a CSRF token

Further reading