CVE-2025-49112
Executive Summary
CVE-2025-49112 is a low-severity vulnerability in the Valkey in-memory data store, affecting versions through 8.1.1. The flaw resides in the setDeferredReply function within networking.c, where an integer underflow can occur when calculating prev->size - prev->used. This condition can lead to a denial of service (DoS) by causing unexpected behavior or crashes in the server process. The vulnerability has a CVSS score of 3.1, indicating low impact, but it is currently unpatched, making it a potential risk for systems running affected versions. No public proof-of-concept (PoC) or exploit code is available at this time.
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
CVSS Breakdown & Threat Level
- CVSS Score: 3.1 (Low)
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely.
- Attack Complexity: High (AC:H) – Exploitation requires specific conditions or knowledge of the server state.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action required.
- Scope: Unchanged (S:U) – The impact is confined to the vulnerable component.
- Confidentiality Impact: None (C:N) – No data exposure.
- Integrity Impact: None (I:N) – No data modification.
- Availability Impact: Low (A:L) – Potential for service degradation or crash.
Threat Level: Low. The high attack complexity and low availability impact reduce the immediate risk, but the lack of a patch means that systems running Valkey 8.1.1 or earlier are exposed to potential DoS attacks.
Deep Dive & Mechanics
The vulnerability is located in the setDeferredReply function in networking.c. This function is responsible for managing deferred replies in Valkey’s networking layer. The issue arises from an integer underflow in the expression prev->size - prev->used. If prev->used is greater than prev->size, the subtraction results in a negative value, which is interpreted as a large unsigned integer due to C’s integer promotion rules. This can lead to incorrect memory allocation or buffer handling, potentially causing a crash or denial of service.
The root cause is a lack of validation before performing the subtraction. An attacker could craft specific network requests that manipulate the prev->used field to exceed prev->size, triggering the underflow. This is a classic CWE-191 (Integer Underflow) vulnerability.
Vulnerable vs. Patched Code
Vulnerable Code (Valkey <= 8.1.1):
// In setDeferredReply function
size_t remaining = prev->size - prev->used;
// No check for underflow
Patched Code (Hypothetical):
// In setDeferredReply function
if (prev->used > prev->size) {
// Handle error or reset
prev->used = prev->size;
}
size_t remaining = prev->size - prev->used;
The patch would add a bounds check to ensure prev->used does not exceed prev->size before performing the subtraction, preventing the underflow.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Lab Setup:
- Install Valkey 8.1.1 on a test server (e.g., Ubuntu 22.04).
- Configure Valkey to listen on a network interface.
- Use a custom Python script to send malformed requests.
Exploit Attempt:
import socket
def trigger_underflow(target_ip, target_port=6379):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((target_ip, target_port))
# Craft a request that manipulates deferred reply state
# This is a placeholder; actual exploit requires deep protocol knowledge
payload = b"*3\r\n$3\r\nSET\r\n$1\r\nx\r\n$1\r\ny\r\n"
sock.send(payload)
response = sock.recv(1024)
print(response)
sock.close()
if __name__ == "__main__":
trigger_underflow("192.168.1.100")
Note: No public exploit exists; this is a conceptual demonstration.
Blue Team (Defense & Detection)
Detection:
- Monitor Valkey logs for crashes or unexpected behavior.
- Use network monitoring to detect anomalous requests.
Mitigation:
- Restrict network access to Valkey servers.
- Apply rate limiting to reduce attack surface.
- Monitor for integer underflow patterns in logs.
Indicators of Compromise (IOCs)
- Network: Unusual Valkey requests with large or malformed payloads.
- Logs: Valkey crash logs containing references to
setDeferredReplyor integer underflow. - System: Unexpected Valkey process termination or high CPU usage.
Detection Engineering
YARA Rule
rule CVE_2025_49112_Valkey_Underflow {
meta:
description = "Detects Valkey binary with integer underflow vulnerability in setDeferredReply"
author = "Valters IT"
date = "2025-04-10"
cve = "CVE-2025-49112"
strings:
$code1 = "prev->size - prev->used" ascii wide
$code2 = "setDeferredReply" ascii wide
condition:
$code1 and $code2
}
Sigma Rule
title: CVE-2025-49112 Valkey Integer Underflow
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects potential exploitation of Valkey integer underflow vulnerability
author: Valters IT
date: 2025-04-10
logsource:
category: application
product: valkey
detection:
selection:
EventID: 1000 # Example crash event
Message: "*setDeferredReply*"
condition: selection
falsepositives:
- Legitimate Valkey crashes due to other reasons
level: low
Suricata Rule
alert tcp any any -> any 6379 (msg:"CVE-2025-49112 Valkey Integer Underflow Attempt"; flow:to_server; content:"*3|0d 0a|"; depth:4; content:"SET"; distance:0; within:10; reference:cve,2025-49112; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Monitor Valkey servers for crashes and apply workarounds if possible.
- Restrict network access to trusted hosts only.
Long-term Fix:
- Apply a patch when available from the Valkey project.
- Upgrade to a patched version once released.
Workarounds:
- Disable deferred replies if not needed (configuration change).
- Use a web application firewall (WAF) to filter malicious requests.
Valters IT
Securing Digital Frontiers