Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to allow to embed an arbitrary external stylesheet into my web-page?

Tags:

html

css

I have a dynamic web-page which I want other people to embed into their web-pages, with an iframe (not necessarily with any kind of more advanced techniques like JavaScript).

Instead of providing all sorts of designs and styles myself, I'm thinking about allowing them to provide their own stylesheet for my page through an HTTP GET parameter, and embed such external stylesheet through a URL w/ <link type="text/css" rel="stylesheet" href… on my page.

Is this safe? Will it violate the security paradigm of my web-site? I'm aware that extra text could be inserted with CSS alone, and indeed elements could be removed (which is the whole point of me providing such functionality for my users), but anything else I should be aware of?

Could malicious people insert links onto my site through such a CSS, to benefit from my http referer and potentially violate some checks, or is CSS insertion limited to text?

like image 573
cnst Avatar asked May 21 '13 17:05

cnst


People also ask

What is the main benefit of using an external style over embedded style sheets?

Advantages of External CSS: Since the CSS code is in a separate document, your HTML files will have a cleaner structure and are smaller in size. You can use the same . css file for multiple pages.

Can you add external CSS to your webpage?

External CSSWith an external style sheet, you can change the look of an entire website by changing just one file! Each HTML page must include a reference to the external style sheet file inside the <link> element, inside the head section.

What is external stylesheet What are the advantages and disadvantages?

To apply a rule to multiple pages, an external style sheet is used. An external style sheet is a separate CSS file that can be accessed by creating a link within the head section of the webpage. Multiple webpages can use the same link to access the stylesheet.

How is the external style sheet placed in the web page coding?

External stylesheets are totally separate from the HTML and you place them in a CSS file (with the . css extension). To use external stylesheets in your HTML, you link them within the head with the link tag.


1 Answers

In the general case, no, allowing third-party CSS is not safe. Some implementations allow JavaScript in CSS, which means that allowing users to modify your CSS allows them to execute arbitrary JavaScript in the context of your page.

However, if this is meant to be sort of a "white-label" page, where it appears to be part of the site it's embedded in and the fact that it's really your page is just an implementation detail, this doesn't seem like a major concern. The person specifying the "third-party" CSS is the site owner, so it's not really third-party at that point — they're not going to XSS themselves!

But nobody else should ever be putting CSS on a page that's meant to be under your control, because it's really under the control of whoever is controlling the CSS.

like image 117
Chuck Avatar answered Sep 28 '22 03:09

Chuck