views:

117

answers:

4

I have a site of user-submitted news articles, and an idea I had for a feature was to grab the favicon on the target site to display along with the link.

The methodology for grabbing the favicon would be checking for the favicon.ico file on the target server. Would displaying that icon as an image open any hole? Could there be some sort of malicious favicon? Would converting the image server-side to a different file format negate risk?

+4  A: 

There was a vulnerability in Window's JPEG parser a few years back. It's possible that vulnerabilities could be discovered in other formats in the future, but I think that you are pretty safe to display it as-is, and be vigilant in applying patches if a threat is publicized.

However, to protect the privacy of your users, you should cache the favicon at your server, and let users' browsers fetch it from there. On the other hand, some sites might feel you've violated their intellectual property by displaying their favicon on your site. Again, I probably wouldn't worry about it too much until they ask you to stop.

erickson
Also, it's considered impolite to hotlink their assets, so it would be better to cache it on your server anyway
K Prime
The idea is definitely to cache, though the initial thought was for performance reasons. The security concern was the initial fetch.
Zurahn
Yes, what I'm saying is that even on the initial fetch, your server should acting as a proxy so that there's never a direct connection between any user and the third-party site.
erickson
And so did I (cache and display the cache). Maybe I'm weird, but I never would have even thought to display the direct content, then have a cache separately.
Zurahn
It would be pretty hard to set that up, actually. Just wanted to make sure my answer was clear.
erickson
+1  A: 

Privacy would be my main concern really as favicons are sometimes used for tracking who bookmarks a page. At the very least it would screw their data as they'd think more people are bookmarking them than really are.

When browsers use them the recommended behaviour which I think is adopted by most now, is to only fetch the favicon when you visit the site and then cache in the browser. I would do the same server side by fetching the icon when a user submits the article and cache it (and at the same time you can take the opportunity to verify the link is valid, extract a summary, etc).

tjmoore
A: 

There is always some risk in including content over which you have no control.

For example, if the image renderer in browser x was to suffer from a buffer overflow vulnerability, then the owner of the site that hosts the source image could swap out the original icon for a malicious one. Your users could then be infected from your site without you knowing.

Cheekysoft
A: 

As an addittion to the other answers, you should know that many (most?) sites these days don't have a file favicon.ico in their web root, but a tag like this in the HTML head:

<link rel="shortcut icon" href="http://www.example.com/images/icon.png"&gt;

Where the icon can be in other formats than .ico.

Bart van Heukelom