Possible Duplicate:
Cross Site Scripting in CSS Stylesheets
I'm considering allowing users to create their own CSS through linked stylesheets (NOT embedded style tags). Can an XSS attack be performed from a stylesheet?
Thanks
Possible Duplicate:
Cross Site Scripting in CSS Stylesheets
I'm considering allowing users to create their own CSS through linked stylesheets (NOT embedded style tags). Can an XSS attack be performed from a stylesheet?
Thanks
In Internet Explorer, Firefox and other browsers you can embed JavaScript in CSS by specifying a javascript:
URL in a url()
CSS statement.
Even if you manage to filter these out, an attacker can still completely redesign the page (including all of its textual content) with advanced CSS. Therefore, it becomes extremely easy to trick users to execute stupid actions, which is what XSS is about. For example, you could make the Delete Account
button fill the entire window and change its text to "Click here to win 1000$".
You can white-list a select few properties (text-*
, font-*
, color
, background
(only colors and gradients, no URLs or other fancy stuff)), but you'll have to reject anything that does not match these restrictions.
Interesting question. I can imagine the style sheet having the ability to remove or hide elements which can be a security problem. You can also insert text after a certain element using :after and :before so you might want to be careful about that.
Alternately I think you should include their style sheet first so that they don't suddenly change all your fonts or something global.
those are old hacks but might still work in older browser, for example you can put javascript protocol in href attr.
http://ha.ckers.org/xss.html (search for style)