Add missing return after free on corrupted RDB buffer

fix(serializer): add missing return after free on corrupted RDB buffer (#1843)
Add missing return after free on corrupted RDB buffer523d98-fix-add-missing-return-after-free-on-cve-2026-5759fixadd missing return after free corrupted

Committed by gkorland

commit message
fix(serializer): add missing return after free on corrupted RDB buffer (#1843)

* fix(serializer): add missing return after free on corrupted RDB buffer
 
In RdbLoadDeletedNodes and RdbLoadDeletedEdges (v18, v19), a misaligned
buffer triggers rm_free() followed by ASSERT(false). In release builds
ASSERT compiles to a no-op, so execution falls through to use the freed
pointer (use-after-free) and free it again (double-free).
 
Add explicit return statements after rm_free() in all four error paths
so the functions exit immediately regardless of build configuration.
 
Co-authored-by: Copilot <[email protected]>
 
* test(serializer): add unit tests for deleted-entity buffer validation
 
Tests misaligned and aligned buffers for RdbLoadDeletedNodes_v19 and
RdbLoadDeletedEdges_v19. The misaligned tests verify the early-return
path does not cause use-after-free or double-free. The aligned tests
verify the happy path correctly marks entities as deleted.
 
Co-authored-by: Copilot <[email protected]>
 
* test(serializer): skip misaligned buffer tests in debug builds
 
In debug builds, ASSERT(false) intentionally crashes (NULL deref) before
the return statement is reached, so the misaligned buffer tests can only
exercise the early-return path in release builds. Wrap them with
#if !RG_DEBUG guards.
 
Co-authored-by: Copilot <[email protected]>
 
* fix(serializer): use RedisModule_Assert for malformed RDB buffers
 
Replace silent return with RedisModule_Log + RedisModule_Assert(false) to
notify Redis and abort on corrupted deleted-entity buffers. Also validates
buffer count matches expected count (not just alignment).
 
Extends fix to v17 decoder which had no validation in release builds.
Converts unit tests to fork-based death tests to verify abort behavior.
 
Addresses review comment: use assert+exit instead of silent return, handle
short read / malformed RDB and notify Redis.
 
Co-authored-by: Copilot <[email protected]>
 
* fix(test): use _exit in mock assert to prevent ASAN hang after fork
 
The mock RedisModule__Assert in death tests was a no-op, letting
exit(1) from RedisModule_Assert run ASAN atexit handlers in the
forked child. This hangs because ASAN tries to clean up thread-local
state that does not exist after fork(). Using _exit(1) in the mock
bypasses atexit handlers entirely.
 
Co-authored-by: Copilot <[email protected]>
 
* removed unit test
 
---------
 
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Roi Lipman <[email protected]>

Editor assessment

This commit patches CVE-2026-5759. Strong body. It explains the release-build failure mode precisely: a misaligned buffer triggers rm_free followed by ASSERT(false), which compiles to a no-op in release builds, so execution falls through to a use-after-free and a double-free. It then notes the return statements, the tests, and the later switch to RedisModule_Assert with death tests. Clear, well scoped and verifiable. Style-wise the serializer scope and fix type are accurate and the body is well separated; nothing formal is missing.

Browse categories

More fix examples · Back to search