Skip to content

Delay full sync during yielding Lua scripts to prevent use-after-free (CVE-2026-23631)#3627

Merged
madolson merged 2 commits into
valkey-io:9.0from
ranshid:9.0.0-CVE-2026-23631
May 5, 2026
Merged

Delay full sync during yielding Lua scripts to prevent use-after-free (CVE-2026-23631)#3627
madolson merged 2 commits into
valkey-io:9.0from
ranshid:9.0.0-CVE-2026-23631

Conversation

@ranshid

@ranshid ranshid commented May 5, 2026

Copy link
Copy Markdown
Member

During a full sync, the functions/scripting engine is freed right before loading the RDB from the primary. If a Lua script is still running and yielding via the long-command mechanism at that moment, the freed engine can be accessed when the script resumes, causing a use-after-free.

Add a guard at the top of replicaReceiveRDBFromPrimaryToMemory() to check isInsideYieldingLongCommand() and return early, deferring the sync processing until the script completes.

No validating test was added because the vulnerability is a race condition between a yielding Lua script and a replication event handler, which cannot be reliably triggered in a deterministic Tcl test.

ikolomi and others added 2 commits April 29, 2026 14:32
… (CVE-2026-23631)

During a full sync, the functions/scripting engine is freed right before
loading the RDB from the primary. If a Lua script is still running and
yielding via the long-command mechanism at that moment, the freed engine
can be accessed when the script resumes, causing a use-after-free.

Add a guard at the top of replicaReceiveRDBFromPrimaryToMemory() to
check isInsideYieldingLongCommand() and return early, deferring the
sync processing until the script completes.

No validating test was added because the vulnerability
is a race condition between a yielding Lua script and a replication event handler,
which cannot be reliably triggered in a deterministic Tcl test.

Signed-off-by: ikolomi <ikolomin@amazon.com>
@madolson madolson marked this pull request as ready for review May 5, 2026 22:37
@madolson madolson merged commit 658237c into valkey-io:9.0 May 5, 2026
58 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants