News for hackers. Stuff that matters.
Re:Can we believe our eyes? Misleading people with Unicode. by Rygu on Thursday August 11, 2011 @10:22AM (#2872956)
I'm pretty shocked that I have never heard of the RLO unicode character before this article. Let's see if it works: ppa.emorhCelgooG => ‮ppa.emorhCelgooG
Re:Can we believe our eyes? Misleading people with Unicode. by yahelc on Thursday August 11, 2011 @10:36AM (#2873037)
Whoa. Check out you did to the markup of this page. http://d.pr/HKSQ
Re:Can we believe our eyes? Misleading people with Unicode. by jerf on Thursday August 11, 2011 @12:02PM (#2873425)
The HTML standard specifies that changes in text direction are bounded to the block they occur in: http://www.w3.org/TR/1999/REC-html401-19991224/struct/dirlan...

I discovered this as I was writing a paranoid HTML cleanup library and wanted to prevent the attack where a user sticks a text-direction-change character into the page and reverses the whole thing. As we've all just witnessed, that can't happen in a conforming browser.

But when viewing the page as a text stream, yup, it reverses and then never really unsticks. Everything's working as designed!

(Maybe my library should still restore the page flow after all... I never thought of how it could mess up view source. As attacks go, it's weak sauce... but like I said, it's meant to be really, really paranoid.)

Re:Can we believe our eyes? Misleading people with Unicode. by zbanks on Thursday August 11, 2011 @02:44PM (#2874186)
Doesn't the library just have to perform a simple search-and-replace on the entire page's HTML for the blacklisted characters to remove them?

Normally blacklisting is bad, but we're only targeting the few text-direction-changing characters that exist.

Re:Can we believe our eyes? Misleading people with Unicode. by yuvipanda on Thursday August 11, 2011 @02:14PM (#2874043)
Is this 'really, really paranoid' library available somewhere?
Re:Can we believe our eyes? Misleading people with Unicode. by jerf on Thursday August 11, 2011 @05:03PM (#2874787)
Not yet. But it'll be in Haskell anyhow, so you're probably not actually interested :)

There are other such libraries for other languages, poke around. See for instance http://htmlpurifier.org/ .

Re:Can we believe our eyes? Misleading people with Unicode. by yuvipanda on Thursday August 11, 2011 @05:54PM (#2875002)
Even more intriguing. What exactly were you writing in Haskell that needed a super-paranoid html sanitizer? Yet another web server/blog/cms? Or something way more cooler?
Re:Can we believe our eyes? Misleading people with Unicode. by jerf on Thursday August 11, 2011 @09:10PM (#2875545)
Yet another blog, except not targeted for release or anything, just to run my own site. To replace the Django blog that runs my site. It's sort of my entertaining diversion, you know? Working with my own fresh, clean code base where I can try some ideas out without having to carry around a couple of man-centuries worth of legacy code every time I step at work. The cleansing library doubles as my HTML formatter, too, doing things like ensuring close italic tags and such. The paranoia is half real, half fun exercise.
Re:Can we believe our eyes? Misleading people with Unicode. by yuvipanda on Friday August 12, 2011 @01:56AM (#2876156)
Ah, yes - I see where you're coming from. Some day I hope to finish my blog, written in C :D Good luck for your haskell blog :)
Re:Can we believe our eyes? Misleading people with Unicode. by nzmsv on Thursday August 11, 2011 @10:52AM (#2873111)
Looks like the bug is in Chrome's View Source - the markup itself is fine.
Re:Can we believe our eyes? Misleading people with Unicode. by cbr on Thursday August 11, 2011 @10:54AM (#2873119)
Is it a bug? Or is chrome correctly interpreting the right-to-left override character it sees in the source?
Re:Can we believe our eyes? Misleading people with Unicode. by nzmsv on Thursday August 11, 2011 @12:07PM (#2873447)
Good point. It is probably the right thing to do technically, since the source view can't rely on parsing the markup. I think I'd prefer such non-printable characters to be simply escaped though.
Re:Can we believe our eyes? Misleading people with Unicode. by yahelc on Thursday August 11, 2011 @11:20AM (#2873227)
Are you sure? curling from Terminal, I get the same result.
Re:Can we believe our eyes? Misleading people with Unicode. by cbr on Thursday August 11, 2011 @11:43AM (#2873326)
That's probably because your terminal interprets the RLO character. Should it? I'm not sure.
Re:Can we believe our eyes? Misleading people with Unicode. by icebraining on Thursday August 11, 2011 @12:38PM (#2873621)
rxvt-unicode, despite being perfectly able to display unicode characters (hence the name), drops the RLO.
Re:Can we believe our eyes? Misleading people with Unicode. by aw3c2 on Thursday August 11, 2011 @10:55AM (#2873123)
Ha, nice catch!

edit: I get the same in Opera 11.50, Firefox 5.0 and some Chrome version.

Re:Can we believe our eyes? Misleading people with Unicode. by jerrya on Thursday August 11, 2011 @10:53AM (#2873117)
This is an interesting page from 2006: http://digitalpbk.blogspot.com/2006/11/fun-with-unicode-and-... and seems to demonstrate to me that Firefox, Opera, and Internet Explorer all will eagerly display the RLO character, and Chrome and Safari will not.

Is Chrome and Safari broken or being responsible? (Are there settings to change the behaviors in any of these browsers...?)

Re:Can we believe our eyes? Misleading people with Unicode. by xtacy on Thursday August 11, 2011 @12:28PM (#2873558)
Try selecting the text, it behaves funnily in a way that I can't understand!
Re:Can we believe our eyes? Misleading people with Unicode. by bzbarsky on Thursday August 11, 2011 @01:02PM (#2873744)
It behaves funny in a very "simple" way. Selections have this little problem where you move your mouse over the visual representation but the selection is in the logical representation.

So say your logical text is this:

  ltr LTR.
where the capital letters are RTL chars (whether because they're actually RTL or because of an RLO in the char stream). That is, the above represents the reading order. Visually this would look like this:

  ltr RTL.
assuming that this paragraph directionality is left-to-right; a reader reading this text would read the letters in the order 'l', 't', 'r', ' ', n 'L', 'T', 'R' (which if you note matches the logical order, hence the name).

Now say you mouse down between the 't' the 'r' and drag right until your mouse is between the 'R' and the 'T'. Those are your selection endpoints. But the selection happens on the _logical_ text, so what's selected is the 'r', the space, the 'L', and the 'T' (and even in that order). You can see that in the example above; if you mouse down between the two 'o' chars in "elgooG" and drag right to between the two 'o' chars in "Google", then you get exactly this sort of behavior.

Re:Can we believe our eyes? Misleading people with Unicode. by xtacy on Thursday August 11, 2011 @01:49PM (#2873943)
Ah, that makes sense. I didn't think that text selection defines end points and everything between the endpoints (in the physical text) is highlighted. So, if you have:

    Hi RLO elgooG
    ^ select ^
I expected (everything between the logical end points selected):

    Hi Google
    ^^^^^^^ (selected)
In other words, I expected text selection to obey RLO character as well.
Re:Can we believe our eyes? Misleading people with Unicode. by groby_b on Thursday August 11, 2011 @08:05PM (#2875382)
Nope - selection is on logical text, not on visual text. For tons of "fun" reasons. If you want an afternoon of madness, read the Chrome or WebKit sources relating to BiDi text.

If that's not enough pain, read http://unicode.org/reports/tr9/ (the unicode BiDi algorithm)

If you're still liking it, I know a few people who'd love to hire you :)

Re:Can we believe our eyes? Misleading people with Unicode. by bzbarsky on Friday August 12, 2011 @01:08AM (#2876069)
I think you're confusing your logical and physical, or I'm misunderstanding you.

Moving your mouse happens over the physical text and sets the selection endpoints. Then everything that's logically (as opposed to physically) between those endpoints is highlighted. Your "I expected" diagram is showing the text physically between the endpoints, not the text logically between them...

Re:Can we believe our eyes? Misleading people with Unicode. by username3 on Thursday August 11, 2011 @12:44PM (#2873646)
Re:Can we believe our eyes? Misleading people with Unicode. by Rygu on Thursday August 11, 2011 @07:10PM (#2875238)
This is really dangerous. Luckily the status bar reveals the real URL. However it's still dangerous when you use a visually trusted address like Gmail:

‮ http://nyan.cat/?0/u/liam/moc.elgoog.liam//:sptth

Re:Can we believe our eyes? Misleading people with Unicode. by lobo_tuerto on Thursday August 11, 2011 @11:06AM (#2873170)
Inspecting the element with Chrome shows an amusing behavior. Try it.
Re:Can we believe our eyes? Misleading people with Unicode. by Dove on Thursday August 11, 2011 @01:48PM (#2873939)
How many failed 0x202Egp registrations do you suppose there have been in the last hour?