skip to content

ACL Users & Rules

ACL SETUSER grants each user commands, key patterns and channels, and requirepass is only the default user's password. Interviewers ask how to run a service with least privilege on one instance.

part ofRedisread it →
on this pageshow

explore

questions

6

In Redis, what does `requirepass` actually set, and why is it not a per-service credential?

level: juniorimportance: must knowfreq 48%

answer

  1. one built-in user on a fresh server
  2. compatibility layer over ACLs
  3. password of the default user only
  4. AUTH with one argument names that user

basics

~20 s

requirepass sets the password of Redis's built-in default user and nothing else. Anyone who authenticates with it gets that user's permissions, normally every command and key, so it is one shared credential, not per-service access.

solid answer

~40 s

Redis connections act as ACL users, and a fresh server has one: `default`, defined by `on nopass ~* &* +@all`. Because it has `nopass`, a new connection is authenticated as `default` without calling `AUTH`. Setting `requirepass` replaces that user's passwords with the one you give, so new connections start unauthenticated and get `NOAUTH` until they send `AUTH <password>`, which is shorthand for `AUTH default <password>`. That changes who must prove themselves, not what they may do afterwards: the user still holds `~*` and `+@all`, including `FLUSHALL` and `CONFIG`. To give a service less, create a separate user with `ACL SETUSER`, then restrict or disable `default`.

code

plaintext · 10 lines
plaintext
> CONFIG SET requirepass s3cret
OK

# a new connection
> GET greeting
(error) NOAUTH Authentication required.
> AUTH s3cret
OK
> ACL WHOAMI
"default"

go deeper

for a junior

Recall that a fresh server has one user called default, and that requirepass only sets that user's password. Say plainly that the permissions behind the password do not shrink.

for a middle

Explain the mechanics: nopass makes new connections log in automatically, requirepass removes that, and AUTH with one argument targets default. Show you know where the NOAUTH reply comes from.

for a senior

Show the migration order: an admin user first, per-service users, a check of the user field in CLIENT LIST, replication and Sentinel credentials, and only then disabling default.

for a principal

Treat default as a standing policy. Decide whether any shared login may remain, what it may do if it does, and how a new deployment is stopped from returning to one password.

## The user model behind a Redis connection Since Redis 6, a client connection acts as an **ACL user**: a named record holding passwords, allowed commands, allowed key patterns and allowed Pub/Sub channels. A freshly started server with stock settings has exactly one user, called `default`, defined by these rules: - `on`: the user is enabled, so it is possible to authenticate as it. - `nopass`: the user needs no password, and any password is accepted. - `~*`: every key may be named in a command. - `&*`: every Pub/Sub channel may be used. - `+@all`: every command may be called, including ones modules load later. The `default` user also gets one special case. Because it carries `nopass`, a new connection is authenticated as `default` straight away, with no `AUTH` call. That is why a stock server answers the first command it receives. ## What `requirepass` changes `requirepass` is older than ACLs, and `redis.conf` now calls it a **compatibility layer**: its effect is only to set the `default` user's password. Inside the server, it resets that user's passwords and adds the new one, which also removes `nopass`. Two things follow: 1. New connections start unauthenticated. Ordinary commands are refused with `NOAUTH Authentication required.` until the client authenticates. `AUTH` and `HELLO` stay callable, since a client needs them to log in. 2. The one-argument form `AUTH <password>` means `AUTH default <password>`. Both forms log in as the same user. | Setup of `default` | A new connection starts | After logging in as `default` | |---|---|---| | Stock (`nopass`) | Authenticated as `default` | `~* &* +@all` | | `requirepass` set | Not authenticated | `~* &* +@all`, unchanged | | `ACL SETUSER default off` | Not authenticated | Not possible: the user is disabled | ## What it leaves alone The password is a gate in front of the same permissions, which is why it cannot express least privilege: - **Permissions stay whole.** A client that logs in can still run `FLUSHALL`, `CONFIG` or `KEYS`, because `requirepass` touches no command or key rule. - **There is one value per server.** Three services on one instance all share it, and there is no way to give each its own `requirepass`. - **Identity is lost.** Each `ACL LOG` entry records a `username`, and with one shared login the entries from all three services say `default`. - **Other users are untouched.** A user made with `ACL SETUSER` has its own passwords and never uses this one. Two edge cases are worth knowing. `redis.conf` says `requirepass` is not compatible with `aclfile` or `ACL LOAD`, which cause it to be ignored, because the `default` user then comes from the file. And clearing it with `CONFIG SET requirepass ""` puts `nopass` back, so new connections are authenticated automatically again. ## Checking what a server is really doing A few commands settle the question quickly: - `ACL WHOAMI` names the user the current connection is acting as. - `ACL LIST` prints every user's rules in the format `redis.conf` uses. With `requirepass` set, the `default` line shows a `#` hash in place of `nopass`, because Redis stores passwords hashed with SHA-256. - `ACL GETUSER default` shows the same facts as named fields, which is easier to read when checking one user. ## Moving a shared instance off one password Take one instance used by a checkout service, a read-only reporting job and a cache warmer, all sharing a `requirepass`. A safe order is: 1. Create an administrative user first, so turning `default` off cannot lock you out of the `ACL` commands. 2. Create one user per service with its own password and rules, using `ACL SETUSER`. 3. Deploy each service with `AUTH <username> <password>` and watch `ACL LOG` for commands its new rules refuse. 4. Confirm nothing still uses the old login: `CLIENT LIST` prints a `user=` field for every connection. 5. Give replicas and Sentinel their own users. A replica with only `masterauth`, or a Sentinel with only `sentinel auth-pass`, logs in as `default`. 6. Run `ACL SETUSER default off` and persist the change. Step 6 stops new logins only. `off` leaves connections that have already authenticated working, so reconnect any that remain, for example with `CLIENT KILL USER default`.

  • What happens if you clear the password with `CONFIG SET requirepass ""`?
    The `default` user's passwords are reset and `nopass` is applied. New connections are then authenticated as `default` automatically again, with whatever command and key rules that user holds. With stock rules that reopens the server to any client that can reach it, so treat it as a security change rather than a tidy-up.
  • A replica authenticates with `masterauth` alone. What breaks if you run `ACL SETUSER default off` on its primary?
    Without `masteruser`, the replica sends the one-argument `AUTH`, which targets `default`. That user is now disabled, so the replica cannot authenticate when it next connects. Create a replication user holding `+psync +replconf +ping`, then set `masteruser` and `masterauth` on the replica before disabling `default`.
  • Why does a stock Redis server accept commands with no `AUTH` at all?
    The stock `default` user has the `nopass` rule, and for that one user `nopass` means new connections are authenticated automatically. Nothing about the connection is anonymous: `ACL WHOAMI` answers `default`, and the session holds that user's `~* &* +@all` permissions.

  • requirepass is a password every ACL user on the server must also supply
  • Setting requirepass limits which commands a client can run after logging in
  • One-argument AUTH logs in anonymously rather than as a named user
  • Each service on one instance can be given its own requirepass value
  • Once requirepass is set, the default user no longer exists
open as a page

How would you write Redis `ACL SETUSER` rules so a checkout service, a read-only reporting job and a cache warmer each get least privilege?

level: middleimportance: must knowfreq 55%

basics

~10 s

Give each service its own user: commands through +@read, +@write and -@dangerous, keys through ~ and %R~ or %W~ patterns, channels through &. Rules apply left to right, and anything not granted returns NOPERM.

open as a page

A Redis service starts failing with `NOPERM` after moving to its own ACL user; how do you use `ACL LOG` to find what was denied?

level: middleimportance: should knowfreq 36%

basics

~20 s

Run ACL LOG on the server that refused the call. Each entry gives a reason (command, key, channel or auth), the object denied, the username and client info. Then widen the rule and confirm it with ACL DRYRUN.

open as a page

A Redis cache warmer whose ACL user holds `+@write ~cache:*` runs `FLUSHALL` and wipes every key; why did the ACL allow it, and how do you close it?

level: seniorimportance: should knowfreq 44%

basics

~20 s

Key patterns limit only commands that name keys, and FLUSHALL names none, so only command rules can stop it. It sits in @write, so +@write granted it. Fix it with +@write -@dangerous, in that order, or a named command list.

open as a page

After a Redis failover, clients get `WRONGPASS` although `ACL SETUSER` succeeded on the old primary; why, and how should users reach every node?

level: seniorimportance: should knowfreq 40%

basics

~20 s

ACL SETUSER changes only the server that received it: users are not replicated, so the promoted replica never had them. Define users in an aclfile or redis.conf deployed to every node, and include the replication and Sentinel users.

open as a page

How should a team model Redis ACL users across many services sharing instances, and who should own the rule set?

level: principalimportance: should knowfreq 30%

basics

~20 s

Default to one user per service plus a few named human roles, built from allowlists, with default disabled. A platform team owns the reviewed rule file and its delivery to every node; service teams propose changes to their own users.

open as a page