Multiple vulnerabilities in Regexp and String case conversion
https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/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.
It's interesting how people start discovering these edge cases again, now that AI can be put to work to find vulnerabilities like this.
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.
Both fixable, but as with a lot of Unicode stuff, might take a long while
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 ß.
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.
This seems like a bad property for a system that encodes human writing systems.
Knight / night is an example for English. That k should be gone, right? Or all those silent -ment and e in French.
Enter the computer and I'm not surprised that German speakers end up mostly with SS because that's what computers do when automatically upcasing words.
A lot of spelling changes are dictated by what's available on keyboards. In Italian we accept E' as È because we don't have that upper case character on our keyboard. Automatic uppercase on start of sentences fixed it where it's available and mobile keywords show an È as an option of you long press a shifted e. But what if you are writing Italian in an English locale form field with a hardware keyboard (here with an OS with English locale) or you have to write È in the middle of a sentence or, go back 30 or 40 years, you have to use a typing machine?
I'm am sure that every language that had to go through a phase of adapting to ASCII and to the limits on the layout of keyboards has similar stories to tell.
https://devblogs.microsoft.com/oldnewthing/20200804-00/?p=10...
https://devblogs.microsoft.com/oldnewthing/20241007-00/?p=11...
It must be noted though that Excel exports CSV as Windows-1252 by default in France (and other countries).Apps that ingest these files and run regexps over them are quite frequent.
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.
[1] or according to some a rotten compromise, between those who though UTF-32 wastes memory and UTF-8 discriminates non-latin languages.
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.
If you try to do the same mistake in Rust it does not compile, this function takes an int (obviously shouldn't but that's a different design bug in C not C++) and we have a wchat_t which is not an int, so that does not compile at all. Footgun removed.
When you start trying to figure out how to write the equivalent mistake in Rust properly, you discover that Rust says uppercasing or lowercasing arbitrary Unicode char values gets you an Iterator and you can't convince your compiler that this cannot make the string longer -- because in fact it might make the string longer. The mistake is averted by design.
There's nothing converting the case of a string in place. The iterator does not decide how many bytes the string has, it delivers one character at a time. It's trivial to decide how many bytes a character has (it's on the definition of your encoding), and it's written down at the type definition.
Converting the case of an string in place is just a bad operation. It should not be done. So the Rust stdlib doesn't do it. The idea that complexity has a fixed size is trivially wrong.
The Iterator doesn't have bytes in it, we're not idiots, the Iterator is over Rust's char type, a Unicode scalar value (a "character" if you don't know the lingo)
What's delivering value here is division of responsibility. Cutting a problem up into pieces each of which can be tackled by an expert. Uppercasing text, encoding characters as bytes, allocating memory, appending to a buffer, these are all distinct problems which a different expert can solve properly.
In that Ruby code you need to gather maybe a half dozen experts to agree how to write this function. Or, of course, one expert YOLOs the rest of it because every topic we don't know much about is easy, right...
Rust does this division a lot. You as a programmer see String but when your String grows that's not code in String where people who know about Unicode live, that's RawVecInner<A> and that code doesn't even know about characters or strings or any such thing, it just allocates enough space to store data.
str = ("\x82\xA0" + ("A" * (2**32 + 4))).force_encoding(Encoding::Shift_JIS)
puts "str.bytesize: #{str.bytesize}"
puts "str.encoding: #{str.encoding}"
puts "str.valid_encoding?: #{str.valid_encoding?}"
new_str = str.downcase
puts "new_str.bytesize: #{new_str.bytesize}"
puts "new_str.bytes: #{new_str.bytes}"
puts "new_str.encoding: #{new_str.encoding}"
outputs on an unfixed version: str.bytesize: 4294967302
str.encoding: Shift_JIS
str.valid_encoding?: true
new_str.bytesize: 6
new_str.bytes: [130, 160, 97, 97, 97, 97]
new_str.encoding: Shift_JIS
also I'd suggest you check out CVE-2026-128084 (GHSA-4fqr-96q8-xrfx) if you are interested in C bugs impacting Ruby on RailsHowever, if you need to do an operation on a malicious multi gb string to trigger this, it makes me slightly less concerned that regular rails apps are vulnerable.
But I'm no a security expert, is my assumption just wishful thinking?
It sounds like they are using GitHub to assign CVEs. We do the same at the rclone project. GitHub are running at a 4 week delay assigning CVEs! They used to do it in 2-3 days.
The reality of these type of bugs being found by autonomous AI models on established software should tell you by now that memory-unsafe languages are completely exposed.
This is who maintainers you are up against:
"Thanks to Stephan Lipp (Ada Logics) and Anthropic for reporting this issue."
Imagine attackers using abliterated models at scale who don't disclose these issues.
[0] https://github.com/ruby/ruby/security/advisories/GHSA-34m4-m...
People come to defend C.
And yes, there can be vulnerabilities in the compiler itself. But it's still better to have less memory unsafe code than more.
Just some days ago I ordered some sheet music, and guess what, it was shipped to an address where ÆØÅ were replaced with ? too. Hopefully it will arrive.
The amount of code out there that still simply breaks on non-ASCII characters (even Latin-1 characters!) is unbelievable. No wonder the AI vulnerability scanners are having a field day.
If that's the case you are lucky to have had package tracking at all.
“I know, I’ll use regular expressions to solve it,” you think.
Now you have two problems.
Writing *p++ = c;
to append to a buffer is just insanity, I don't know why so many people like to write "clever" code like this.
I have a buf_putc(struct buf *b, int c); which does bounds checking (and potentially growing the memory), and I've used this kind of abstraction for decades.
Same with "use after free" bugs, WHY are people malloc()ing and free()ing all over the place, and storing away pointers to things all over the place (people just looove their "objects" and stuffing pointers to things into structs and classes so now you have these insane lifetime couplings).
Ban pointer arithmetic, ban null terminated strings, ban malloc() and free() (and similar general purpose allocators), ban passing arrays without a length (and preferable have a struct ptrlen {} and pass it by value) and you eliminate 99.9999% of these bugs.
Multi threading in C is genuinely difficult because you get zero help from the compiler, but these low hanging bounds and lifetime problems can easily be eliminated with simple abstractions.
Seriously, all these snarky posts about Rust being the god language really comes off as "look how utterly superior we are as Rust programmers and look how superior the Rust language is, this would never ever happen in Rust the god language". Yes, I'm annoyed by stuff like this.