Summary[/+]
[+]Kvrocks uses a Lua library (RocksLabs/lua) that contains a stack buffer overflow vulnerability (CVE-2024-31449), originally from Redis's Lua bit library. The bit.tohex() function does not check for INT32_MIN before negation, causing signed integer overflow and stack buffer overflow.[/+]
[+]## Details[/+]
[+]- CVE: CVE-2024-31449[/+]
[+]- Vulnerable Code: src/lua_bit.c in RocksLabs/lua (commit f458c3d7)[/+]
[+]- Root Cause: INT32_MIN negation causes undefined behavior and buffer overflow[/+]
[+]## Reproduction[/+]
[+][/+] [+]redis-cli -p 6666 EVAL "return bit.tohex(65535, -2147483648)" 0[/+] [+][/+]
[+]## Fix[/+]
[+]Add if (n == INT32_MIN) n = INT32_MIN+1; before if (n < 0) { n = -n; ... } in bit_tohex().[/+]
[+]Upstream Redis fix: redis/redis@1f7c148
Summary[/+]
[+]Kvrocks uses a Lua library (RocksLabs/lua) that contains a stack buffer overflow vulnerability (CVE-2024-31449), originally from Redis's Lua bit library. The
bit.tohex()function does not check forINT32_MINbefore negation, causing signed integer overflow and stack buffer overflow.[/+][+]## Details[/+]
[+]- CVE: CVE-2024-31449[/+]
[+]- Vulnerable Code:
src/lua_bit.cin RocksLabs/lua (commit f458c3d7)[/+][+]- Root Cause:
INT32_MINnegation causes undefined behavior and buffer overflow[/+][+]## Reproduction[/+]
[+]
[/+] [+]redis-cli -p 6666 EVAL "return bit.tohex(65535, -2147483648)" 0[/+] [+][/+][+]## Fix[/+]
[+]Add
if (n == INT32_MIN) n = INT32_MIN+1;beforeif (n < 0) { n = -n; ... }inbit_tohex().[/+][+]Upstream Redis fix: redis/redis@1f7c148