ForgeNEX

Ruby fixes three bugs in its regex engine behind four GitLab RCEs

Ruby releases versions 4.0.9, 3.4.12 and 3.3.13 to close three bugs in Onigmo, the regular expression engine that originated four critical flaws in GitLab.

4 min read

In this article

A regular expression engine at the center of the problem

Ruby has released versions 4.0.9, 3.4.12 and 3.3.13 to fix three bugs in Onigmo, the regular expression engine built into the language. The news is not just a routine update: those three flaws are behind four critical vulnerabilities in GitLab that the company has been patching over the past month.

According to what has been published, GitLab detected that a specially crafted pattern could corrupt memory while Ruby was compiling it, which in theory opened the door to code execution on its own servers. In other words, we are not talking about malicious input that reaches the application and is processed incorrectly, but about a problem that is triggered at a very early stage: the compilation of the pattern by the engine.

Illustrative detail: Ruby Fixes Three Regex Engine Bugs Responsible for Four Critical GitLab RCE Flaws

Why this matters more than it seems

Regular expressions are everywhere. In a small business the end user does not see them, but they appear in form validations, log parsing, search filters, routing rules and any library that processes text. If the engine that compiles them has a memory corruption flaw, the risk does not depend on your team writing an unusual pattern: it depends on someone being able to influence the pattern that is compiled.

In GitLab's case, the impact was serious enough to warrant four critical patches in a month. And GitLab is not a desktop product: it is a platform that many companies use as a code repository, CI/CD system and issue tracker. An RCE there is not just a compromised server; it is potential access to source code, deployment secrets and production pipelines.

What it means for a small business or an IT team

The first thing is not to read this news as a notice exclusively for large companies. Any organization that has a GitLab instance, self-managed or at a provider that has not applied the patches, should review its situation. The second is to understand that the underlying problem is one of dependencies: Ruby, Onigmo and GitLab form a chain where a flaw in the lower layer ends up affecting the upper one.

  • If you self-manage GitLab: check the version and apply the available updates. Do not wait for the quarterly maintenance window.
  • If you use GitLab SaaS: the provider should have patched, but it is worth confirming and checking whether there are pending notices in your administration panel.
  • If you develop in Ruby: update to 4.0.9, 3.4.12 or 3.3.13 depending on your branch and check whether your application compiles patterns that come from users or external sources.
  • If you have applications that process text: check whether any component exposes regular expression compilation to untrusted input. It is an attack surface that often goes unnoticed.

The recurring pattern: dependencies that execute code

This case fits a trend we have already discussed on the blog: critical flaws rarely live in the code we write ourselves. We recently talked about the two CVSS 9.2 RCE flaws in PHP and how emergency patches are becoming the norm. The lesson is the same: the dependency inventory and the ability to react quickly are worth more than any trendy tool.

It is also worth looking at the cost of not acting. An RCE on a code platform can lead to theft of intellectual property, manipulation of build artifacts or the deployment of malicious code to production. For a small business, that can be the difference between a contained incident and a serious reputational and legal problem.

The useful question is not whether your team uses regular expressions, but whether any of them are compiled with data you do not control.

Concrete recommendations from ForgeNEX

  1. Inventory and versions: locate all GitLab instances and Ruby environments. Note the exact version and the person responsible for updating.
  2. Prioritized patching: treat RCE notices as critical, even if the vector seems far-fetched. Exploitation does not always require a sophisticated attacker.
  3. Input review: identify where patterns are compiled from user data, logs or external APIs. If you can, validate and restrict those patterns.
  4. Monitoring: watch for anomalous processes on GitLab servers and unexpected changes in pipelines or CI/CD credentials.
  5. Response plan: be clear about who updates, when and how it is verified that the patch has been applied. Without that, the news remains just a headline.

As on other occasions, the underlying recommendation is the same one we apply when we talk about static credentials and tokens: reduce the surface, control dependencies and do not assume that the provider has resolved everything. Ruby has already put the patches on the table; now it is time to check whether your organization has applied them.

Source: The Hacker News. Analysis and adaptation: ForgeNEX.

Keep reading