3 ms·
> I wonder if the same attack can be used on other sites or if it exploits something about Github. It doesn't exploit anything GitHub-specific! The way it's d
by TazeTSchnitzel 12y ago
> I wonder if the same attack can be used on other sites or if it exploits something about Github.
It doesn't exploit anything GitHub-specific! The way it's done is applicable to any site. The reason is that it uses the <script> loophole around the Same Origin Policy (<script> can be loaded cross-domain, thanks Eich...). They basically just inject this every two seconds:
<script src="http://github.com/greatfire/"></script>
The browser will request that page expecting a script. And it'll get HTML, but that's not valid JS and just ignore it, but the DDOS is successful.
However, this also makes all sites with the malicious JS vulnerable to an XSS attack by GitHub, like GitHub is currently doing. If you visit that URL, you get this:
alert("WARNING: malicious javascript detected on this domain")
Though I think the same trick could be done with, say, <img> or <style>, and those wouldn't allow XSS (though <style> could fuck with the page, certainly). Sloppy coding, Chinese Government employee...
- jfroma 12y agoI was wondering if you can prevent this by looking at the "Accept" header in the request but it seems accept is "/" for scripts. I'd expect the browsers rather to send "application/javascript". Then the answer from my server will be 400 because I don't have a javascript representation of this url.
- TazeTSchnitzel 12y agoWell, you're still spammed with requests.
- jfroma 12y agoYes, but it is not the same if I can reply with 400 directly without further inspection. I imagine github can do this at the reverse proxy level, instead of doing 20 queries to mysql and overload the ruby application.
- TazeTSchnitzel 12y agoWell, GitHub is already returning a special response for those URLs.
- myth_buster 12y ago> They basically just inject this every two seconds: Isn't that the difficult part, ie. to intercept a request to a server and inject malicious code. In this case as all request goes through the great firewall, the hack was trivial. The retaliation from GitHub is quite clever although not great for the user or Baidu.
- TazeTSchnitzel 12y ago> Isn't that the difficult part, ie. to intercept a request to a server and inject malicious code. Um, sure. But that's not GitHub-specific, which is what they were asking about...
- laumars 12y ago> Though I think the same trick could be done with, say, <img> or <style>, and those wouldn't allow XSS You can XSS with SVG "images" [1]. Though up-to-date browsers should be patched against this. The other option is having an image which said the same as the alert() message. Again, using SVG, this needn't be much bigger file size than the JS response [2] [1] https://www.owasp.org/images/0/03/Mario_Heiderich_OWASP_Sweden_The_image_that_called_me.pdf https://www.owasp.org/images/0/03/Mario_Heiderich_OWASP_Swed... [2] http://www.w3schools.com/svg/svg_text.asp http://www.w3schools.com/svg/svg_text.asp
- TazeTSchnitzel 12y agoThe image would definitely be user-visible.
- laumars 12y agoSadly you can't guarantee that. If it was an advert, then yes, most likely it would be visible (baring ad blockers, but then they should hopefully block the attack anyway so that's a non-issue). But if it was a tracking image, then the dimensions would likely only be 1px^2. I use those two specific examples (ad and tracking) because that seems to be the two instances in which this JS was MITM'ed.