Redis RCE via Malicious Module Load
Redis 4.0 introduced external module support — loadable .so files that extend Redis with custom commands. A malicious module can register a command that executes arbitrary OS commands on the host. The module must first reach the target filesystem, then be loaded with MODULE LOAD. This technique works on Redis 4+ and does not depend on the target OS distribution — unlike CVE-2022-0543, it is not Debian-specific.
Prerequisites Check
1 – Redis version is 4.0 or above:
Version 4.0.0 or higher required.
2 – CONFIG access:
Must return a path. CONFIG is needed to write the module to disk via BGSAVE.
3 – MODULE command is not disabled:
An empty list or (empty array) is fine — it means no modules are loaded yet. An error like ERR unknown command 'module' means MODULE is disabled. If disabled, this technique will not work.
Step 1 – Get the exp.so Module
Clone the RedisModulesSDK repository which includes a precompiled exp.so:
The exp.so file registers two commands: system.exec (runs a command and returns output) and system.rev (opens a reverse shell).
If the precompiled binary does not work (architecture mismatch), compile from source:
Requires gcc and the Redis source headers — check the README for dependencies.
Step 2 – Deliver exp.so to the Target
Option A – Via Redis BGSAVE write:
Host the module on your attack box temporarily, then use Redis to write it. This only works cleanly if you can control binary content — easier with the master-slave technique. For a direct CONFIG write approach:
Then write the module content as a key (works for small modules, but RDB encoding may corrupt binary):
For reliable binary delivery, use the master-slave replication technique which handles binary data cleanly — see https://hackindex.io/services/redis/exploitation/master-slave-replication.
Option B – Via a shell you already have:
If you have any shell on the target (from another service or prior exploitation), upload exp.so directly:
Or via a web server:
Step 3 – Load the Module
OK
Confirm it loaded:
Step 4 – Execute Commands
Run any OS command and get output:
Get a reverse shell:
Step 5 – Unload and Clean Up
Remove the module after use:
Delete the uploaded file from the target if you have shell access:
References
-
RedisModulesSDKgithub.com/n0b0dyCN/RedisModulesSDK (opens in new tab)
n0b0dyCN Malicious Redis module source and precompiled exp.so with system.exec and system.rev commands.
-
Redis Modules APIredis.io/docs/latest/develop/reference/modules (opens in new tab)
Official module loading and command registration documentation.
Was this helpful?
Your feedback helps improve this page.