Lots of services out there like browser-update.org tell you to load snippets of js over http from some random location they control. It's pretty unsafe unless you really know who's running the show over there and how secure their system is. Them being compromise could make every user site vulnerable.
There is of course the maintenance issue... what happens when their script is updated and breaks how you use it?
You shouldn't hotlink someone else's JavaScript
11–20 of 102 posts
Re: You shouldn't hotlink someone else's JavaScript
#12Every time you include some externally hosted javascript you open yourself and your visitors to a security risk. And on top of that, if you do it like this you're stealing bandwidth.
When including remotely hosted javascript make sure you have permission, make sure the other party is trustworthy and periodically review the linked script to make sure it does what is advertised (and that's imperfect, it could be you're seeing something else than other visitors).
Re: You shouldn't hotlink someone else's JavaScript
#13Ok there is a better way to handle this than adding some html to a page to make a banner, posting to HN, and hoping for the best. Check for referal headers and throw a 301.
Re: You shouldn't hotlink someone else's JavaScript
#14whoops, not sure he wanted it here too. http://gsgd.co.uk/sandbox/jquery/easing/
Actually, it's not a bug, pretty obvious he's "demonstrating a feature"... :)
Re: You shouldn't hotlink someone else's JavaScript
#15Ok there is a better way to handle this than adding some html to a page to make a banner, posting to HN, and hoping for the best. Check for referal headers and throw a 301.
Re: You shouldn't hotlink someone else's JavaScript
#16Re: You shouldn't hotlink someone else's JavaScript
#17- Detect referrer and return a script that has a warning
- Rotate your script filenames so those hotlinking will soon realise they will need to host it themselves
- Use a CDN yourself and don't encourage them to hotlink
- Slow down the request
For those hotlinking, consider:
- You can't trust the source of the code
- You can't trust that the code will always be there and it will load quickly
- You can't trust the contents of the code may change and break your application
If you want to be sinister to those hotlinking you could:
- Redirect the user (as others have noted)
- Display any message to the user
- Steal data from the user who is using the site hotlinking
- Inject your own adverts into the target web page
- Make the web page do the Harlem Shake
Re: You shouldn't hotlink someone else's JavaScript
#18Ok there is a better way to handle this than adding some html to a page to make a banner, posting to HN, and hoping for the best. Check for referal headers and throw a 301.
I hope referrals will be disabled anytime soon. Firefox has AFAIK disable referrals to other domains by default.
if(/whatispolymath/.exec(location.href)) alert("...");Re: You shouldn't hotlink someone else's JavaScript
#19document.location = '...'
and route the page to a java drive-by which redirects back afterwards and most of their visitors would've been infected. They are incredibly lucky that the owner of that script was nice enough just to add a simple banner.
Re: You shouldn't hotlink someone else's JavaScript
#20Earlier quoted context omitted.
I hope referrals will be disabled anytime soon. Firefox has AFAIK disable referrals to other domains by default.
In the case of Javascript hotlinking, that'll do approximately diddly squat though. if(/whatispolymath/.exec(location.href)) alert("...");