>_ IzzyLab

Hands-on task

This task is step 8 of the course “Redis in production”

Close anonymous access to Redis

medium~10 min

Right now anyone who can reach port 6379 works in Redis with no password and full privileges — as the default user. Close this hole:

  • create an administrator ops with password ops-secret and full access (all commands, all keys, all channels);
  • make a client without authentication get refused (NOAUTH): disable default or give it a password;
  • the settings must survive a restart (service redis-server restart);
  • the data in the database must not be harmed.
What you'll practise:
  • redis
  • ACL
  • default user
  • NOAUTH
  • CONFIG REWRITE
  • security

Topic breakdown

By default Redis has a single user default with no password and all privileges: whoever connects is the administrator. Such instances exposed to the network are found en masse by scanners and turned into miners via CONFIG SET dir + SAVE. The right setup is named users with passwords (ACL SETUSER) and a disabled default (or default with a password — that is how the old requirepass works). An unauthenticated client then gets NOAUTH for any command except AUTH and HELLO. ACL changes live in memory, so they are saved to redis.conf (CONFIG REWRITE) or to a separate aclfile (ACL SAVE).

What's checked

  1. an anonymous client is refused
  2. ops logs in with a password and has full access
  3. data is intact
  4. settings survive a restart (the check restarts Redis)

What it looks like