OWASP CSRF Cheat sheet mentions the "User interaction based CSRF defense", which would also entirely mitigate a CSRF attack. I imagine that the reason OWASP considers it as a Defense-in-Depth (DiD) is because of the impact it has on UX.
I'm quite curious about the "One-time Token" implementation but fail to find any resource that goes more into detail here?
Personally, I would imagine that you generate a unique token for each critical action, associated with the user's specific session. The token can be sent to the user using different methods:
- via email
- as part of the API response to the initial request, which should then be submitted as an HTTP header value. Here, the user would then have to perform some interaction (e.g. Clicking a button) that would add the token to the header.
In both cases, attackers will be unable to read the valid token, preventing them from completing their attack. Specifically, with the "as part of the API response to the initial request", during a CSRF attack, an attacker can initiate requests, but not read their responses (thanks to SOP), which would be the key point here.