Hacker News new | past | comments | ask | show | jobs | submit
There's what I think is probably an awesome bug here.

Windows-1252 encoding has a representation for lowercase German sharp 's' (ß), but not one for the uppercase. If you upcase a string containing a sharp 's', it gets normalized to "SS", which increases the length of the string by one character. The 1252 case conversion code doesn't handle this; it looks like it checks for headroom in the buffer one character at a time. So if the last character of a string you upcase is ß, it looks like you get a one-byte overflow (of 'S').

If that's really the bug (there's a claimed RCE POC), the heap grooming for it must be really fussy! I couldn't find any other character pairs that expand like this.

You can feed strings in 1252 to a Rails program through multipart POSTs, which get to pick their encodings.

The great thing about this bug, apart from how it illustrates how doomed we all are (if I'm right), is that it should by rights have the best vulnerability name of the year, because you get to work 'ß' into it.

loading story #50556731
Haha, that exact character caused problems in a programming class I tutored for. Got to throw the first year students some curveballs.
Should we call it #upcaße2Shell?
One of the discoverers suggested, on Twitter, Ruby2ßhell. My wife, who speaks and writes German, refused to entertain this.
I am a native German speaker, and I'm ok with all of them. I draw the line with reading ß as b or beta.
I have a modest proposal: it should be named Rußy2Shell
Believe it or not - Straight to Jail.
loading story #50557039
ß is not s though. It is closer to th. ”ßhell“ would be pronounced like Mike Tyson would probounce ”sell“.
In what language? For german, ß gets transliterated to "ss" in ASCII environments for a reason and words where updated spelling rules no longer use ß also replaced it with "ss" and not "th". That's also why it's pretty uncommon at the start of a word, which is why we got along without an uppercase variant for so long.
Indeed. For example, straße.

Maybe parent commenter was mixing up ß with þ; thorn.

> Þ (minuscule: þ), called thorn or þorn (/θɔːrn/ thorn), is a Latin-script letter used in the Old English, Old Norse, Old Swedish and modern Icelandic alphabets, as well as modern transliterations of the Gothic alphabet, Middle Scots, and some dialects of Middle English. It was also used in medieval Scandinavia but, except in Iceland (where it still survives), it was later replaced with the digraph th. The letter originated from the rune ᚦ (Thurisaz) in the Elder Futhark and was called thorn in the Anglo-Saxon and thorn or thurs in the Scandinavian rune poems. It is similar in appearance to the archaic Greek letter sho (ϸ), although the two are historically unrelated. The only language in which þ is currently in use is Icelandic.

https://en.wikipedia.org/wiki/Thorn_(letter)

loading story #50555241
loading story #50556695
loading story #50555741
I wonder if there is a similar bug for U+0130 which (I think) expands to two characters when lowercased.
Maybe somewhere! But that character isn't in Windows-1252 at all, so it can't trip this string counting bug.
I've encountered bugs with U+FB03 (Latin Small Ligature FFI) which expands to three characters when uppercased.
Wait, why would the Turkish dotted uppercase I expand to two characters?
Because, unless you use a Turkish locale for the case-conversion, it turns into a lowercase i plus a combining dot above.
Unicode also has this feature because SS is the correct uppercase form of ß
Not only that, when you uppercase 1 char with precomposed diacritics, but uppercase doesn't have precomposed diacritics, so they expand into separate chars (max is 1 to 3 chars)

Both fixable, but as with a lot of Unicode stuff, might take a long while

It’s not. There are multiple uppercase forms, including “SS”, “SZ”, and the uppercase ß character, all of which are well-established, which makes all of them correct according to the principle of linguistic descriptivism.
And according to linguistic perscriptivism, the upper case of ß is ẞ since 2017. (SS is also allowed, but no longer preferred)
The uppercase ß was introduced as an option in 2017 but only became the preferred option in 2024.

Interestingly Unicode included the uppercase ß since 2008.

tbh I'm German and just learned about this now. I don't even know which keyboard incantation I would have to use to create this abomination. My android keyboard does not seem to have an uppercase ß.

> tbh I'm German and just learned about this now.

It's a little amusing how many Germans I've heard this from, meanwhile as a non-German I think I first heard about ß and ẞ at least a decade ago.

Maybe this is one of those "outsiders have fresh eyes" things where googling "wait, wtf is up with ß" is not something most Germans would do?

A similar thing happens with Japanese natives and ヷ/わ゛ -- most are not aware this character existed historically and they usually also incorrectly guess how it's read.

loading story #50555620
Or so the Germans would have us believe...
loading story #50556493
loading story #50555400
loading story #50555966
As is tradition, Raymond Chen has had something to say about this. The windows-1252 code page was introduced with Windows 1.0, and according to Wikipedia its final version shipped with Win98. String operations are just plain too hard.

https://devblogs.microsoft.com/oldnewthing/20200804-00/?p=10...

https://devblogs.microsoft.com/oldnewthing/20241007-00/?p=11...

loading story #50556367
I'm mortified by the second article, C++ really is Lovecraftian-level insanity.
To be fair, there aren't many languages out there where working with strings and encodings is not a nightmare
C and C++ are amongst the worst for working with strings, substrings, etc. It has gotten a bit better in newer versions of C++ (and I don't keep track of changes in C, so not sure what is going on there these days), but it is still far behind most more modern languages.

Python has good string support, as does Rust. I think (though I don't know it myself) Perl is famous for good string handling? Even bash has ok support for working with strings.

So I don't really agree on "aren't many languages", but then again there are a ton of languages I don't know, so maybe those I mentioned are the exception.

It’s unclear whether you are talking about the ergonomics of dealing with strings, the flexibility of using encodings other than UTF-8, or whether you mean human-oriented or computer-protocol-oriented string handling. It’s also unclear whether you are talking about using the standard library only or if you include other ubiquitous libraries like ICU.
I said "strings and encodings". Almost all modern languages break the moment you realise there's more to text than ASCII
UTF-16 in general was a good idea[1] at some point of time but that didn't last long.

[1] or according to some a rotten compromise, between those who though UTF-32 wastes memory and UTF-8 discriminates non-latin languages.

No it wasn't. Using UTF-16 for that reason is all about posturing and not based on reason. Even for mostly CJK documents or ther languages where UTF-8 happens to be longer on average, any ASCII-based markup will quckly turn the tables. And if storage is that much of a concern just compress the damned thing - then the UTF-16 vs. UTF-8 doesn't matter at all for size.

And to be clear, UTF-16 was not chosen anywhere for that reason. It only exists because people thought UCS-2 would be enough for everybody (even though that was always far-fetched and futilely trying to make it reality has permanently damaged Unicode) and UTF-16 was the easies quck fix hack to "fix" UCS-2 based systems. It's yet another short term solution that will keep causing problems forever.

loading story #50557833
Mutable strings bite again, but I never thought they would actually cause a buffer overflow like this.
loading story #50563350
loading story #50561856
Can we just eliminate windows-1252 for good. that encoding have given me so many headaches over the years, and there is no good reason to not just use utf-8 especially nowadays.
loading story #50555612
loading story #50557514