How to protect against CSRF

GURKE

How can I protect my website against Cross-Site Request Forgery attack? I am visiting a "normal" website. (f.e. normal.php) In the background it loads another website (f.e. victim.php/send_comment) where I'm already logged in. The website fills the comment boxes of the victim.php with JS and automatically send the request.

In the web I always find the trick to use tokens against CSRF. But in this example, the website normal.php will get the token, when it loads the other website. Am I misunderstanding how the token works? If not, how can i prevent my site from accepting this request?

goncalopp

The whole idea of CSRF is that you can't get victim.php/send_comment without a token from a previous page you've visited.

You form a "chain" of requests from your initial login until you get there, where each request is authorized by the previous one - unless you intercept the login page, there should be no way to forge requests.

The easiest and safest way of doing this is just using a web framework that handles CSRF for you. Doing it by hand is probably unnecessary and error-prone.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Where to store JWT in browser? How to protect against CSRF?

From Dev

How to protect against CSRF when using Backbone.js to post data?

From Dev

How to protect against this type of attack?

From Dev

How to protect session against theft?

From Dev

How to protect against data leak?

From Dev

How does SSL protect the data against sniffing?

From Dev

How to protect against spoofed access point?

From Dev

How to protect against changing mail server AS IS?

From Dev

C++ How to protect against invalid input?

From Dev

Protect an old web application against CSRF without adding hidden input in all forms

From Dev

Protect against CSRF attacks in ASP.NET Web Forms without Master Pages

From Dev

How to protect request url against going upper in NodeJS?

From Dev

Is XSS possible via an @import, and if so how? Are there ways to protect against it?

From Dev

How to modify the supported ciphers in yaws.conf to protect against poodlebleed

From Dev

How to protect against Redis::TimeoutError: Connection timed out on Heroku

From Dev

How does OAuth 2.0 protect against compromised accounts?

From Dev

Java and XSS: How to html escape a JSON string to protect against XSS?

From Dev

How does fail2ban protect against DDoS?

From Dev

How to modify the supported ciphers in yaws.conf to protect against poodlebleed

From Dev

Is a package specific to a Linux distribution? How to protect against KRACK

From Dev

How can I protect against single user mode

From Dev

How to protect libgdx function fromJson against bad input?

From Dev

Protect Website Against Piracy

From Dev

SameSite Flag against CSRF

From Dev

Prevention against CSRF?

From Java

Protect against password cracking in Windows

From Java

How does OAuth 2 protect against things like replay attacks using the Security Token?

From Dev

How to protect the python interpreter against termination when a called module/program issues sys.exit()

From Dev

How to protect against distributed denial-of-service attacks in Node.js with Socket.io?

Related Related

  1. 1

    Where to store JWT in browser? How to protect against CSRF?

  2. 2

    How to protect against CSRF when using Backbone.js to post data?

  3. 3

    How to protect against this type of attack?

  4. 4

    How to protect session against theft?

  5. 5

    How to protect against data leak?

  6. 6

    How does SSL protect the data against sniffing?

  7. 7

    How to protect against spoofed access point?

  8. 8

    How to protect against changing mail server AS IS?

  9. 9

    C++ How to protect against invalid input?

  10. 10

    Protect an old web application against CSRF without adding hidden input in all forms

  11. 11

    Protect against CSRF attacks in ASP.NET Web Forms without Master Pages

  12. 12

    How to protect request url against going upper in NodeJS?

  13. 13

    Is XSS possible via an @import, and if so how? Are there ways to protect against it?

  14. 14

    How to modify the supported ciphers in yaws.conf to protect against poodlebleed

  15. 15

    How to protect against Redis::TimeoutError: Connection timed out on Heroku

  16. 16

    How does OAuth 2.0 protect against compromised accounts?

  17. 17

    Java and XSS: How to html escape a JSON string to protect against XSS?

  18. 18

    How does fail2ban protect against DDoS?

  19. 19

    How to modify the supported ciphers in yaws.conf to protect against poodlebleed

  20. 20

    Is a package specific to a Linux distribution? How to protect against KRACK

  21. 21

    How can I protect against single user mode

  22. 22

    How to protect libgdx function fromJson against bad input?

  23. 23

    Protect Website Against Piracy

  24. 24

    SameSite Flag against CSRF

  25. 25

    Prevention against CSRF?

  26. 26

    Protect against password cracking in Windows

  27. 27

    How does OAuth 2 protect against things like replay attacks using the Security Token?

  28. 28

    How to protect the python interpreter against termination when a called module/program issues sys.exit()

  29. 29

    How to protect against distributed denial-of-service attacks in Node.js with Socket.io?

HotTag

Archive