/

CVE-2025-67733

Severity:

HIGH RISK

(8.5)

Injection in Valkey Lua Scripting Error Handling

CVE-2025-67733

Modified

Vulnerability type

Category:

Injection

CWE:

CWE-74, CWE-170

Impact:

Response Tampering and Data Integrity Compromise

Severity:

HIGH RISK

(8.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Valkey's Lua scripting error handling previously allowed a malicious user to inject arbitrary data into the server's response stream by abusing improperly handled null characters.

In deployments where multiple logical users share the same client connection, this can corrupt responses or return attacker-controlled data to other users over that shared connection.

Affected context

This vulnerability appears in Valkey instances that:

  • Enable and use Lua scripting capabilities
  • Allow untrusted or partially trusted clients to execute scripts
  • Use client connection pooling, multiplexing, or shared connections between different application users

The problem specifically arises when Lua script errors are generated and returned, and the error handling logic fails to safely process embedded null characters, allowing crafted content to spill into the response stream.

Exploit preconditions

  • Attack surface: Valkey Lua scripting interface exposed to clients (e.g., via application backends or direct access).
  • Required access: Ability to send scripting commands and supply controlled Lua code or arguments to a Valkey instance.
  • Trigger point: Execution of a Lua script that intentionally triggers an error condition containing specially crafted data, including null characters.
  • Why exploitation is possible: The error handling code for Lua scripts does not properly neutralize or delimit null characters, enabling attackers to inject arbitrary information into the response stream and affect subsequent responses on the same connection.

Why this happens

The underlying issue is improper neutralization of special elements in output that forms part of a structured response, mapping to CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.

By not handling null characters correctly in Lua script error messages, the server's response framing becomes unreliable: injected bytes can break expected message boundaries, causing data intended for one client operation to be corrupted, merged with, or replaced by attacker-controlled content.

Conceptually, this is an output encoding and protocol-framing flaw, where the system assumes error text is benign and fails to sanitize characters that have special meaning to the response parser or downstream consumer.

Potential impact

  • Response tampering on a shared connection, where other users may receive attacker-injected data.
  • Corruption of application-level protocol framing between the application and Valkey.
  • Misleading or incorrect data being returned to the application, potentially influencing business logic.
  • Undermining of data integrity guarantees, leading to subtle bugs or security checks being bypassed due to corrupted responses.
  • Potential information exposure if injected responses cause the application to log or display internal data in unexpected ways.

General mitigation guidance

Effective mitigation centers on hardening error handling and response construction boundaries:

  • Ensure that error messages and script outputs are treated as untrusted text and are strictly encoded or sanitized before being placed on the wire.
  • Enforce clear response framing rules so that special characters (including null bytes) cannot escape their intended field or segment.
  • Prefer protocols and client libraries that do not multiplex different security principals over the same low-level Valkey connection, reducing cross-user impact if response corruption occurs.
  • Apply defense-in-depth by validating and constraining Lua script inputs and outputs, limiting the ability of untrusted users to create arbitrary or unexpected error messages.
  • Use least-privilege principles for scripting access, reserving script execution for trusted components and restricting direct script access from low-trust clients.

How teams detect issues like this

Organizations can detect and monitor for this class of issue using:

  • Static analysis and code review: Look for error handling paths that concatenate raw script output or error text directly into protocol responses without sanitization or encoding, especially where null characters or control characters are possible.
  • Protocol-level testing: Use fuzzing or integration tests that send Lua scripts designed to generate unusual error messages (including embedded nulls and control characters) and validate that responses remain well-framed and parseable.
  • Runtime monitoring: Instrument Valkey clients and proxies to detect malformed or unexpected response frames, such as truncated messages, unexpected delimiters, or inconsistent length fields.
  • Security gateways and automated tools: Employ reverse proxies or security gateways with protocol-awareness that can flag anomalous responses and apply generic output sanitization policies where feasible.

Sources

SourceLink
github.comgithub.com/valkey-io/valkey/security/advisories/GHSA-p876-p7q5-hv2m
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3443
access.redhat.comaccess.redhat.com/errata/RHSA-2026:3507
access.redhat.comaccess.redhat.com/errata/RHSA-2026:5445
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-67733
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2442025
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-67733.json

Frequently asked

questions

Yes, if an attacker can reach a Valkey instance (directly or via an application) and execute Lua scripts or cause script errors, they can attempt to inject data into response streams over that connection.

The attacker needs the ability to issue Lua scripting commands or indirectly control script inputs that the server executes. They do not necessarily need administrative privileges, but they must be able to trigger script execution that results in controlled error messages.

The safest pattern is to strictly sanitize and encode all error messages and script outputs before they are included in protocol responses, ensuring that special characters such as null bytes cannot alter response framing. Additionally, ensure the response parser on the client side correctly handles and validates message boundaries.

Design error handling and protocol layers with explicit framing and robust encoding rules, treat all script-generated content as untrusted, and use automated testing and code review to verify that control characters cannot escape their intended context. Avoid multiplexing different trust levels over a single low-level connection so that any response corruption cannot affect unrelated users.

Find out what's already
exploitable in your codebase.