Redis answers -DENIED to a remote client holding a valid certificate, although bind lists the VM's private address and named ACL users have passwords: why, and what fixes it?
answer
- the reply text names the cause
- one user's flag, not the listener
- private is not the same as loopback
- disabling a user keeps its nopass flag
basics
~20 sProtected mode is still on and the default user still has the nopass flag, so non-loopback connections are refused whatever bind, certificates or other users say. Give default a password, or resetpass it, rather than turning the check off.
solid answer
~40 sThe refusal comes from one test made as the connection is accepted: `protected-mode` is on, the `default` user still has the `nopass` flag, and the peer is not a `127.*` address, `::1` or a Unix socket. `bind` is not part of it, and a private address is not loopback. Certificates do not count either: the TLS handshake has already succeeded by then, and `tls-auth-clients-user` mapping runs afterwards. Passwords on named users are irrelevant, and `ACL SETUSER default off` leaves `nopass` set. The fix is to give `default` a password, or `ACL SETUSER default off resetpass` if only named users should log in. `protected-mode no` also ends the refusal, but with `default` still enabled and `nopass`, every client that finishes the handshake is automatically an unrestricted user.
code
plaintext · 8 lines$ redis-cli -h 10.0.0.5 --tls --cert app.crt --key app.key --cacert ca.crt PING
(error) DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. ...
# on the Redis host, over loopback
127.0.0.1:6379> ACL LIST
1) "user default on nopass sanitize-payload ~* &* +@all"
127.0.0.1:6379> ACL SETUSER default off resetpass
OKgo deeper
Recall that -DENIED comes from protected mode, and that it is about the default user having no password, not about a firewall or a wrong certificate.
State the three-part condition and explain which common settings do not take part in it: bind, client certificates, passwords on other users, and the default user being off.
Use the event order: a -DENIED means network, listener and handshake all succeeded. Choose the fix by intent, persist the ACL change so a restart does not undo it, and flag same-host forwarders as a blind spot.
Make the default user's state part of your baseline, disabled with resetpass or passworded, so nobody reaches for protected-mode no under deadline. Disabling the backstop should need a recorded reason.
## The test Redis actually runs Protected mode is a short check in the code that finishes accepting a client. A connection is refused when all of these are true: 1. `protected-mode` is `yes`. 2. The `default` user has the `nopass` flag. 3. The peer is not local, meaning its address does not start `127.` and is not `::1`, and it did not arrive on a Unix socket. That is the whole condition in Redis 8.10. Older descriptions, including the security page's wording about the default configuration binding all interfaces, suggest `bind` plays a part. The code does not read `bind` here, so a server listening only on a private address still refuses remote clients. ## Why each expected fix does nothing | What the team did | Does the refusal stop? | Why | |---|---|---| | Named `bind 10.0.0.5` | No | `bind` is not in the condition | | Clients present valid certificates | No | The check reads no certificate | | Set `tls-auth-clients-user CN` | No | The mapping runs after the check | | Gave named ACL users passwords | No | Only `default` is consulted | | `ACL SETUSER default off` | No | `off` does not clear `nopass` | | `requirepass` or `ACL SETUSER default >secret` | Yes | Clears `nopass` | | `ACL SETUSER default off resetpass` | Yes | `resetpass` clears `nopass` | | `protected-mode no` | Yes | Removes the first condition | The fifth row is the most instructive. A disabled `default` looks secure, and the startup warning about missing authentication stays silent for it, but protected mode still sees the flag and keeps refusing. ## The order of events for a TLS client 1. TCP connection to the `tls-port` listener. 2. TLS handshake, enforcing `tls-auth-clients`. Under the default `yes`, a client with no valid certificate fails here and never sees `-DENIED`. 3. Protected-mode check. 4. `tls-auth-clients-user` mapping, if configured. 5. Commands, subject to `AUTH` and ACLs. So a `-DENIED` proves that the network path, the listener and the certificate were all fine. That narrows the search a long way. ## Diagnosing it - **Read the reply.** It says protected mode is enabled and no password is set for the default user, and it lists the ways out. - **Inspect from loopback.** `ACL LIST` on the server shows `nopass` on the `default` line, and `CONFIG GET protected-mode` shows the setting. - **Check the startup log.** With `default` enabled and `nopass`, Redis logs `WARNING: Redis does not require authentication` at startup. With `default` set to `off` that warning is absent, although the refusal continues. - **Watch the counter.** `rejected_connections` in `INFO stats` rises with each refusal, though it also counts clients turned away at `maxclients`. ## The right fix depends on the intent - **Clients should log in with a password:** set `requirepass` or `ACL SETUSER default >secret`. Clients then need `AUTH`. - **Only named users should exist:** create the admin user first so you are not locked out, then `ACL SETUSER default off resetpass`. New connections start unauthenticated and must log in, or arrive through `tls-auth-clients-user`. - **Certificates really are the only gate:** `protected-mode no` needs `tls-auth-clients yes` and `port 0` to be defensible at all, and then every holder of a certificate from that CA runs as a full-rights `default`. Trim that user with ACLs or accept this explicitly. A change made with `ACL SETUSER` lives in memory until it is saved. Use `CONFIG REWRITE` when users are defined in `redis.conf`, or `ACL SAVE` with an `aclfile`, otherwise a restart restores `nopass` and the refusals return. ## A trap beside the fix Protected mode judges the peer address it can see. A tunnel or proxy on the same host that dials `127.0.0.1` connects from loopback, so everything forwarded through it passes as local, whoever is at the far end. If a TLS terminator or port forwarder sits on the Redis host, the check protects nothing for that path. This also explains a common red herring during an incident: the operator tests on the box, the command works, and the team concludes the server is healthy. A test over loopback is exempt from the check, so reproduce the failure from the client's host, or read the `-DENIED` text the client has already logged.
- Why does a client on the same VM succeed while one in the same private subnet fails?A connection arriving from a `127.*` address, `::1` or a Unix socket counts as local, and everything else does not. The check has no notion of private ranges or subnets, so `10.0.0.0/8` is treated like any public address. A client on the VM's own loopback is exempt regardless of `nopass`, which is why the same command works when you test it on the box.
- Can you tell a certificate problem from a protected-mode refusal on the client?Yes. With `tls-auth-clients yes`, a missing or invalid certificate fails during the handshake, before Redis can send a RESP reply, so the client reports a TLS or connection error. `-DENIED` is written after the handshake has completed. Seeing that text therefore tells you the certificate was accepted, and you can stop looking at the CA and the client's key.
- Protected mode stops applying as soon as bind names a specific address
- A client presenting a valid certificate counts as authenticated for protected mode
- Giving named ACL users passwords satisfies protected mode
- ACL SETUSER default off removes the default user's nopass flag
- Private network addresses count as local for protected mode
Assumes Redis 8.10, whose protected-mode check reads the default user's nopass flag and the peer address but not bind; descriptions tying it to binding all interfaces do not match this code.