Repository navigation
Fix out-of-bounds read in getNodeByQuery's cross-DB COPY check - #4301
Conversation
The cross-DB COPY guard added in valkey-io#1671 checked `margc >= 4` but then dereferenced `margv[4]`, one past the end of the argument vector. COPY has arity -3, so `COPY k1 k2 DB` (argc == 4) passes the arity check in processCommand and reaches getNodeByQuery before copyCommand's own parser gets a chance to reject it as a syntax error. On a cluster with a slot in migrating or importing state this crashes the server: SIGSEGV in getLongLongFromObject <- getNodeByQuery <- processCommand The same guard was also order-dependent. COPY's DB and REPLACE tokens are optional and order-independent, and DB may be repeated, but the guard only looked at argv[3]. `COPY k1 k2 REPLACE DB 1` therefore skipped the check entirely and performed a cross-DB copy during slot migration, which is exactly what the guard exists to prevent, while the equivalent `COPY k1 k2 DB 1 REPLACE` was correctly blocked. Scan every DB clause the way copyCommand does, and leave a DB token with no value for copyCommand to reject as a syntax error. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Madelyn Olson <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesCOPY cluster validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The single commit ( |
There was a problem hiding this comment.
One design point inline: copyDbIdArgs() already implements this exact scan and is reachable from here as mcmd->get_dbid_args. The out-of-bounds read itself and the order-dependence both look correctly closed — the new scan stays aligned with copyCommand's parse for every syntactically valid argument form, so a cross-DB DB clause can't slip past it. DCO sign-off is noted separately in a PR comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #4301 +/- ##
============================================
+ Coverage 76.85% 76.86% +0.01%
============================================
Files 162 162
Lines 81487 81494 +7
============================================
+ Hits 62625 62642 +17
+ Misses 18862 18852 -10
🚀 New features to boost your workflow:
|
33b7bad to
41cfce1
Compare
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cross-DB `COPY` guard in `getNodeByQuery()` (added in #1671) checks `margc >= 4` but then dereferences `margv[4]`: ```c if (mcmd->proc == copyCommand && margc >= 4 && !strcasecmp(objectGetVal(margv[3]), "db")) { long long value; if (getLongLongFromObject(margv[4], &value) != C_OK || ... ``` `COPY` has arity `-3`, so `COPY k1 k2 DB` (`argc == 4`) passes the arity check in `processCommand()` and reaches `getNodeByQuery()` — which runs *before* `copyCommand()`'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbage `robj *` is dereferenced. Reproduced on a two-node cluster (`cluster_state:ok`) with one slot `MIGRATING`: ``` control: COPY {b}k1 {b}k2 DB 0 -> TRYAGAIN ... (server survives) trigger: COPY {b}k1 {b}k2 DB -> Server closed the connection ``` ``` === VALKEY BUG REPORT START === crashed by signal: 11, si_code: 2 0 valkey-server getLongLongFromObject + 28 1 valkey-server getNodeByQuery + 1312 2 valkey-server processCommand + 1128 ``` Reaching the check requires the slot to be in migrating or importing state (`cluster.c` short-circuits otherwise), i.e. during a resharding. `COPY`'s `DB` and `REPLACE` tokens are optional and order-independent, and `DB` may appear more than once (`copyCommand()` keeps the last value — see the note above `copyDbIdArgs()`), but the guard only inspected `argv[3]`. So the check was silently skipped whenever `REPLACE` came first. On the same cluster, both keys present, slot migrating: ``` COPY {b}k1 {b}k2 DB 1 REPLACE -> TRYAGAIN ... (correctly blocked) COPY {b}k1 {b}k2 REPLACE DB 1 -> 1 (cross-DB copy went through) ``` The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent. Scan every `DB` clause the way `copyCommand()` does, instead of hardcoding `argv[3]`/`argv[4]`. A `DB` token with no value is left alone so `copyCommand()` reports the syntax error. Behavior with the fix, same setup: | command | before | after | |---|---|---| | `COPY k1 k2 DB` | **SIGSEGV** | `ERR syntax error` | | `COPY k1 k2 REPLACE DB` | `ERR syntax error` | `ERR syntax error` | | `COPY k1 k2 REPLACE DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 1 REPLACE` | `TRYAGAIN ...` | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 DB 1` | `1` (cross-DB copy) | `TRYAGAIN ...` | | `COPY k1 k2 DB 0 REPLACE` | `1` | `1` | | `COPY k1 k2 REPLACE DB 0` | `1` | `1` | Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it; `unit/cluster/slot-migration`, `unit/cluster/multidb` and `unit/keyspace` all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [valkey/valkey](https://github.com/valkey-io/valkey) | patch | `9.1.1` → `9.1.2` | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/6) for more information. --- ### Release Notes <details> <summary>valkey-io/valkey (valkey/valkey)</summary> ### [`v9.1.2`](https://github.com/valkey-io/valkey/releases/tag/9.1.2) [Compare Source](valkey-io/valkey@9.1.1...9.1.2) ## Valkey 9.1.2 - Released Mon 31 August 2026 Upgrade urgency SECURITY: This release includes security fixes we recommend you apply as soon as possible. ##### Security Fixes - GHSA-jcj7-v34w-v9vv: Fix a use-after-free in RDMA connection handling that could allow an authenticated client to crash the server using CLIENT KILL. Only affects servers built with USE\_RDMA and configured with an RDMA listener ([#​4534](valkey-io/valkey#4534)) - GHSA-fq2f-crmw-q97r: Fix an unauthenticated use-after-free of the Lua interpreter state, caused by a process-global script debugger command table that cached a raw pointer to a freed interpreter and was never invalidated ([#​4574](valkey-io/valkey#4574)) ##### Bug Fixes - Fix a double-free crash when a module timer callback stops its own timer with `ValkeyModule_StopTimer` by [@​quanyeyang](https://github.com/quanyeyang) ([#​4211](valkey-io/valkey#4211)) - Fix torn RESP3 push frames when a client publishes to a channel it is also subscribed to, which could desync client libraries by [@​quanyeyang](https://github.com/quanyeyang) ([#​4253](valkey-io/valkey#4253)) - Listpacks are now always validated on RDB load and RESTORE, preventing deferred assertion crashes; `sanitize-dump-payload` and its ACL flags become no-ops by [@​jjuleslasarte](https://github.com/jjuleslasarte) ([#​3721](valkey-io/valkey#3721)) - Fix crashes, hangs, and CPU spinning when the RDMA transport is used together with I/O threads by [@​quanyeyang](https://github.com/quanyeyang) ([#​3611](valkey-io/valkey#3611)) - RESET now clears the `CLIENT IMPORT-SOURCE` flag, so reused pooled connections return to normal expiration semantics by [@​tjade273](https://github.com/tjade273) ([#​3973](valkey-io/valkey#3973)) - Truncate a partially written MULTI block from the AOF on short read, preventing loss of newer writes after a later restart by [@​chzhoo](https://github.com/chzhoo) ([#​4342](valkey-io/valkey#4342)) - Fix an ACL bypass where duplicate STORE/STOREDIST options let GEORADIUS write or delete keys outside the user's permitted patterns by [@​tjade273](https://github.com/tjade273) ([#​3971](valkey-io/valkey#3971)) - Fix command log redaction leaking between commands in a MULTI transaction and missing for commands executed from scripts by [@​madolson](https://github.com/madolson) ([#​4323](valkey-io/valkey#4323)) - Fix a use-after-free crash when a module's cluster message type is received after the module is unloaded by [@​enjoy-binbin](https://github.com/enjoy-binbin) ([#​4360](valkey-io/valkey#4360)) - Fix out-of-bounds access for cluster module message type 255, which is now a valid, dispatchable message type by [@​enjoy-binbin](https://github.com/enjoy-binbin) ([#​4410](valkey-io/valkey#4410)) - AOF loading no longer performs ACL checks on replayed commands, preventing silent data loss when the default user is disabled by [@​lukepalmer](https://github.com/lukepalmer) ([#​3984](valkey-io/valkey#3984)) - Fix a client memory accounting leak on replicas that inflated the `mem_clients_normal` INFO field after primary disconnections by [@​enjoy-binbin](https://github.com/enjoy-binbin) ([#​4395](valkey-io/valkey#4395)) - Fix a permanent client deadlock when a blocking command like BLPOP is followed by a partially delivered pipelined command by [@​foobar](https://github.com/foobar) ([#​4531](valkey-io/valkey#4531)) - HGETEX now requires write permission on the key, closing an ACL gap that let read-only users change field TTLs or delete fields by [@​ranshid](https://github.com/ranshid) ([#​4576](valkey-io/valkey#4576)) - Compare the whole TLS certificate CN during authentication, so an embedded NUL can no longer impersonate another ACL user by [@​madolson](https://github.com/madolson) ([#​4577](valkey-io/valkey#4577)) - Fix atomic slot migration failures with I/O threads by not offloading the export job's writes while snapshotting by [@​satheeshaGowda](https://github.com/satheeshaGowda) ([#​4104](valkey-io/valkey#4104)) - Reject invalid slot import ranges when loading an RDB, so corrupted files can no longer create bad migration jobs by [@​enjoy-binbin](https://github.com/enjoy-binbin) ([#​4229](valkey-io/valkey#4229)) - Reject RDB slot import records with an invalid job name length, preventing an out-of-bounds read at startup by [@​quanyeyang](https://github.com/quanyeyang) ([#​4210](valkey-io/valkey#4210)) - MOVE and COPY now check ACL access to the current database, so users can no longer exfiltrate keys from an unauthorized DB by [@​cjx-zar](https://github.com/cjx-zar) ([#​4155](valkey-io/valkey#4155)) - Fix a crash on COPY with a trailing DB option during slot migration, and block cross-DB COPY regardless of option order by [@​madolson](https://github.com/madolson) ([#​4301](valkey-io/valkey#4301)) - Fix a server panic when pipelined commands with invalid arity reach the key prefetcher with I/O threads enabled by [@​madolson](https://github.com/madolson) ([#​4302](valkey-io/valkey#4302)) - HPERSIST, HTTL, HPTTL, HEXPIRETIME, and HPEXPIRETIME now return a syntax error when the FIELDS keyword is missing by [@​cjx-zar](https://github.com/cjx-zar) ([#​4300](valkey-io/valkey#4300)) - Fix a race between TLS I/O-thread writes and reads that could leave slot migration export jobs stuck until timeout by [@​jjuleslasarte](https://github.com/jjuleslasarte) ([#​4320](valkey-io/valkey#4320)) - Fix a signed overflow that let very large hash field expiration times (e.g. via HPEXPIREAT) crash the server by [@​ranshid](https://github.com/ranshid) ([#​4312](valkey-io/valkey#4312)) - Fix a frozen monotonic clock on hosts with unsynchronized TSC that stopped background tasks and key expiration by [@​quanyeyang](https://github.com/quanyeyang) ([#​4346](valkey-io/valkey#4346)) - Fix a stack overflow crash when retrying a failed TLS write with a large reply by [@​murphyjacob4](https://github.com/murphyjacob4) ([#​4307](valkey-io/valkey#4307)) - Fix the `--check-system` clocksource check to skip hosts using a hardware clock and suggest only actually available clocksources by [@​quanyeyang](https://github.com/quanyeyang) ([#​4272](valkey-io/valkey#4272)) - Fix an assertion failure with I/O threads when a blocked client's pending command was processed again before unblocking by [@​quanyeyang](https://github.com/quanyeyang) ([#​4376](valkey-io/valkey#4376)) - Sentinel no longer loads the built-in Lua scripting engine, removing a spurious warning at startup by [@​enjoy-binbin](https://github.com/enjoy-binbin) ([#​4327](valkey-io/valkey#4327)) - Validate channel, message, and module payload lengths in cluster bus packets, preventing forged packets from crashing nodes by [@​tjade273](https://github.com/tjade273) ([#​3972](valkey-io/valkey#3972)) - Harden stream validation on RDB load and RESTORE so crafted payloads can no longer crash the server on later commands by [@​madolson](https://github.com/madolson) ([#​3922](valkey-io/valkey#3922)) - Reject stream payloads with mismatched live/deleted record counts, preventing XDEL from destroying unaccounted entries by [@​roshkhatri](https://github.com/roshkhatri) ([#​4381](valkey-io/valkey#4381)) - Skip unnecessary post-read processing with I/O threads on socket and TLS connections, restoring small-payload throughput by [@​quanyeyang](https://github.com/quanyeyang) ([#​4401](valkey-io/valkey#4401)) - Fix a use-after-free crash when serving clients blocked on the same key if one client is freed during processing by [@​quanyeyang](https://github.com/quanyeyang) ([#​4212](valkey-io/valkey#4212)) - Avoid an unneeded client lookup per write completion with I/O threads on socket and TLS connections, improving pipelined throughput by [@​dgershko](https://github.com/dgershko) ([#​4440](valkey-io/valkey#4440)) - Fix CLUSTER SLOT-STATS ORDERBY returning wrong ordering when slot counters differ by more than 2^31 by [@​jzy1688](https://github.com/jzy1688) ([#​4459](valkey-io/valkey#4459)) - Fix slot migration failures with I/O threads and TLS by keeping the export job's ACK reads on the main thread while snapshotting by [@​satheeshaGowda](https://github.com/satheeshaGowda) ([#​4559](valkey-io/valkey#4559)) **Full Changelog**: <valkey-io/valkey@9.1.1...9.1.2> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNC4zIiwidXBkYXRlZEluVmVyIjoiNDQuMTQuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://forge.superkooka.com/Superkooka/infra-gitops/pulls/31
Problem
The cross-DB
COPYguard ingetNodeByQuery()(added in #1671) checksmargc >= 4but then dereferencesmargv[4]:COPYhas arity-3, soCOPY k1 k2 DB(argc == 4) passes the arity check inprocessCommand()and reachesgetNodeByQuery()— which runs beforecopyCommand()'s own parser would reject it as a syntax error. The read is one past the end of the argument vector, and the resulting garbagerobj *is dereferenced.Reproduced on a two-node cluster (
cluster_state:ok) with one slotMIGRATING:Reaching the check requires the slot to be in migrating or importing state (
cluster.cshort-circuits otherwise), i.e. during a resharding.Second issue in the same guard
COPY'sDBandREPLACEtokens are optional and order-independent, andDBmay appear more than once (copyCommand()keeps the last value — see the note abovecopyDbIdArgs()), but the guard only inspectedargv[3]. So the check was silently skipped wheneverREPLACEcame first.On the same cluster, both keys present, slot migrating:
The second form performed exactly the cross-DB copy during slot migration that this guard exists to prevent.
Fix
Scan every
DBclause the waycopyCommand()does, instead of hardcodingargv[3]/argv[4]. ADBtoken with no value is left alone socopyCommand()reports the syntax error.Behavior with the fix, same setup:
COPY k1 k2 DBERR syntax errorCOPY k1 k2 REPLACE DBERR syntax errorERR syntax errorCOPY k1 k2 REPLACE DB 11(cross-DB copy)TRYAGAIN ...COPY k1 k2 DB 1 REPLACETRYAGAIN ...TRYAGAIN ...COPY k1 k2 DB 0 DB 11(cross-DB copy)TRYAGAIN ...COPY k1 k2 DB 0 REPLACE11COPY k1 k2 REPLACE DB 011Tests
Extended the existing "Cross-DB COPY command should not be allow during slot migration" test. Verified the new assertions fail on unstable without the code change and pass with it;
unit/cluster/slot-migration,unit/cluster/multidbandunit/keyspaceall pass.🤖 Generated with Claude Code