Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

Multiple vulnerabilities in Regexp and String case conversion (https://www.ruby-lang.org)

339 points by runesoerensen 1 day ago | 131 comments | View on ycombinator

tptacek 1 day ago |

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.

pentestercrab 1 day ago |

  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 Rails

lousken 1 day ago |

I need a vacation

nickcw 1 day ago |

> CVE identifiers have been requested for these vulnerabilities but have not been assigned yet, so this advisory refers to them by their GitHub Security Advisory (GHSA) identifiers.

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.

rvz 1 day ago |

These are all C-based memory corruption vulnerabilities.

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...

vintermann 1 day ago |

Fun fact, I ordered something online to an address in Ålesund once, it took a long time to arrive, package tracking showed the idiots (Deutsche Post as I recall) had shipped it to a place called Lesund instead. Ignoring the post code.

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.

mpetrovich about 23 hours ago |

You have a problem.

“I know, I’ll use regular expressions to solve it,” you think.

Now you have two problems.

xiaoliangliang 1 day ago |

[dead]

slopinthebag 1 day ago |

oh boy. if only we had a language that could prevent this from happening. oh well, i guess there is nothing we can do but patch these things once they're discovered.

TZubiri 1 day ago |

It should be pretty straightforward to replace regexes with good ole ifs, array acceses, and comparision operators, whether manually or with an LLM. Pretty low hanging fruit to shave off some kilobytes of attack vector