Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are both csrf tokens and captcha needed?

Can someone confirm this: do I need to provide both a CSRF token and a Captcha in a submission form, or do the two more or less serve the same function (one can be used instead of the other)?

like image 804
jblue Avatar asked Sep 27 '10 18:09

jblue


People also ask

Does Captcha prevent CSRF?

CAPTCHA does not prevent cross-site request forgery (CSRF)

Are CSRF tokens necessary?

CSRF tokens prevent CSRF because without token, attacker cannot create a valid requests to the backend server. CSRF tokens should not be transmitted using cookies. The CSRF token can be added through hidden fields, headers, and can be used with forms, and AJAX calls.

Do you need CSRF token on login?

Yes. In general, you need to secure your login forms from CSRF attacks just as any other. Otherwise your site is vulnerable to a sort of "trusted domain phishing" attack. In short, a CSRF-vulnerable login page enables an attacker to share a user account with the victim.

Is CSRF token necessary for JWT?

If you put your JWTs in a header, you don't need to worry about CSRF. You do need to worry about XSS, however. If someone can abuse XSS to steal your JWT, this person is able to impersonate you.


2 Answers

A captcha can be used instead of a CSRF token. This is covered in the OWASP CSRF Prevention Guide. A Captcha is considered to be a stronger form of CSRF prevention than a token or referer check because it cannot be bypassed with XSS.

like image 128
rook Avatar answered Oct 02 '22 01:10

rook


The above suggests the answer is "no".

But in reading about CSRF tokens compared to CAPTCHA it's worth looking into this, which says:

"CAPTCHA does not prevent cross-site request forgery (CSRF)":

https://blog.detectify.com/2017/12/06/captcha-csrf/

like image 41
Steve Avatar answered Oct 02 '22 02:10

Steve