CVE-2025-27788
Executive Summary
CVE-2025-27788 is a high-severity vulnerability in the Ruby JSON gem, affecting versions 2.10.0 and 2.10.1. The flaw is an out-of-bounds read that can be triggered by a specially crafted JSON document, leading to a denial of service (DoS) condition, most likely resulting in a crash. The vulnerability is remotely exploitable without authentication, making it a significant threat to applications that parse untrusted JSON input. No known workarounds exist, and the only remediation is to upgrade to version 2.10.2.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability resides in the json gem, a core component of the Ruby ecosystem. Applications using Ruby's built-in JSON parsing are affected if they use version 2.10.0 or 2.10.1. The gem is widely used in web frameworks (e.g., Ruby on Rails), API services, and data processing pipelines. An attacker can exploit this by sending a malicious JSON payload to any endpoint that parses JSON, causing the application to crash and resulting in a denial of service. This is a supply chain risk because the vulnerable gem is a direct dependency of many Ruby applications.
CVSS Breakdown & Threat Level
- CVSS Score: 7.5 (High)
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerability does not affect other components.
- Confidentiality (C): None (N) – No data exposure.
- Integrity (I): None (N) – No data modification.
- Availability (A): High (H) – Causes a crash, leading to denial of service.
Threat Level: High. The low attack complexity and network exploitability make this a serious threat for any Ruby application processing untrusted JSON.
Deep Dive & Mechanics
The vulnerability is an out-of-bounds read in the JSON gem's parser. When parsing a specially crafted JSON document, the parser reads memory beyond the allocated buffer. This is a classic CWE-125 (Out-of-bounds Read) issue. The root cause is likely an improper bounds check when handling certain JSON structures, such as deeply nested objects, arrays with specific lengths, or malformed escape sequences. The out-of-bounds read can cause a segmentation fault, crashing the Ruby process.
The vulnerable code path is in the C extension of the JSON gem, which is used for performance. The fix in version 2.10.2 likely adds proper bounds checking to prevent reading beyond the input buffer.
Vulnerable vs. Patched Code
The exact code change is not publicly available, but the fix is in version 2.10.2. The vulnerable code (in C) likely looks like:
// Vulnerable (2.10.0, 2.10.1)
while (pos < len) {
// No bounds check on pos
char c = input[pos];
// ... processing that can increment pos beyond len
}
The patched code (2.10.2) would add a bounds check:
// Patched (2.10.2)
while (pos < len) {
if (pos >= len) break; // Additional safety
char c = input[pos];
// ... processing with proper bounds
}
Exploitation & Lab Setup
Red Team
Objective: Cause a denial of service by crashing the Ruby application.
Lab Setup:
- Install a vulnerable Ruby environment with JSON gem 2.10.0 or 2.10.1.
- Create a simple Ruby script that parses JSON from stdin or a file.
- Craft a malicious JSON payload that triggers the out-of-bounds read.
Example Payload (Conceptual):
{"a": [{"b": [{"c": [{"d": "x" * 10000}]}]}]}
Or a deeply nested structure:
[[[[[[[[[[[[[[[[[[[[["crash"]]]]]]]]]]]]]]]]]]]]]
Exploit Execution:
echo '{"a": [{"b": [{"c": [{"d": "x" * 10000}]}]}]}' | ruby -rjson -e 'JSON.parse(STDIN.read)'
Blue Team
Detection:
- Monitor for repeated application crashes.
- Look for JSON payloads with unusual nesting depth or length.
- Use the detection rules below.
Mitigation:
- Immediately upgrade to JSON gem 2.10.2.
- If upgrade is not possible, implement a web application firewall (WAF) rule to block excessively large or deeply nested JSON payloads.
- Restrict network access to the application to trusted sources.
Indicators of Compromise (IOCs)
- Network: Incoming HTTP requests with JSON payloads containing deeply nested objects (e.g., > 100 levels) or extremely long strings.
- System: Ruby process crashes with segmentation fault (SIGSEGV) in the
jsongem's C extension. - Logs: Application logs showing
JSON::ParserErrorfollowed by a crash, orsignal SIGSEGVin the Ruby error log.
Detection Engineering
YARA Rule
rule CVE_2025_27788_JSON_OOB_Read {
meta:
description = "Detects malicious JSON payloads targeting CVE-2025-27788"
author = "Valters IT"
date = "2025-03-20"
reference = "CVE-2025-27788"
strings:
$json_start = "{" ascii wide nocase
$json_array = "[" ascii wide nocase
$deep_nest = /(\[|\{){50,}/ // 50+ opening brackets/braces
$long_string = /"[^"]{1000,}"/ // String > 1000 chars
condition:
($json_start or $json_array) and ($deep_nest or $long_string)
}
Sigma Rule
title: CVE-2025-27788 Ruby JSON Out-of-Bounds Read
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects potential exploitation of CVE-2025-27788 via HTTP requests with malicious JSON
author: Valters IT
date: 2025/03/20
logsource:
category: webserver
product: generic
detection:
selection:
http.method: POST
http.content_type: application/json
http.body|contains|all:
- '{'
- '['
condition: selection and (len(http.body) > 100000 or count(http.body, '{') > 100 or count(http.body, '[') > 100)
falsepositives:
- Legitimate large JSON payloads
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-27788 Ruby JSON Out-of-Bounds Read Attempt"; flow:to_server; content:"POST"; http_method; content:"application/json"; http_content_type; pcre:"/(\{|\[){100,}/"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate:
- Upgrade the
jsongem to version 2.10.2 or later:gem update json - If using Bundler, update your Gemfile:
gem 'json', '>= 2.10.2'and runbundle update json
Compensating Controls (if upgrade is not possible):
- Implement input validation to reject JSON payloads with excessive nesting depth (e.g., > 50 levels) or string length (e.g., > 10,000 characters).
- Use a reverse proxy or WAF to filter malicious payloads.
- Monitor for crashes and restart the application automatically.
Long-term:
- Keep all Ruby gems updated.
- Use a dependency scanner (e.g.,
bundler-audit) to detect vulnerable gems. - Consider using a safer JSON parser or sandboxing the parsing process.
Valters IT
DevSecOps & Cyber Threat Intelligence