Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Major HTMLawed Security Issues

edited December 2011 in Vanilla 2.0 - 2.2
HTMLawed is used by Vanilla to sanitize HTML, however, that is NOT what it is intended for. HTMLawed is only designed to be used to ensure valid HTML. HTMLawed fails to sanitize against a number of major attack vectors, especially in the style attribute, which can be used for click-jacking, phishing, web-page overlays, defacement, and more.

This is mentioned at

For example, the following snippet can be used to display a div outside the post area:
<div style="width: 100px; height: 100px; position: absolute; bottom: 0; right: 0; background: red; opacity: 0.5; z-index: 10000;">this is a security test</div>
A slight alteration could be used to exploit users via a clickjacking type attack:
<a href="" style="display: block; width: 100000px; height: 10000px; position: absolute; top: 0; left: 0; opacity: 0.0; z-index: 10000;">this is a security test</a>
You can test either of the above non-persistently by copying into a reply and clicking preview.

I strongly recommend returning to something intended for security, such as HTML Purifier. Alternately, it is supposedly possible to write your own filter to sanitize the style attribute yourself. If abandoning HTMLawed is not an option, it might be ideal to lock down all styles except those used for basic text formatting.


  • great topic. didnt v2 use html purifier at one point and time?
  • @bugslayer

    it appears that htmlawed does work to purify html. the site says

    "use to filter, secure & sanitize HTML in blog comments or forum posts, generate XML-compatible feed items from web-page excerpts, convert HTML to XHTML, pretty-print HTML, scrape web-pages, reduce spam, remove XSS code, etc."

    the plugin shows its using htmlawed and the most recent version is

    Maybe the plugin is not configured correctly, or the older version doesn't catch clickjacking?
  • I tested your clickjacking script on htmlawed, and it still works.

    you can test it for yourself here
  • update

    tested clickjacking script on html purifier and it stopped the attack
  • edited September 2010
    htmLawed can easily handle the kind of attack mentioned above. It's a matter of configuring it properly. Denying the 'style' attribute is a simple solution (set the htmLawed config. parameter 'deny_attribute' to include 'style'). If a blanket denial of 'style' is not possible, it's value can be checked using the htmLawed parameter 'spec' to conditionally deny it as needed (e.g., if in a 'style' value, a z-index is set or if display is set to block). Many have misunderstood and misspoken of htmLawed's abilities without fully reading its documentation or configuring it properly.
  • @bobtheman, the marketing jargon in this case does a great disservice to the community. The bottom line is that "safe" mode isn't really safe. It's a known issue, and handled only by briefly documenting it. I raised this concern a while back when looking into HTMLawed for other purposes, and was told "we'll make it more clear in the documentation." Unfortunately, many products (such as Vanilla) take the promises at face value, and never notice the fine print.

    There is a plugin to use HTML Purifier instead, and I plan to use that as a workaround. I'm raising the issue here because a security issue like this could cripple Vanilla's reputation, which would be a rotten shame.

    @patnaik, Blanket denial of style would be a big problem for Vanilla, especially for forums where WYSIWYG editors are in use. Actually processing the contents of style would be a real chore, especially since the processing would have to be cross browser secure against any type of malformed styles that people could come up with. The only safe solution I can think of would be to parse the styles and rebuild them based on a whitelist and value validation. This isn't easy.

    I'm sure this seems to you like an attack on HTMLawed. I'm sorry for that. I really desperately want to be able to use it (it would be VERY convenient.) My problem is that, as currently implemented, it isn't a safe/suitable way to sanitize of this type of content. It could be patched with a custom filter, but honestly, I couldn't find any "easy" way to do this. The recommended snippet glazed over the issue of how to *actually* use CSS Tidy to do this. After digging through the CSS Tidy documentation, I don't think it can actually be done that way, because CSS Tidy doesn't appear to support any type of custom property filtering.
  • You may have a valid point

    @Mark @Todd
    Have you had a chance to read over this discussion? care to comment?
  • ToddTodd Chief Product Officer Vanilla Staff
    Curses. The problem with HtmlPurifier is that it takes a ton of memory and slows things down greatly. I'm wondering if I can deny some of the style attributes such as position an whatnot?
  • edited September 2010
    Seems like we should go back to purifier and some uber caching.
  • i havent had time to look fully into this but, @Todd is the htmlawed project still actively being developed compared to html purifier ? This would be my first question

    if htmlawed is still active, are our setting just not configured correctly, and this is allowing this clickjacking script? Or is this a known issue that maybe the htmlawed team is working on? Maybe we could report this and submit a fix, then update the plugin on our side.
  • MarkMark Vanilla Staff
    @bobtheman - Correct me if I'm wrong, but I think @patnaik *is* one of the HtmLawed developers.

    @patnaik - any chance you could help us to tighten up our htmLawed implementation so we don't have to go back to HtmlPurifier? :)
  • ToddTodd Chief Product Officer Vanilla Staff
    I just pushed a potential fix that filters out any style attributes with a position, z-index, or opacity. This is on unstable.
  • @Todd, I agree on the memory and speed issues. That's why I was looking into HTMLawed when I first learned about this issue several months ago.

    I looked at your code and the change helps, but there are still lots of ways around it. I'll send you a PM with more details, since this will be outside the realm of obvious attack vectors.

    Sorry to be such a pain!
  • how can i configure htmLawed to get rid off all "style" attribute?
  • idea: have those cases in which a style attribute is to be accepted (WYSIWYG editors and such) if they have a sibling attribute class="{token: }" that is a md5() of a salted value, to be specified by the Administrator via an htmlLawed option the Dashboard Settings, and have the plugin remove any instance of style that does not comply with that? That way you don't have to fork htmlLawed or rely on them fixing this specific case?
  • @pixeline, That doesn't add any security, because the javascript would have to have access to the salt, which in turn means that the attacker has access to the salt. The attacker could craft the malicious code and salt it without using the WYSIWYG editor.
  • ToddTodd Chief Product Officer Vanilla Staff
    @glow, I think I'm going to add a config setting to disallow all style and class attributes within the Html. People that want wysiwyg can disable this and use HtmlPurifier.
  • @Todd, it would be good to put a comment with that option indicating what the users need to do to keep their forum secure. Otherwise they're likely to open a hole without realizing it.
  • ToddTodd Chief Product Officer Vanilla Staff
    I just pushed a change to unstable with a Garden.Html.SafeStyles option that will disable class and style attributes entirely. It is set to true in config-defaults.php with a comment saying that its meant to prevent click-jacking attacks.

    This will cause problems for people with wysiwyg and BBCode, but I think those issues can be dealt with separately.
  • MarkMark Vanilla Staff
    This issue has been addressed in Vanilla 2.0.10
  • BUMP
    Is there a possible threat even after disabling position, z-index and opacity?
  • MarkMark Vanilla Staff
    If you are using vanilla 2.0.10 or greater, this is no longer a threat.
  • atmeyatmey New
    edited October 2010
    I see the "style" has been disabled, and it seems I can enable it by commenting line 53 in plugins/HtmlLawd/class.htmlawed.plugin.php
    $Config['deny_attribute'] .= ',style';
    My question is: if I comment this line "style" will be working again, does that pose a threat?

    There seems to be a work around against position, z-index and opacity in line 73
  • MarkMark Vanilla Staff
    We found that even if you disable z-index and opacity, there were other ways to get hack things the more we tested. We decided to drop style altogether as a result. If the community wants to work on a definitive css attribute blocking list, we'd be happy to implement it. But this was the most sure-fire way to block attacks for the time being.
  • Okay, gotcha, thanks.
    What are html alternatives to change font color?
  • @Atmey, you can do this with the color attribute of the font tag, but the font tag is technically deprecated.

    If you want to allow very much formatting you should probably switch your forum to use HTML Purifier. There's a plugin you can download for this.
  • Hi,
    I'm the author of DaDaBIK, a PHP Web application generator, and I would like to use HTMLawed for my project too, because HTMLpurifier seems to me too complex and doesn't support PHP4.

    However, it seems that there are other vulnerabilities than the style and class ones, that you solve disabling them.
    I refer for example to the character encode checking problems or the attribute-based security vulnerabilities...anyway you can read all the limitations and problems here:

    So what do you think about and why didn't you consider these issues?

    Thanks in advance.


  • MarkMark Vanilla Staff
    @Todd or @Tim have any comments/ideas?
  • Notice this topic thank to SPAM messages above.
    Apart this, the HTML security problems this thread is about has been solved?
    The argument is very interesting: maybe using the old good BBcode as only markup editor can be a solution?

  • x00x00 MVP
    edited December 2011

    candyman @patnaik answers the question well, and he would know. It is all about using it appropriately.

    btw I mentioned the class white-list approach aswell. You can also have limited styling, not really a problem.

    Vanilla forums uses a style, they are happy to firefight tomfoolery. It really is not a problem to limit style to bbcode level. But you also get the benefit, of using broader html.

    This really isn't as big an issue as has been made out. Out of the box the plugin is safe.

    grep is your friend.

Sign In or Register to comment.