-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prepend jsonp callbacks with a comment to prevent the rosetta-flash vulnerability #1766
Conversation
prepend jsonp callbacks with a comment to prevent the rosetta-flash vulnerability
@@ -1011,7 +1011,7 @@ describe('Response', function () { | |||
|
|||
server.inject('/?callback=me', function (res) { | |||
|
|||
expect(res.payload).to.equal('me({"some":"value"});'); | |||
expect(res.payload).to.equal('/**/me({"some":"value"});'); | |||
expect(res.headers['content-length']).to.equal(21); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON-P responses should also get an X-Content-Type-Options: nosniff
header, just in case. This would have prevented the Rosetta Flash vulnerability too, in modern browsers, and it might prevent similar attacks that bypass the /**/
-based protection in the future.
See https://gist.github.com/mathiasbynens/5547352 for an example in PHP (LOLWAT, I know).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That header can be added by setting
{
security: {
noSniff: true
}
}
in your server options.
Or with several other security related headers by just setting { security: true }
.
Just to remind people that this functionality does exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would make sense to enable this header by default for JSON-P responses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a while I think @hueniverse was debating enabling all of the security headers by default. I'm not sure how he feels about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll submit another PR and we can find out :]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
background
tl:dr - someone created a alphanum only swf converter, which means that they can in theory use it as a callback at a JSONP endpoint, and as a result, send data across domains.
Prepending callbacks with an empty inline comment breaks the flash parser, and prevents the issue. This is how google, facebook, github, et al are handeling it.
CVE-2014-4671A