I haven't tested it yet, but I believe you can extend
DefaultRequestTransport as discussed in this thread to set a request
header containing your session ID or other XSRF token:
HTH,
/dmc
> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/
Thanks for the info on X-GWT-Permutation. However, I want to make it
clear that the GWT team doesn't believe this is sufficient protection
against XSRF. The current implementation of RemoteServiceServlet
checks only for a non-null value.
protected void checkPermutationStrongName() throws SecurityException {
if (getPermutationStrongName() == null) {
throw new SecurityException(
"Blocked request without GWT permutation header (XSRF attack?)");
}
}
While the absence of X-GWT-Permutation header likely implies an
attack, this code is not intended to offer general protection against
XSRF.
The current GWT security guidelines[1] recommend the use of a token
passed with each request. In fact, there is new code[2] in trunk as of
last week to make this easier, and we're currently working on docs for
it.
[1] http://groups.google.com/group/google-web-toolkit/web/security-for-gwt-applications
[2] http://gwt-code-reviews.appspot.com/1107801/show
Regards,
/dmc
This is really interesting and I was not aware of that feature of modern browsers. Could you clarify how this works or link to a website explaining it? (In particular, I'm interested to know how a browser can prevent malicious javascript to insert this header in a request.)
Please note that the degree of flexibility offered by XMLHttpRequest, and not seen in other cross-domain content referencing schemes, may be actually used as a simple security mechanism: a check for a custom HTTP header may be carried out on server side to confirm that a cookie-authenticated request comes from JavaScript code that invoked XMLHttpRequest.setRequestHeader(), and hence must be triggered by same-origin content, as opposed to a random third-party site. This provides a coarse cross-site request forgery defense, although the mechanism may be potentially subverted by the incompatible same-origin logic within some plugin-based programming languages, as discussed later on.
--
Thanks for these links and explanation, really useful! So, to
summarize my understanding:
- Requests issued by forms do not allow you to add custom headers
- Javascript (XMLHttpRequest) cannot be used in an XSRF attack due to
same-origin-policy
- Therefore, if you exclude mechanisms based on faulty plugins (or old
browsers), there is no way for a 3rd party webpage to ping your webapp
while including custom headers.
As a result, if you assume:
1) Your user is running a modern browser
2) Your user doesn't have a faulty plugin
Then, the presence of a custom header is enough to guarantee that the
request was created with javascript and this originate from your page.
Did I get this right?
Philippe
Thanks for these links and explanation, really useful! So, to
summarize my understanding:
- Requests issued by forms do not allow you to add custom headers
- Javascript (XMLHttpRequest) cannot be used in an XSRF attack due to
same-origin-policy
- Therefore, if you exclude mechanisms based on faulty plugins (or old
browsers), there is no way for a 3rd party webpage to ping your webapp
while including custom headers.
As a result, if you assume:
1) Your user is running a modern browser
2) Your user doesn't have a faulty plugin
Then, the presence of a custom header is enough to guarantee that the
request was created with javascript and this originate from your page.
Did I get this right?
What's the current state of Request Factory and CSRF/XSRF for 2.5.1 version?
This post confuses me: http://stackoverflow.com/questions/6227436/preventing-csrf-when-using-gwts-requestfactory