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
0
votes
1 answer

Implementing CSRF protection using a session token

I was trying to implement CSRF Protection in my new Project. I did the same using creating a session token for every form and the token is stored in a hidden field in the form. Every time the form gets submitted, i check whether the token in the…
g4GG
  • 11
  • 5
0
votes
1 answer

How does this save my form from csrf attack?

I have this form
//code
Token is unique for every user. Now suppose attacker is logged in and open this page. Now he knows what current session token is , by…
Ace
  • 841
  • 9
  • 23
0
votes
2 answers

CSRF protection for file upload posts

I have an angularJS application in which I use Angular's CSRF protection mechanism for all POST, PUT and other nonsafe web service calls. It works well except for one case: a multipart/form-data POST which uploads a file to the server. In this case,…
Paul Taylor
  • 5,651
  • 5
  • 44
  • 68
0
votes
1 answer

csrf_protection false option doesn't work while form creation

i followed this example to disable csrf protection on form generated in my actionController: http://www.craftitonline.com/2011/08/symfony-2-how-to-disable-csrf-on-a-per-form-basis/ So i have this action: public function contactAction(Request…
MeursaultF
  • 209
  • 1
  • 9
  • 20
0
votes
3 answers

How do I handle CRSF tokens for login pages?

I've recently run into an interesting problem with login pages and CSRF tokens. I want to ensure the login form POST is secured with a CSRF token, however, when/if a user remains on the login page for an extended period of time his/her session will…
Vincent Catalano
  • 2,259
  • 4
  • 22
  • 29
0
votes
1 answer

CSRF PHP Prevention Mechanism

I have read many articles about CSRF, almost all of them have the same solution which is hidden tokens, so i wrote a code to prevent CSRF and i tried hacking my own page afterwards but it didn't work, i would like to know if my code is CSRF…
0
votes
1 answer

When is this Rack::Protection::FormToken a security issue?

The header comment for Rack::Protection::FormToken says: # This middleware is not used when using the Rack::Protection collection, # since it might be a security issue, depending on your application Can anyone describe an example of when this…
dgo.a
  • 2,634
  • 23
  • 35
0
votes
1 answer

Zend framework 2 - csrf regenerates on refresh

I am having a problem with the Zend Framework 2 formElement csrf. It works fine until I submit an invalid form, hit the same page then refresh the page. A "notTheSame" validation error occurs on the field and the message "The form submitted did not…
user2299243
  • 63
  • 2
  • 8
0
votes
0 answers

Symfony 1.4 CSRF TOKEN protection for AJAX forms

I have an AJAX form that I wish to be protected with the CSRF TOKEN on submit. My question is, How do I validate it in my action? I can successfully send it over via my AJAX call but the problem is validating it on my action. I know that …
kevin
  • 315
  • 4
  • 12
0
votes
1 answer

CodeIgniter not setting csrf cookie with Nginx

I'm using nginx and I can't login to the admin panel. It's using https so that may be a part of it. Here are the relevant portions of my nginx.conf server { listen 80; listen 443 ssl; ssl_certificate /ssl.crt; ssl_certificate_key…
Shamoon
  • 41,293
  • 91
  • 306
  • 570
0
votes
2 answers

Web Form BOT Protection transparent to user

I was thinking a lot for last few days on how to protect the web form that Bots uses. The usage is kindly abuse, around 800k bot's queries in ~8hours. Let's take a quick situation overview, any missing info - please ask for. The bot: The bot have…
Valentin Rusk
  • 630
  • 5
  • 13
0
votes
2 answers

Zend Framework 2 - CSRF Token Server-side validation

I've got the following issue on my mind: I built some kind of generic fieldset which I want to use in all my standard forms. It contains a CSRF-Token and a Submit-Button. It works great on the client side. But I wonder: If I use this…
Ron
  • 22,128
  • 31
  • 108
  • 206
0
votes
1 answer

CSRF Protection: Methods to send CSRF token for each request

My initial code generated tokens for the requests that could alter state of my database, like CRUD operations. The token was generated for each request. Sent to client side in JSON-format along with other data and I expected this token to be…
Mono Jamoon
  • 4,437
  • 17
  • 42
  • 64
0
votes
2 answers

If your site doesn't use cookies do you still need to worry about CSRF protection?

I have been reading up on CSRF/XSRF a bit and a lot of it seems to talk about cookies as they can be involved in logging the user back in automatically. So I was just wondering if your site doesn't use cookies, do you still need to worry about using…
Brett
  • 19,449
  • 54
  • 157
  • 290
0
votes
1 answer

Is there a way to log that someone has made a CSRF attack to a web-application

I understand how CSRF works, why it works & how to mitigate it. now, I have a web-application, its vulnerable to CSRF, I want to know if someone has successfully made a CSRF attack on my web-app. Is there a way to log it if there's CSRF Thanks…
suzee
  • 29
  • 1
  • 3