Read the docs

Use-after-free in Valkey Lua script debugger command cache

Priority MEDIUM 53CWE-416Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
Low
Impact type
Code execution
Confidentiality · integrity · availability
High · High · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-fq2f-crmw-q97r. Fix status from GitHub. Impact type from CWE-416 and the CVSS impact.

Summary

Valkey server versions up to and including 9.1.1 are affected. The script debugger keeps a pointer to a Lua interpreter state that SCRIPT FLUSH ASYNC frees, and a later debugger command dereferences it (CWE-416). An attacker with low privileges who can run scripting commands can crash the server and may be able to control an indirect call.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

Description from the GitHub advisory

## Impact An attacker who can run scripting commands can free the Lua interpreter state out from under the script debugger's cached command table, leaving a dangling pointer that is dereferenced on the next debugger command. This yields a reliable crash of the server process, and can be escalated to control of an indirect call by reclaiming the freed heap chunk with attacker-controlled bytes. This issue affects the 9.x line. The defect was introduced when the Lua scripting engine was moved into a Valkey module. The 8.0.x and 8.1.x lines use the previous non-module debugger and are not affected. ## Details `ldbGenerateDebuggerCommandsArray` in `src/modules/lua/debug_lua.c` builds the interactive debugger command table once and caches it in a file-scope static, binding the then-current `lua_State` pointer into each command descriptor's context field. The table is never rebuilt or invalidated. `SCRIPT FLUSH ASYNC` recreates the scripting engine, creating the replacement interpreter state before freeing the previous one on the lazyfree thread. Nothing clears the cached command table, so its context is left pointing at a freed chunk. Any subsequent debugger command dereferences it. Because the freed chunk lives on the ordinary allocator heap, it can be reclaimed with attacker-controlled bytes and shaped into a counterfeit interpreter state, at which point the next allocation performed by the interpreter calls the allocator function pointer stored inside that state. A second use-after-free in `ldbLogStackValue` is fixed in the same change: the logged module string was freed while the debugger log list still held a reference to it. ## Mitigation You can mitigate this issue by using Valkey ACLs to restrict the SCRIPT command, in particular `SCRIPT DEBUG`, if your application doesn't intend to use the script debugger. ## Credits The defect was independently reported by Trung Nguyen (@everping) of CyStack, by Phuc Nguyen Dinh (pucagit) of CyStack, and Han Sang-Kyung ([email protected]). The fix was authored by https://github.com/Baraa-Hasheesh.

Why it matters now

Fix Fixed valkey-server (valkey): 9.1.2

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—valkey-server (valkey)<=9.1.19.1.2Patch availableGHSA-fq2f-crmw-q97r
  • valkey-server (valkey) Vendor— Affected <=9.1.1 Fixed in 9.1.2 Patch available GHSA-fq2f-crmw-q97r

Remediation

Upgrade valkey-server to 9.1.2, the fixed version. You can mitigate this issue by using Valkey ACLs to restrict the SCRIPT command, in particular SCRIPT DEBUG, if your application does not use the script debugger.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

  • Fix · GHSA-fq2f-crmw-q97r valkey-server (valkey) Fixed in 9.1.2 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-fq2f-crmw-q97r

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences