Questions tagged [csrf-protection]

Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.

Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF (sometimes pronounced sea-surf) or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser.

Web sites have various CSRF countermeasures available:

  • Requiring a secret, user-specific token in all form submissions and side-effect URLs prevents CSRF; the attacker's site cannot put the right token in its submissions. This technique is commonly referred to as the Synchronizer Token Pattern.
  • Requiring the client to provide authentication data in the same HTTP Request used to perform any operation with security implications (money transfer, etc.)
  • Limiting the lifetime of session cookies
  • Ensuring that there is no clientaccesspolicy.xml file granting unintended access to Silverlight controls
  • Ensuring that there is no crossdomain.xml file granting unintended access to Flash movies
  • Verifying that the request's header contains a X-Requested-With (used by Ruby on Rails before v2.0 and Django before v1.2.5), or checking the HTTP Referer header and/or HTTP Origin header. These protections have been proven insecure under a combination of browser plugins and redirects which can allow an attacker to provide custom HTTP headers on a request to any website, hence allowing a forged request.

Links:

712 questions
12
votes
3 answers

Simple CSRF protection using nginx alone

I have an nginx server serving plain HTML and JS files. The js code then calls various REST API to GET/POST data from API servers. If nginx receives a request for /api/ location, it forwards the request to another server which handles all the APIs. …
Anirudhan J
  • 2,072
  • 6
  • 27
  • 45
11
votes
2 answers

In what case can CSRF-exempt be dangerous?

This question is more a re-insurance than one directly about how to code. As an autodidact i did not have a lot of possibilities to ask professionals such things, so i try here. I have read the documents in the django-docs (…
marue
  • 5,588
  • 7
  • 37
  • 65
11
votes
2 answers

CSRF - Is it safe to ask it with api call?

I'm using session based CSRF on a site using Angular. Is it safe to make an HTTP call to ask for the CSRF token? For example, if I sent a request with valid user session to a page called /csrf/get and it prints a raw token, is this secure enough…
Michalis
  • 6,686
  • 13
  • 52
  • 78
11
votes
2 answers

Protecting against CSRF attacks in Aurelia

In Aurelia, there doesn't seem to be any support for CSRF protection yet, as opposed to AngularJS's XSRF-TOKEN header which is set automatically on all XHR requests by the AngularJS framework. How should I go about protecting an Aurelia app from…
Svein Fidjestøl
  • 3,106
  • 2
  • 24
  • 40
10
votes
1 answer

CSRF Protection with HTTP GET requests in Rails

I understand that Rails by default doesn't have CSRF protection for HTTP GET requests, because, it claims they are idempotent. However, there is sensitive information that is returned to the user from these GET requests, and, I would't want a…
10
votes
1 answer

Using a session token or nonce for Cross-site Request Forgery Protection (CSRF)?

I inherited some code that was recently attacked where the attacker sent repeated remote form submissions. I implemented a prevention using a session auth token that I create for each user (not the session id). While I realize this specific attack…
Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
10
votes
1 answer

EXTJS CSRF protection

I am trying to implement protection in one app against CSRF. In PHP it is relatively simple to implement. I have many questions about how to do it with Extjs. The EXTJS books I read do not address the subject and I can not find concrete guidance on…
jose
  • 1,490
  • 3
  • 30
  • 65
10
votes
4 answers

Express CSRF token validation

I'm having issues with CSRF tokens. When I submit a form, a new XSRF-TOKEN is being generated but I think I'm generating two different tokens, I'm kinda confused. There's also a token called _csrf, so I see two different cookies in developer tools…
salep
  • 1,332
  • 9
  • 44
  • 93
10
votes
2 answers

Does an anonymous comment/post form need csrf token? If not why does SO use it and how to implement it?

There are some discussing like this on SO claiming that csrf protection is not required for anonymous forms. Looking at the stackoverflow html code, when not logged in, you can see the csrf token being set for he answer box when posting as an…
ali
  • 531
  • 5
  • 22
10
votes
2 answers

Session timeout leads to Access Denied in Spring MVC when CSRF integration with Spring Security

I have Integrated CSRF token with Spring Security in my Spring MVC Project. Everything work properly with CSRF token, token will be send from client side to server side. I have changed my logout process to make it POST method to send CSRF token…
Yagnesh Agola
  • 4,556
  • 6
  • 37
  • 50
9
votes
1 answer

CSRF protection question

I'm currently in the process of implementing CSRF protection into my framework (PHP). However I am wondering: Wouldn't it be possible for an attacker to load my page in a (hidden) iframe (obtaining the token) and change some data using…
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
9
votes
2 answers

WordPress CSRF Exploit Draft Status

How can I best secure WP against a CSRF exploit when creating a new post draft? If I add a new post and save as draft, I can intercept the request using Burp Suite. Using the engagement tool in Burp Suite, I can change the value of the post title…
wbdlc
  • 1,070
  • 1
  • 12
  • 34
9
votes
3 answers

ValidateAntiForgeryToken in WebForms Application

I have done some reading about the use of ValidateAntiForgeryToken to prevent XSRF/CSRF attacks. However what I have seen seems to relate only to MVC. These are the articles I've seen: ValidateAntiForgeryToken purpose, explanation and example CSRF…
Dov Miller
  • 1,958
  • 5
  • 34
  • 46
9
votes
1 answer

Different csrf token per request in Spring security

I am using tag in my spring security xml file for a web project. And sending csrf token in a form:
But on intercepting the…
Shailesh Yadav
  • 1,061
  • 1
  • 15
  • 30
9
votes
4 answers

Laravel 5 and Internet Explorer : Token Mismatch

My Laravel5 website uses csrf tokens to prevent CSRF attacks. On Chrome and Firefox, eveything works fine. I submitted the site for my client to test and, when he uses Internet Explorer (9/10), he has "Token mismatch" errors on evey page using the…
Didier Sampaolo
  • 2,566
  • 4
  • 24
  • 34
1 2
3
47 48