Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT RPC - Does it do enough to protect against CSRF?

UPDATE : GWT 2.3 introduces a better mechanism to fight XSRF attacks. See http://code.google.com/webtoolkit/doc/latest/DevGuideSecurityRpcXsrf.html


GWT's RPC mechanism does the following things on every HTTP Request -

  1. Sets two custom request headers - X-GWT-Permutation and X-GWT-Module-Base
  2. Sets the content-type as text/x-gwt-rpc; charset=utf-8

The HTTP request is always a POST, and on server side GET methods throw an exception (method not supported).

Also, if these headers are not set or have the wrong value, the server fails processing with an exception "possibly CSRF?" or something to that effect.

Question is : Is this sufficient to prevent CSRF? Is there a way to set custom headers and change content type in a pure cross-site request forgery method?

like image 903
Sripathi Krishnan Avatar asked Apr 09 '10 18:04

Sripathi Krishnan


People also ask

Is CSRF possible on GET request?

CSRF GET RequestThe simplest CSRF attack is simply to trick a user into making a GET request to a specific URL. This can done by putting the URL into a deceptively named link. The link could be put in a blog comment (lots of WordPress exploits have used this technique), a post on a web forum, or in a phishing email.

What is the best Defence against CSRF?

The most effective method of protecting against CSRF is by using anti-CSRF tokens. The developer should add such tokens to all forms that allow users to perform any state-changing operations.

Is CORS enough to prevent CSRF?

In the case of GET requests, it prevents JavaScript to read the response data. This also applies in the case when page B is embedded as an <iframe> on the page A. Cross-Origin Resource Sharing (CORS) is not a CSRF prevention mechanism.

What methods prevent cross site request forgery attacks?

To prevent CSRF attacks, use anti-forgery tokens with any authentication protocol where the browser silently sends credentials after the user logs in. This includes cookie-based authentication protocols, such as forms authentication, as well as protocols such as Basic and Digest authentication.


2 Answers

If this GWT RPC is being used by a browser then it is 100% vulnerable to CSRF. The content-type can be set in the html <form> element. X-GWT-Permutation and X-GWT-Module-Base are not on Flash's black list of banned headers. Thus it is possible to conduct a CSRF attack using flash. The only header element you can trust for CSRF protection is the "referer", but this isn't always the best approach. Use token based CSRF protection whenever possible.

Here are some exploits that i have written which should shed some light on the obscure attack i am describing. A flash exploit for this will look something like this and here is a js/html exploit that changes the content-type.

My exploit was written for Flex 3.2 and the rules have changed in Flex 4 (Flash 10) Here are the latest rules, most headers can be manipulated for requests POST only.

Flash script that uses navigateTo() for CSRF: https://github.com/TheRook/CSRF-Request-Builder

like image 62
rook Avatar answered Oct 20 '22 16:10

rook


GWT 2.3 introduces a better mechanism to fight XSRF attacks. See GWT RPC XSRF protection

like image 23
rjrjr Avatar answered Oct 20 '22 17:10

rjrjr