Video in progress
What do you configure to secure a production Redis? Is setting a password enough?
No. Redis should never be exposed to the internet, each service should have its own ACL user with access only to its own keys and the commands it needs, dangerous commands should be disabled, the network should use TLS, and the version should be kept up to date.
📖 Answer
The classic attack: a Redis with no password, open on a public IP. The attacker runs CONFIG SET dir /root/.ssh and CONFIG SET dbfilename authorized_keys, then writes their own SSH key with SAVE. Or installs a crypto miner through cron. You can still find thousands of such servers on the internet.
My checklist:
-
Network:
bindonly on the internal interface,protected-mode yes, and a security group or KubernetesNetworkPolicythat allows only the services that need it. A password is no substitute for this layer. -
ACL (Redis 6+): instead of one shared
requirepass, a separate user per service:
ACL SETUSER orders on >s3cret ~orders:* &orders:* +@read +@write -@dangerous
ACL SETUSER default off
-@dangerous covers FLUSHALL, CONFIG, KEYS, DEBUG and the like. Commands called from Lua are also checked against the ACL. You can give one user two passwords, which is handy for rotating a password without downtime.
- TLS: available since Redis 6 (
tls-port). In Spring Boot 3.1+:
spring:
data:
redis:
ssl:
enabled: true
username: orders
password: ${REDIS_PASSWORD}
-
The data itself: RDB/AOF files and backups are not encrypted, and they may hold tokens, sessions and personal data. If backups are in S3, check access to them as seriously as you check access to Redis. If you can, don't put sensitive fields into Redis at all, or encrypt them.
-
Updates: several serious vulnerabilities have been found in Redis's embedded Lua interpreter, including ones that lead to remote code execution. An authenticated user is a source of risk too, so update the version regularly and don't give
+@scriptingto users who don't need it.
On a managed service, part of points 1-3 comes ready-made, but the ACL and network rules are still your job.
Sign up to mark studied questions and save your progress.