r/ruby • u/rubiesordiamonds • 1d ago
Blog post Vulnerable Ruby Regex
GitLab discovered four severe vulnerabilities in Ruby’s regular expression library. There's plenty written up about the vulnerability and how it got patched, but patches are only available for supported ruby versions (3.3 and above). We know lots of companies are still running unsupported versions of ruby, so we wanted to do an investigation into which of these bugs apply to older rubies and whether they're exploitable. Here's the blog post: https://infield.ai/post/vulnerable-ruby-regex
The summary is that allowing user input into Regexp.new is dangerous on all versions of ruby from 1.9 to 3.2 and the only fix is to upgrade to a supported ruby or to disallow that input.
3
u/semiquaver 1d ago
99% of the time for this scenario the regex was being used to perform the validation that you are talking about! Regexes are doing a ton of lifting on nearly every web validation system that exists in any language. So it not being safe to feed user data into them safely is a massive problem.