GitLab’s Hidden Weakness: Five-Year-Old JSON Parser Flaws Open the Door to Remote Code Execution + Video

Listen to this Post

Featured ImageIntroduction: A Trusted Feature Becomes an Unexpected Attack Vector

Cybersecurity researchers continue to uncover vulnerabilities hidden deep inside software dependencies, proving that modern applications are only as secure as the libraries they rely on. While GitLab has built a strong reputation as one of the world’s leading DevSecOps platforms, a newly disclosed vulnerability chain demonstrates how a seemingly harmless feature can become the starting point of a devastating attack.

Researchers from Depthfirst have revealed a sophisticated Remote Code Execution (RCE) exploit chain affecting GitLab Community Edition (CE) and Enterprise Edition (EE). Surprisingly, the vulnerability was not introduced directly by GitLab itself but originated from Oj, a high-performance native C-based JSON parser for Ruby that had quietly contained multiple memory corruption bugs for nearly five years.

Even more concerning is that the exploit begins with GitLab’s notebook comparison feature, a component few administrators would ever consider to be a critical security risk. By combining two independent memory corruption vulnerabilities, researchers successfully achieved arbitrary command execution without requiring administrator privileges or user interaction.

GitLab RCE Chain Discovered After Years of Remaining Invisible

The vulnerability chain remained undiscovered for almost five years before security researchers connected several low-level memory corruption issues inside the Oj Ruby gem with GitLab’s notebook diff rendering engine.

Whenever a developer uploads or modifies a Jupyter Notebook (.ipynb) file inside a GitLab repository, GitLab automatically parses the notebook’s JSON structure in order to generate a readable visual comparison between revisions.

Instead of processing the JSON using

Oj::Parser.usual.parse

Although this appears to be a normal Ruby function call, execution quickly transitions into Oj’s native C extension running inside GitLab’s Puma worker process under the git user account.

That transition into native memory management is precisely where the attack begins.

How the Exploit Starts Inside the Notebook Diff Renderer

Unlike traditional GitLab vulnerabilities that target authentication systems or web interfaces, this attack abuses GitLab’s automatic notebook comparison engine.

An authenticated project member with permission to push commits can upload specially crafted Jupyter Notebook files containing malicious JSON structures.

Simply requesting the notebook diff causes GitLab to parse attacker-controlled JSON.

No administrator approval is required.

No phishing attack is necessary.

No victim interaction is involved.

The parser itself becomes the victim.

First Memory Corruption Bug Creates an Out-of-Bounds Write Primitive

The first vulnerability exists inside

Internally, the parser maintains a fixed 1,024-byte stack buffer to monitor nested JSON arrays.

Unfortunately, developers failed to verify whether deeply nested arrays exceeded that limit.

As parsing continues beyond the expected nesting depth, the parser writes repeated 0x01 bytes outside the allocated buffer.

This seemingly small programming mistake gradually corrupts adjacent memory, eventually overwriting one of Oj’s internal buffer pointers named:

buf.head

Researchers demonstrated that carefully structured JSON containing a 4,001-digit number together with a 446-element array could manipulate the heap allocator (jemalloc) into positioning attacker-controlled memory exactly where Oj later expects legitimate callback structures.

This process, commonly known as heap grooming, transforms a simple memory overwrite into reliable control over internal parser behavior.

Second Vulnerability Leaks Critical Memory Addresses

Achieving reliable code execution typically requires bypassing Address Space Layout Randomization (ASLR).

Fortunately for attackers, the second Oj vulnerability provides exactly what they need.

Oj stores JSON object key lengths inside a truncated 16-bit field.

When extremely large object keys are processed, their original 64-bit size becomes truncated.

This integer truncation causes the parser to unintentionally expose 29 bytes of internal heap memory through GitLab’s notebook diff output.

Those leaked bytes contain valuable information, including active heap pointers.

With a valid heap address exposed, researchers gained a reliable reference point inside the process memory.

ASLR Protection Falls Through Memory Disclosure

GitLab deploys Puma workers using a preloaded cluster model.

Because workers are forked from a common parent process, they inherit identical shared library mappings.

After leaking one heap pointer, researchers compared known memory offsets until they successfully calculated the locations of critical shared libraries including:

libc

libruby

Using repeated callback-controlled probes, they brute-forced the correct memory layout within only a few minutes.

Once ASLR protections were defeated, arbitrary code execution became significantly easier.

Final Stage Hijacks Program Execution

The final exploit chain relies on two carefully crafted notebook files submitted in lexical order.

The first notebook silently prepares memory corruption and overwrites Oj’s callback pointer.

The second notebook immediately triggers another parser invocation during the same GitLab diff request.

When Oj attempts to invoke its callback, execution no longer follows legitimate code.

Instead, control flow jumps directly into:

system()

At that point, attackers gain the ability to execute arbitrary operating system commands with the permissions of GitLab’s git account.

This effectively provides Remote Code Execution against the GitLab server.

Affected GitLab and Oj Versions

The vulnerability impacts multiple supported GitLab releases before security patches became available.

Affected GitLab Versions

GitLab CE/EE 15.2.0 – 18.10.7 → Fixed in 18.10.8

GitLab CE/EE 18.11.0 – 18.11.4 → Fixed in 18.11.5

GitLab CE/EE 19.0.0 – 19.0.1 → Fixed in 19.0.2

Affected Oj Versions

Oj 3.13.0 – 3.17.1

Fixed in Oj 3.17.3

Organizations running vulnerable versions should prioritize upgrading immediately.

Nine Additional Security Vulnerabilities Raise Broader Concerns

The same security audit uncovered nine separate CVEs affecting the Oj library.

Researchers identified multiple categories of memory safety issues, including:

Buffer overflows

Heap overflows

Use-after-free vulnerabilities

Integer overflows

Memory corruption across parser APIs

Loader vulnerabilities

Dumper API flaws

The findings demonstrate that native C extensions embedded inside otherwise memory-safe Ruby ecosystems remain an overlooked attack surface.

While Ruby itself offers significant memory safety compared to C, native extensions bypass those protections entirely.

Deep Analysis

This disclosure is another reminder that application security extends far beyond the visible source code. Organizations often trust mature third-party libraries without continuously reassessing their security posture. The Oj vulnerabilities illustrate how a low-level dependency can compromise an enterprise platform like GitLab.

Several technical lessons emerge from this research:

Native extensions written in C continue to introduce classic memory corruption risks.

Memory-safe programming languages cannot fully protect applications when unsafe native code is integrated.

Features considered “low risk,” such as notebook diff rendering, can become unexpected attack vectors.

Chaining multiple “minor” vulnerabilities often produces a critical exploit.

Information disclosure bugs remain powerful because they help defeat modern exploit mitigations like ASLR.

Routine fuzz testing and code audits should include third-party dependencies, not just application code.

Useful Defensive Commands

Check your GitLab version

gitlab-rake gitlab:env:info

Verify installed Oj version

bundle list | grep oj

Update Ruby dependencies

bundle update oj

Upgrade GitLab packages

sudo apt update
sudo apt install gitlab-ee

or

sudo apt install gitlab-ce

Restart GitLab after updates

sudo gitlab-ctl restart

Search for suspicious notebook files

find /var/opt/gitlab -name ".ipynb"

Review GitLab logs

sudo gitlab-ctl tail
What Undercode Say:

This vulnerability chain is an excellent example of why software supply chain security has become one of the biggest challenges facing modern enterprises. GitLab itself was not fundamentally broken—the real issue originated in a trusted dependency that had silently carried exploitable memory corruption bugs for years.

The attack also highlights an important misconception within the development community: adopting a memory-safe language does not automatically eliminate memory safety risks. Whenever applications integrate native C or C++ extensions for performance reasons, they reintroduce the very vulnerabilities that memory-safe languages are designed to prevent.

Another noteworthy aspect is the creativity of the exploit. Researchers did not rely on a single catastrophic bug. Instead, they combined an out-of-bounds write, an information disclosure flaw, heap grooming, callback pointer manipulation, and ASLR bypass into a reliable exploit chain. This reflects the growing sophistication of offensive security research.

For organizations using GitLab, the lesson is clear: patch management must extend beyond the main application and include all bundled libraries and dependencies. Continuous dependency audits, automated software composition analysis (SCA), and memory fuzzing should become standard practices.

The disclosure may also influence the broader Ruby ecosystem. Native gems that prioritize performance over memory safety are likely to face increased scrutiny, with maintainers encouraged to adopt safer coding practices, stronger compiler protections, and more extensive testing.

From a defensive perspective, monitoring unusual activity around notebook uploads, parser crashes, and repeated diff requests could provide early indicators of exploitation attempts. Security teams should also validate that only trusted users have repository push access, as this exploit requires authenticated project membership.

Ultimately, this case reinforces a broader industry trend: attackers are increasingly targeting hidden components rather than obvious entry points. As software ecosystems grow more interconnected, every dependency deserves the same level of security attention as the primary application itself.

✅ Fact: GitLab confirmed that affected CE and EE versions received security updates, and patched releases were issued to address the vulnerability chain.

✅ Fact: The disclosed exploit relies on vulnerabilities within the Oj Ruby gem rather than flaws introduced directly into GitLab’s core application logic.

✅ Fact: The security research identified multiple memory safety issues, including additional vulnerabilities beyond the primary exploit chain, emphasizing that native C extensions remain a significant security concern despite being used within memory-safe language ecosystems.

Prediction

(+1) Positive Prediction

The disclosure is likely to accelerate security improvements across the Ruby ecosystem. More projects will adopt automated dependency auditing, continuous fuzz testing, and stricter reviews of native C extensions. GitLab and similar DevSecOps platforms may also introduce stronger isolation for auxiliary features such as notebook rendering, reducing the likelihood that a single vulnerable library can compromise an entire application. In the long term, this incident will encourage developers to balance performance with memory safety, leading to more resilient software supply chains and stronger defenses against complex exploit chains.

▶️ Related Video (80% Match):

🕵️‍📝Let’s dive deep and fact‑check.

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

References:

Reported By: cyberpress.org
Extra Source Hub (Possible Sources for article):
https://www.discord.com
Wikipedia
OpenAi & Undercode AI

Image Source:

Unsplash
Undercode AI DI v2

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeNews & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky | 🐘Mastodon | 📺Youtube