Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

eranhd
Copy link
Contributor

@eranhd eranhd commented Jan 6, 2025

No description provided.

tezc added 3 commits January 6, 2025 14:18
Fix potential crash due to missing validation for number of keys argument on cms.merge

To reproduce:
```
CMS.INITBYPROB c1 0.001 0.01
CMS.MERGE c1 -1 c1
```

Negative argument makes an alloc size calculation negative. This negative number overflows and becomes a huge number when it is passed to `RM_Calloc()`. It triggers OOM panic.

```
2024-04-22 11:10:25 === REDIS BUG REPORT START: Cut & paste starting from here ===
2024-04-22 11:10:25 9:M 22 Apr 2024 08:10:25.489 # ------------------------------------------------
2024-04-22 11:10:25 9:M 22 Apr 2024 08:10:25.489 # !!! Software Failure. Press left mouse button to continue
2024-04-22 11:10:25 9:M 22 Apr 2024 08:10:25.489 # Guru Meditation: Redis aborting for OUT OF MEMORY. Allocating 16033030816760063908 bytes! #server.c:6835
2024-04-22 11:10:25
2024-04-22 11:10:25 ------ STACK TRACE ------
2024-04-22 11:10:25
2024-04-22 11:10:25 Backtrace:
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(redisOutOfMemoryHandler+0x36)[0x558b0662a1b6]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(RM_Calloc+0x74)[0x558b066f8e54]
2024-04-22 11:10:25 /opt/redis-stack/lib/redisbloom.so(NewCMSketch+0x68)[0x7fe2cfa28ab8]
2024-04-22 11:10:25 /opt/redis-stack/lib/redisbloom.so(CMSketch_Create+0x166)[0x7fe2cfa28596]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(RedisModuleCommandDispatcher+0xae)[0x558b066f9c0e]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(call+0x186)[0x558b06618226]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(processCommand+0xba9)[0x558b06619559]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(processInputBuffer+0x107)[0x558b0663e387]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(readQueryFromClient+0x368)[0x558b0663e908]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(+0x1c9b9c)[0x558b06747b9c]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(aeMain+0xf9)[0x558b0660ddd9]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(main+0x3df)[0x558b0660263f]
2024-04-22 11:10:25 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90)[0x7fe2d205dd90]
2024-04-22 11:10:25 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80)[0x7fe2d205de40]
2024-04-22 11:10:25 /opt/redis-stack/bin/redis-server *:6379(_start+0x25)[0x558b06602e05]
```

(cherry picked from commit 2b055d4)
MOD-6970 Fix possible crash on cms.initbydim and cms.initbyprob

Fix possible crash on cms.initbydim and cms.initbyprob

We allocate memory according to cms.initbydim and cms.initbyprob
command arguments. Currently, we are missing overflow checks. In case
of misuse or malicious input, we may try to allocate huge memory.
In other case, overflow may go undetected and later crash on another
 command:

```
CMS.INITBYDIM key 8589934592 8589934592
CMS.INCRBY key val 1
```

(cherry picked from commit fcad365)
(cherry picked from commit e656c7c)
@eranhd eranhd merged commit e57ad64 into 2.4 Jan 6, 2025
13 of 14 checks passed
@eranhd eranhd deleted the 2.4-cve branch January 6, 2025 14:33
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.

2 participants