Recent Facebook XSS Attacks Show Increasing Sophistication
theharmonyguy.com
theharmonyguy.com
It would be great if Facebook had a security research group that openly published the results of their findings, those findings that don't expose corporate secrets. They almost certainly have seen it "all."
parse_url(" javascript:alert('hello')") yields
Array
(
[path] => javascript:alert('hello')
)
which clearly does not have an URL scheme on any whitelist you might apply. Even if it had incorrectly claimed the scheme was "http", the reconstitution step would give you an URL like "http://localhost/%20javascript:alert(hello), which would avoid the problem.1. Use an unique CSRF hidden field in the form that only users on Facebook can get and so it's them that can submit posts to their wall. (More: https://secure.wikimedia.org/wikipedia/en/wiki/Cross-site_re... )
2. Regarding video; Don't allow Javascript code to be submitted and presented anywhere. The code to link to videos is unescaped javascript (with space) followed by a video link.
If you HAD to draw a lesson here, I'd go with something more along the lines of
Even if you protect your site properly against clickjacking and CSRF, an XSS vulnerability allows an attacker to bypass all of those protections.
"According to Facebook, it turned out that some older code was using PHP's built-in parse_url function to determine allowable URLs. For example, while parse_url("javascript:alert(1)") yields a scheme of "javascript" and a path of "alert(1)", adding whitespace gives a different result: parse_url(" javascript:alert(1)") does not return a scheme and has a path of "javascript:alert(1)"."
This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly. "
http://au2.php.net/manual/en/function.parse-url.php
It seems like parse_url is not designed for filtering javascript. Since it came out in front-end, it seems that Facebook initially accepted the embedded javascript in the link.
One of the main problems is mixing code and data. Say there's a new HTTP header that tells the browser to disable inline scripts, would that help solve the problem?