What can anyone reaching an unauthenticated Redis do, and why restrict commands with ACLs rather than rename-command?
answer
- new connection, already fully authorized
- data, configuration and replication all reachable
- three enable-* settings still say no
- a renamed command is renamed for everyone
basics
~20 sAnyone reaching an unauthenticated Redis runs as the default user: reads every key, runs FLUSHALL, changes settings with CONFIG SET. Stock defaults still block MODULE LOAD, DEBUG and changing dir. rename-command is deprecated; ACLs restrict commands per user.
solid answer
~40 sWith `protected-mode no` and a `nopass` `default` user, a new connection is automatically authenticated as a user holding `+@all ~* &*`. So a stranger can read every key, `FLUSHALL` the data set, set `requirepass` to lock you out, or point `REPLICAOF` at their own host and have your data replaced. The stock config still blocks three things: `MODULE LOAD` and `DEBUG` through `enable-module-command no` and `enable-debug-command no`, and `CONFIG SET` of `dir` and `dbfilename` through `enable-protected-configs no`. To restrict commands, `rename-command` is the wrong tool and is deprecated: it changes the command table for every client at startup, relies on a name staying secret, and renaming commands that reach the AOF or replicas may cause problems. ACLs take `CONFIG` away from `default` and give it to a named admin. Neither replaces closing the port.
code
conf · 6 lines# Deprecated: renames it for every client, or removes it for all
# rename-command CONFIG ""
# Preferred: the same restriction, per user
user default on >long-random-app-secret ~* &* +@all -@dangerous
user admin on >long-random-admin-secret ~* &* +@allgo deeper
Recall that an unauthenticated connection runs as the default user with every command and key, and give two concrete things a stranger could do, such as reading keys and FLUSHALL.
Name what stock settings still block, through enable-protected-configs, enable-module-command and enable-debug-command, and list what stays open. Contrast rename-command's server-wide effect with per-user ACL rules.
Audit rather than assume: read the live enable-* values, look for leftover rename-command lines, and check what @dangerous would take from the application before applying it to the default user.
Set one rule: administrative commands live behind a named user, never behind a secret name. Retire rename-command from your baseline, since Redis has deprecated it and it complicates replication and tooling.
## Why one connection holds so much Redis's security page opens with the model: it is designed to be accessed by trusted clients inside trusted environments. The account model follows from that. A fresh server has one user, `default`, described as `on nopass ~* &* +@all`: enabled, no password, every key, every channel, every command. For the default user, `nopass` means a new connection is immediately authenticated without any `AUTH`. So when protected mode has been turned off and no password is set, the network is the only control left. Reaching the port is the same as being the administrator. ## What an anonymous client can still do On a stock Redis 8.10 file these all work for anyone who connects: - **Read everything:** `SCAN`, `KEYS` and `GET` walk the whole data set, sessions and tokens included. - **Destroy data:** a single `FLUSHALL` deletes the data set, which is the security page's own example. `SHUTDOWN` stops the service. - **Lock the owner out:** `CONFIG SET requirepass` is an ordinary runtime change. - **Replace the data:** `REPLICAOF` aimed at a host the client controls makes the server sync from it, discarding what it held. - **Exhaust the server:** an `EVAL` script or a `KEYS` on a large data set holds up other clients. The usual interview mistake runs in the other direction: repeating that any client can load a module or write files anywhere with `CONFIG`. That needs checking against the current defaults. ## What the stock settings still block Three settings default to `no`, and each also accepts `yes` (any connection) or `local` (loopback and Unix sockets only). | Setting | Blocks | Reply to a client | |---|---|---| | `enable-protected-configs` | `CONFIG SET` of `dir` and `dbfilename` | `can't set protected config` | | `enable-module-command` | `MODULE LOAD` | `MODULE command not allowed` | | `enable-debug-command` | `DEBUG` | `DEBUG command not allowed` | The first one matters most. Changing `dir` and `dbfilename` lets a client write RDB files to arbitrary paths, which the security page calls a route to compromising the host. That page still describes the route without mentioning this setting, so read it together with `redis.conf`. These three settings are immutable at runtime, so an attacker cannot flip them with `CONFIG SET`. A deployment that set them to `yes` to make some tool work has reopened those routes, so check the live file. Running Redis as an unprivileged user remains the recommendation either way. ## rename-command versus ACLs The older hardening advice was to hide commands: `rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52`, or rename to the empty string to remove one entirely. `redis.conf` now labels the directive deprecated, and the docs say it may be removed in future versions. | | `rename-command` | ACL rules | |---|---|---| | Scope | The whole server, every client | One user | | Applied | Read from the config at startup | `ACL SETUSER` at runtime, or config | | Admin access | Whoever learns the name, or nobody after `""` | A named user with its own password | | Protection rests on | An unguessable name | Authentication | | Side effects | Renaming commands logged to the AOF or sent to replicas may cause problems | Commands keep their names | Tools feel this too. Sentinel has to be told the new names with `SENTINEL rename-command`, because it calls `CONFIG` and the replication commands on your instances. The ACL form is short: keep the application on `default` with `+@all -@dangerous` plus a password, and create an `admin` user holding everything. Be careful with that category, because it also contains commands applications and monitoring often use, such as `INFO` and `KEYS`. ## A hardening order for the VM 1. Bind a private address and leave `protected-mode yes` on as a backstop. 2. Firewall the port, as the security page advises for any directly exposed host. 3. Give `default` a password, or disable it in favour of named users. 4. Move administrative commands to an admin user with ACLs. 5. Add TLS if the traffic crosses a network you do not trust, because `AUTH` is otherwise sent unencrypted. 6. Keep the three `enable-*` settings at `no`, and run as an unprivileged user.
- The Redis security page warns that CONFIG can change the working directory. Is that still a live risk?On a stock config, no: `dir` and `dbfilename` are protected configs, and `CONFIG SET` replies `can't set protected config` while `enable-protected-configs` is `no`. The page's description is still right about why it matters, since writing RDB files to arbitrary paths can compromise the host. The risk returns wherever someone set that option to `yes`, or to `local` with a local attacker.
- What does Redis warn about when renaming a command, and where does that bite?`redis.conf` warns that changing the name of commands logged to the AOF or sent to replicas may cause problems. So `CONFIG`, which is not written there, is the milder case, and a data-changing command such as `FLUSHALL` is the riskier one. It also breaks any tool using the original name, which is why Sentinel has its own `SENTINEL rename-command` setting.
- Does an ACL on the default user help if the port is still public?It limits what an anonymous connection can do, which is a real improvement, but the port stays reachable and the password becomes the only barrier. The security page notes Redis answers quickly enough that many passwords per second can be tried, so it should be long, and `AUTH` is unencrypted without TLS. Close the network path as well.
- On stock Redis 8.10 any connected client can run MODULE LOAD
- rename-command can restrict a command for just one client
- A long renamed command name is as good as authentication
- CONFIG SET can flip enable-protected-configs from a client connection
- An exposed Redis only risks losing cached data, nothing else
Assumes the Redis 8.10 redis.conf defaults for enable-protected-configs, enable-module-command and enable-debug-command; a config that loosens them reopens those routes.