-
-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add json prefix to prevent script tag csrf attack #76
Comments
Seems a good addition. |
The issue is that your return value is not JSON anymore. So if you put the prefix, you have to change the content-type of your response to avoid lying, and client code must be aware that the prefix needs to be stripped to retrieve the JSON. So a JSON visitor should not do it by default. FYI, the PR implementing it for Symfony uses |
Thus, if you always return an object in your response rather than an array, you are not affected by the vulnerability, as mentionned in the blog post. |
I think this is outside the scope of the serializer. |
According to http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx it is possible to attack a json response by transforming it into jsonp.
Adding a prefix like suggested in http://docs.angularjs.org/api/ng.$http (JSON Vulnerability Protection).
I did it in my fork 3d73cf6 in the class serializer, but maybe it would be good to do it in the JsonSerializationVisitor.
The text was updated successfully, but these errors were encountered: