Skip to content

[Security] CVE-2024-31449: Stack buffer overflow in Lua bit.tohex() #3433

@jinchengyang98

Description

@jinchengyang98

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions