ACLs (Access Control Lists)

Difficulty: Intermediate

Question

What security feature did Redis 6 introduce with ACLs, and how would you set up users with least-privilege access for different services?

Answer

Redis 6 introduced Access Control Lists (ACLs): named users, each with its own password and a precise set of allowed commands, key patterns and Pub/Sub channels. Before ACLs there was a single shared password (requirepass) that gave every client full power, including FLUSHALL and CONFIG. With ACLs, a reporting service can be limited to reading report:* keys while only an admin user can run dangerous commands.

Building blocks of an ACL rule

RuleMeaning
on / offEnable or disable the user
>passwordAdd a password (stored as SHA-256)
~patternAllow keys matching the glob, e.g. ~cache:*
%R~pattern / %W~patternRead-only or write-only key access (7.0+)
&patternAllow Pub/Sub channels (6.2+)
+command / -commandAllow or deny one command
+@category / -@categoryAllow or deny a category like @read, @write, @dangerous, @admin
nopass, resetkeys, resetSpecial helpers

Rules are applied left to right, so +@all -@dangerous means everything except dangerous commands. ACL CAT lists categories and ACL CAT dangerous shows the commands in one.

The default user and backward compatibility

Every server has a user called default. On a fresh install it has nopass and full permissions, which is why older clients that never authenticate still work. requirepass simply sets the default user's password. In production you should either give default a strong password and restricted rights or disable it with ACL SETUSER default off, and have every service authenticate as its own user with AUTH <username> <password>.

A least-privilege setup

  • checkout-service: read and write cart: and session:, no admin commands.
  • analytics-reader: +@read on report:* only.
  • queue-worker: list commands on queue:, publish to events:.
  • admin: full access, used only by people and ops tooling.

Operating ACLs

  • Persist users in an ACL file (aclfile /etc/redis/users.acl) and use ACL SAVE / ACL LOAD, or define them with user lines in redis.conf. You cannot mix both methods.
  • ACL LOG shows recent denied commands and failed logins; it is the first place to look when a deploy suddenly gets NOPERM.
  • ACL WHOAMI, ACL LIST and ACL GETUSER name help debug.
  • Since Redis 7.0 the default for new users is no Pub/Sub channel access (acl-pubsub-default resetchannels), so grant &channel explicitly.
  • Redis 7.0 also added selectors, extra permission sets in parentheses, for users who need different command sets on different key patterns.

Limits to keep in mind

Key patterns are checked against the keys a command declares. ACLs cannot restrict a user to a logical database index. Also, ACLs do not encrypt anything; use TLS (also added in Redis 6) when traffic crosses untrusted networks.

How Redis checks a command against ACLs. Every command is checked for user, command permission and key access before it runs.
  1. Client sends AUTH user pass: Connection is bound to that user.
  2. Client sends a command: For example SET cart:42 ...
  3. Is the command allowed?: Checked against +/- commands and categories.
  4. Are the keys allowed?: Matched against ~ and %R~/%W~ patterns.
  5. Execute or reply NOPERM: Denials are recorded in ACL LOG.

Code examples

Creating least-privilege users

# Application user: cart and session keys, no dangerous commands
ACL SETUSER checkout on >Ch3ckout!Pass ~cart:* ~session:* +@all -@dangerous

# Read-only reporting user
ACL SETUSER analytics on >An4lytics!Pass %R~report:* +@read +@connection

# Worker: list ops on queue keys and publish to events channels
ACL SETUSER worker on >W0rker!Pass ~queue:* &events:* +@list +publish +@connection

# Lock down the default user
ACL SETUSER default off
ACL SAVE

# Test as the analytics user
AUTH analytics An4lytics!Pass
GET report:daily
SET report:daily x
ACL LOG 1

Each service gets only what it needs. The denied SET is recorded in ACL LOG with the user, command and reason. ACL SAVE requires an aclfile to be configured.

Key points

  • ACLs (Redis 6+) add named users with per-user passwords, command, key and channel permissions
  • Rules apply left to right; +@all -@dangerous is a common baseline for apps
  • The default user is nopass with full access unless you change it
  • %R~ and %W~ key permissions and selectors arrived in Redis 7.0
  • Use ACL LOG to debug NOPERM errors and pair ACLs with TLS

Common follow-up questions

  • What is in the @dangerous category and why?
  • How do you rotate a service's Redis password without downtime?
  • How do ACLs interact with replication and Sentinel authentication?
  • Why can't ACLs restrict access by logical database?

Interview tips

  • Contrast with the old single requirepass model to explain why ACLs matter
  • Write at least one real ACL SETUSER command; specifics stand out
  • Mention disabling or restricting the default user, a common production gap

Concepts covered

ACL, ACL SETUSER, Command categories, Key patterns, Default user

More Redis & Caching questions