Displaying referer links on blogs
Not a good idea without first cleaning them.. As I discovered today on another blog, way too easy to hijack via a javascript in the referer!
How is it done? Too easy..
<script>top.location.href='http://redirect_to_this_assholes_page';</script>
Edit: On second thought, this was probably targeting automatically-generated statistic pages... and a blog just got caught.. of course this is assuming someone didn't specifically target that blog but rather used a crawler.
Statistic pages makes more sense as hardly anyone ever visits their own and would likely not notice for a while, whereas with a busy blog it's spotted very quickly.
Comments
That's why it's important to check referers to make sure that it's both a valid site and it links to your site.
If you are using Awstats and MT (probably nobody) you can see http://www.estey.com/files/mt-awstats.zip for a little plugin.
Posted by: Gavin | February 16, 2003 02:15 PM
is that what happened to jeremy's site?
Posted by: john | February 16, 2003 05:34 PM
And always, always HTML encode any dynamically generated content that isn't supposed to be HTML itself. It's really quite a simple concept, but it still tends to be forgotten way too often.
Posted by: Filip Salomonsson | February 16, 2003 06:23 PM
"Statistic pages makes more sense as hardly anyone ever visits their own..."
Huh!!?! My blog is like - the only blog I visit on a daily basis. Even if I know that it hasnt changed.
I dont know what your talkin bout.
::g::
Posted by: action vance | February 17, 2003 10:48 PM
This particular issue is better known as Cross Site Scripting (shortened to XSS). Properly done, it can lead to all sorts of "interesting" issues, where data can be leaked out of a browser. A blog is a handy page to try and "exploit" with the aid these flaws, as it's not necessarily obvious where the real malicious code has come from.
As a general rule, any user input should be validated and sanitised before being used. That's just a sensible precaution.
Posted by: Áedán | February 19, 2003 01:47 PM
Áedán has it right, always filter any data you accept from a user. Also referer checking is nice, but it cannot be depended on. It is very easy to spoof since it relys on the clients browser to keep track of the referer. A perl script can be easily whipped up to act as a very simple browser which can post with any referer the programmer wishes to use.
Posted by: Scin | February 19, 2003 02:45 PM
Áedán has it right, always filter any data you accept from a user. Also referer checking is nice, but it cannot be depended on. It is very easy to spoof since it relys on the clients browser to keep track of the referer. A perl script can be easily whipped up to act as a very simple browser which can post with any referer the programmer wishes to use.
Posted by: Scin | February 19, 2003 02:46 PM
hey kasia, have you seen that this post has been referenced on El Reg?
you're famous! (in britain anyway...)
Posted by: brandt | February 19, 2003 03:07 PM
The easiest way is use the striptags function in php. I only allow users to bold, link, and italicize. Keeps it simple. Good job in getting on the register.
Posted by: Chris | February 19, 2003 03:27 PM
Surely all you need to do is strip out the code for top.location.href='http://www.theregister.co.uk/content/55/29396.html'; anglebracket script close anglebracket? or maybe get the form to strip out top.location.href from any script which is input in the comments box?
Posted by: ElRed | February 19, 2003 08:59 PM
Surely all you need to do is strip out the code for top.location.href='http://www.theregister.co.uk/content/55/29396.html'; anglebracket script close anglebracket? or maybe get the form to strip out top.location.href from any script which is input in the comments box?
Posted by: ElRed | February 19, 2003 09:00 PM
I also went to Mexico, found the people a bit strange but the food was great. Did anyone else see the Monkey directing traffic?
Posted by: Tom | February 20, 2003 02:56 AM
Congrats on the entry at The Register :)
As for the interesting problem, I have thankfully disabled trackbacks on my MT journal (elsewhere), so I don't think I have the problem.
Thanks for letting people know :)
Posted by: Stefan | February 20, 2003 05:58 AM
I mentioned this idea about a week ago as well as a few possible routes for poisioning the http referrer field. http://www.stargeek.com
Posted by: http referrer poisioning | February 20, 2003 08:14 AM
See both of these (in german):
http://www.sns1.de/partner/flamme/wflamme.nsf/Shortcut/XSSAttacke
http://www.sns1.de/partner/flamme/wflamme.nsf/Shortcut/ReferrerTrouble
Wolfgang
Posted by: Wolfgang Flamme | February 20, 2003 09:19 PM
To protect your blogs from stupid referrers just disable html in your forms... Period.
no html access no tricky javascripts.
Jessi
Posted by: Jessica | February 22, 2003 05:33 AM