redis.conf Check · GUIDE

redis.conf mistakes explained

Each thing redis.conf Check reports, and the Redis 7.0 behaviour behind it. The behaviour follows Redis 7.0.15's config.c, sds.c and acl.c and the redis.conf documentation, and was compared with a real redis-server 7.0.15 on 800 generated files (the parity run). Not affiliated with Redis Ltd.

A worked example

A server opened up for app servers on another subnet, with a password added later and a user line copied from a tutorial:

bind 0.0.0.0
protected-mode no
requirepass hunter2
user default on nopass ~* &* +@all
enable-protected-configs yes
maxmemory 512m

What the CLI says about it (node check.mjs redis.conf):

redis.conf Check (Redis 7.0.15): 4 high, 1 medium, 2 low
Read, in order: redis.conf
Starts: yes
Listens: port 6379 on 0.0.0.0
  From another machine: connects and runs commands with no password
  From this machine (127.0.0.1): connects and runs commands with no password

[high] open-without-password  redis.conf:2
  protected-mode no
  Redis listens on 0.0.0.0 (port 6379), protected mode is off and the default user needs no password: anyone who can reach the port can read and change every key, and CONFIG SET dir/dbfilename lets them write files on the server.
  fix: Set requirepass (or a user default line with a long password), bind to 127.0.0.1 -::1 or a private address only, and keep protected-mode yes.

[high] default-user-nopass  redis.conf:4
  user default on nopass ~* &* +@all
  This user line gives the default user nopass with admin commands, so every connection is logged in as an administrator without a password.
  fix: Give the default user a password (>long-secret or #sha256) or turn it off and create named users.

[high] requirepass-replaced  redis.conf:3
  requirepass ****
  requirepass is set, but the user default line at redis.conf:4 resets the default user after it, so the requirepass password is not accepted and no password is needed at all.
  fix: Use one of them: delete requirepass, or delete the user default line.

[high] protected-configs-enabled  redis.conf:5
  enable-protected-configs yes
  enable-protected-configs yes: clients can CONFIG SET dir and dbfilename, which is how Redis worms write SSH keys and cron files to disk.
  fix: Leave enable-protected-configs at its default, no, and change it only for the time you need it.

[medium] weak-password  redis.conf:3
  requirepass ****
  The requirepass password is 7 characters. Redis checks passwords fast and has no lockout, so short ones fall to guessing.
  fix: Use a long random password (openssl rand -base64 32), and rotate it.

[low] password-in-file  redis.conf:3
  requirepass ****
  Cleartext passwords are stored in this file, so anyone who can read it (backups, config repositories, other users on the box) can log in.
  fix: Keep the file mode 640 or tighter and out of version control; for user lines, store #<sha256 hex> instead of >password.

[low] decimal-memory-unit  redis.conf:6
  maxmemory 512m
  maxmemory 512m is 512000000 bytes: Redis reads k, m and g as powers of 1000 and kb, mb and gb as powers of 1024.
  fix: Write 512mb if you meant 512 MiB.

The requirepass line looks like protection, but the user default line after it resets the default user to nopass, so the password does nothing. Deleting the user line, choosing a long password and binding only the private address fixes all four high findings.

Will it start?

refuses-to-start

Redis stops at the first line it cannot use and prints *** FATAL CONFIG FILE ERROR ***, the line number, the line, and a reason such as Bad directive or wrong number of arguments, argument must be between 1 and 2147483647 inclusive or argument(s) must be one of the following: .... It reads nothing after that line. The number counts lines of the file being read when the error happened, which may be an included file the message does not name; for a wildcard include, the matching files are joined first and the count runs across them. The tool reports the real file and line. Some errors come only after the file has loaded, with no line number at all: an unknown command in a user rule (Critical error while loading ACLs) or a unix socket path of 108 bytes or more.

inline-comment

# starts a comment only when it is the first thing on a line. requirepass s3cret # change me has four words, so Redis stops with wrong number of arguments; bind 127.0.0.1 # local only asks Redis to listen on addresses called #, local and only, and it exits with Failed listening on port 6379 (TCP).

include-not-found

An include without wildcards that names a file Redis cannot open stops Redis with Fatal error, can't open config file. With a wildcard (include /etc/redis/conf.d/*.conf) a missing file is not an error.

include-glob-no-match

A wildcard include that matches nothing is skipped without a word, so a typo in the directory name quietly drops every setting you meant to load. Files whose names start with a dot are matched only by a pattern that starts with a dot, as glob(3) does.

include-joined-lines

For a wildcard include, Redis reads the matching files (in name order) into one text and then splits it into lines. If a file does not end with a newline, its last line and the next file's first line become one line: maxmemory 100mb followed by port 6380 becomes maxmemory 100mbport 6380, which stops Redis, or worse, a line that still parses.

include-relative-path

Redis opens a relative include path from its working directory, not from the directory of the file that includes it. The working directory is wherever redis-server was started (systemd units often set it), and every dir line moves it, so include extra.conf after dir /var/lib/redis reads /var/lib/redis/extra.conf.

no-listener

With port 0, no tls-port and no unixsocket, or with bind "", Redis has nowhere to listen and exits with Configured to not listen anywhere, exiting.

bind-address-unavailable

Redis binds each bind address in turn; one the machine does not have stops Redis with Failed listening on port ... (TCP), aborting., unless the address is prefixed with - (optional). An IPv6 address on a machine with no IPv6 at all is skipped. The CLI's --host-addrs checks against the machine's own addresses.

tls-port-without-cert

A tls-port (or tls-replication yes or tls-cluster yes) needs tls-cert-file, tls-key-file and, while tls-auth-clients is on (the default), tls-ca-cert-file or tls-ca-cert-dir; without them Redis exits with Failed to configure TLS.

acl-file-and-users

Redis refuses to start when users are defined both in redis.conf (user lines) and in an aclfile.

module-config-without-module

A setting with a dot in its name (mymodule.option 1) belongs to a module. Without a loadmodule line for that module, Redis exits after loading the file.

Who gets in

open-without-password

The server listens on an address other machines can reach, protected mode is off, and the default user has nopass (no requirepass, or a user default ... nopass line): every client is logged in as the default user. With the default +@all that is every key, FLUSHALL, and, if enable-protected-configs allows it, CONFIG SET dir plus dbfilename plus SAVE, the file write Redis worms use to drop SSH keys and cron jobs.

local-without-password

Only 127.0.0.1 is bound and protected mode is off, with no password: any process on the machine, any container sharing its network, and any server-side request forgery that reaches localhost can run every command.

protected-mode-only

With protected mode on and no password on the default user, Redis answers clients that are not on 127.0.0.1 or ::1 with -DENIED and closes the connection. That keeps strangers out but is not authentication: remote clients cannot use the server at all, and one protected-mode no (in a later file, or by CONFIG SET from localhost) opens it.

default-user-nopass

A user default on nopass ... line with admin commands logs every new connection in as an administrator without a password, whatever requirepass says.

requirepass-replaced

Redis applies requirepass to the default user first and the user lines after it. A user default line resets the default user, so the requirepass password stops working; if that line says nopass, no password is needed at all.

weak-password

Redis answers password attempts as fast as any other command and has no lockout; its own example redis.conf warns that an outside user can try very many passwords a second. The tool flags passwords under 16 characters or starting with a common word; it never prints them.

password-in-file

requirepass, masterauth and >password rules are stored in cleartext. Anyone who can read the file (a backup, a config repository, another account on the machine) can log in. For user lines, # followed by the SHA-256 hex of the password works instead.

protected-configs-enabled

Since Redis 7.0, CONFIG SET dir and dbfilename are refused unless enable-protected-configs is yes, or local for connections from this machine. Turning it on brings back the classic file-write attack.

debug-command-enabled

enable-debug-command yes lets clients run DEBUG, which can crash or stall the server (DEBUG SEGFAULT, DEBUG SLEEP) and read internals. Redis checks this before ACL permissions.

module-command-enabled

enable-module-command yes lets clients run MODULE LOAD, which loads a shared library from any path the Redis user can read: code execution as that user.

plaintext-port-beside-tls

A TLS port does not close the plaintext port. Until port 0, passwords and data still cross the network unencrypted for any client that uses the old port.

unixsocket-world-writable

With unixsocketperm giving others write permission (777, 776 ...) every local account can connect to the socket.

listens-on-all-interfaces

No bind line means bind * -::*: every interface, public ones included. With a password set, the password is then the only thing between the internet and the data.

aclfile-not-read

With an aclfile, users (the default user included) come from that file, which this tool does not read, so who can log in is decided there.

Which line wins

overridden-directive

For an ordinary setting, the last line Redis reads wins, and an include counts where its line stands. A setting in a file included at the top of redis.conf is overridden by the same setting lower down; a file included at the end overrides everything above it. Redis's own example file says to put includes first if redis.conf should win, last if the included file should. save lines add to each other (the first one in the file replaces the defaults, and save "" clears them), and client-output-buffer-limit sets one client class at a time.

rename-command-used

rename-command CONFIG "" removes a command for everyone; renaming it to a secret name makes that name a password stored in the file. It does not change ACL permissions, and Redis's documentation recommends ACL rules (-@dangerous, -config) instead.

decimal-memory-unit

Redis reads k, m and g as powers of 1000 and kb, mb and gb as powers of 1024: maxmemory 2g is 2,000,000,000 bytes, about 7% less than 2 GiB.