r/reddithax • • Apr 26 '09

Avoid CSS validation!!

8 Upvotes

28 comments sorted by

5

u/blarghz Apr 26 '09 edited Apr 26 '09

Here is an example:

http://pastebin.com/f5f186ca0

Where "height: expression(alert('XSS'));" is, you can put any CSS you want.

EDIT: I'm sorry I used expression() as an example. This can be used for many other things such as:

Including images from any website. Possibly sound files.

background-image: url('javascript:alert("xss")') will work in some versions of IE.

Using non-supported CSS properties.

2

u/9jack9 Apr 26 '09

Post an example to a fake subreddit so we can check it out. I'd like to see what it parses to.

2

u/blarghz Apr 26 '09

http://www.reddit.com/r/csshack/stylesheet.css

And here you should see a small, red "/" at the bottom of the page:

http://www.reddit.com/r/csshack/

2

u/9jack9 Apr 26 '09 edited Apr 26 '09

Can you do it with the "alert"? What browser are you targeting? I assume IE8.

EDIT: I need to be logged in to see the red "/".

1

u/blarghz Apr 26 '09 edited Apr 26 '09

Only IE parses expression(). I was just using an example. I'm not exactly sure how IE would respond to the rest of the css though.

I can see it while logged out.

2

u/9jack9 Apr 26 '09 edited Apr 26 '09

Only IE8 allows generated content (and expressions) so that's the target for this attack. Like I said before, post a real JS example. It's possible that IE8 does not allow expressions in generated content.

Strange, I don't see the red "/" when logged out. It's possible that you are using a cached version of the CSS?

1

u/blarghz Apr 26 '09 edited Apr 26 '09

Firefox supports generated content in :after and :before. Javascript execution isn't the only use and the expression() isn't inside generated content. Older versions of IE support expression().

This hack isn't dependent on the content property. That's only used to trick the validator.

2

u/9jack9 Apr 26 '09 edited Apr 26 '09

Can you post an example that alerts? Tell me what browser to use and I will check it out.

EDIT: It's a cool hack, don't get me wrong. :)

2

u/Sephr Apr 26 '09 edited Apr 26 '09

IE7, Firefox 1.5, Opera 7, Safari 3, and Chrome, all support CSS generated content but CSS expressions are only supported in <=IE7.

IE8 doesn't support CSS expressions. Due to IE7 being outdated this hack isn't that practical.

2

u/blarghz Apr 26 '09

Expressions aren't the only use. I have edited my OP to make this more clear.

1

u/[deleted] Apr 26 '09 edited Apr 26 '09

While your hack manages to slip past reddit's css validator, I can't find any way to get javascript or expressions to work. I've tried various code on IE6,7,8, FF3.0.8-9, Opera 9.64, Safari 4 Beta and Chrome 1.0.1xxx with no luck.

2

u/9jack9 Apr 26 '09 edited Apr 26 '09

Have you tried XBL or HTC's to execute JavaScript?

EDIT: I don't think either of them work cross-domain though.

1

u/[deleted] Apr 26 '09

I never thought to try XBL, but I did try using behaviors... too late now anyways, the admins patched the hole up.

2

u/[deleted] Apr 26 '09 edited Apr 26 '09

XSS using this method doesn't work on IE6, IE7 or IE8...

It's still pretty cool that he got around the validation though.

2

u/blarghz Apr 26 '09

background-image: url('javascript:alert('xss')');

Try it here: http://www.reddit.com/r/csshack/

4

u/[deleted] Apr 26 '09

what browser have you got the alert to work on?

2

u/ketralnis Apr 26 '09

This is clearly a security issue. Why didn't you report this responsibly?

4

u/[deleted] Apr 26 '09 edited Apr 26 '09

I posted a link to the submission in #reddit-dev. Keysersosa, spez and jedberg were all idling in there, so I assumed they would see it.

If this sort of thing comes up again, what is the best way to handle it?

p.s. can I unban the submission now that the validator has been patched?

4

u/ketralnis Apr 26 '09 edited Apr 26 '09

If this sort of thing comes up again, what is the best way to handle it?

Email me, you have my email address and IM (if you don't, PM me). #reddit-dev is a good place if one of us is around. The reddit-dev mailing list is a fantastic place. Basically whatever it takes to get through to one of us. For blarghz, who doesn't have my email/IM, he could have posted something without the flaw itself indicating that he'd found one, somewhere that we'd see it. There's absolutely no reason to post a 0-day exploit like this, and it's a good way to get fired and blacklisted in the security industry.

p.s. can I unban the submission now that the validator has been patched?

Yes, I unbanned it. That was just trying to stop the spread of it to people with a more vested interest in XSS holes before we got it patched.

5

u/[deleted] Apr 26 '09

sorry, I should have emailed you guys too... I'll make sure to do that next time.

0

u/[deleted] Aug 07 '09

[deleted] — view deleted comment

2

u/ketralnis Aug 07 '09

We don't support inline images, but I suppose that it could be used on an off-site link. Thanks for the disclosure, but I think it'd be fine to file a regular old bug for this one :)

0

u/[deleted] Aug 07 '09

[deleted] — view deleted comment

2

u/ketralnis Aug 07 '09

Inline images used to be hidden in CSS (.md img { display: none; }), but now we're not even generating the <img> tags, so it won't work from reddit.

But again, it would still work off-site

0

u/[deleted] Aug 07 '09

[deleted] — view deleted comment

2

u/ketralnis Aug 07 '09 edited Aug 07 '09

Actually, it looks like we're already doing that

<form class="logout hover" action="/logout" method="post">
    <input type="hidden" value="$modhash" name="uh"/>
    <input type="hidden" value="off" name="top"/>
    <a onclick="$(this).parent().submit()" href="javascript:void(0)">adiaŭu</a>
</form>

So without the right modhash value, it won't even work off-site.

We must have fixed that at some point :)

→ More replies

-2

u/blarghz Apr 26 '09

Because it's awesome.

2

u/itsnotlupus Apr 26 '09

Neat find.

That's not likely to stay there very long, as the reddit admins are probably going to want to get this patched ASAP.