Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Description of Redis service security hardening

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Redis (full name: Remote Dictionary Server remote Dictionary Service) is an open source API that is written in ANSI C language, supports the network, can be memory-based and persistent, and provides multi-language API.

Vulnerability description

Redis has an unauthorized access vulnerability due to improper configuration, which can be maliciously exploited by * users.

Under certain conditions, if Redis runs as root, * you can write a SSH public key file to the root account and log in to the victim server directly through SSH to obtain server permissions and data. Once * * is successful, * * users can directly add accounts to the SSH remote login control server, bringing security risks to the user's Redis operating environment and Linux hosts, such as deleting, leaking or encrypting important data, causing blackmail events, and so on.

Affected area

On the Redis client, test whether Redis sets the password:

Root@kali:~# redis-cli-h 10.16.10.2redis 10.16.10.2 keys 6379 > keys * 1) "1" `

As can be seen from the login results, the Redis service is open to the public network, and authentication is not enabled.

Repair scheme

No eavesdropping on the public network

Specify the network card used by the Redis service

By default, Redis listens on 127.0.0.1. If it is only local communication, make sure that the monitoring is local.

This approach can alleviate the risk of unauthorized access to Redis to a certain extent (exceptionally, if Redis is run as root users, * * users can use the existing webshell to bounce back shell to increase rights).

Find # bind 127.0.0.1 in the redis.conf file, remove the previous #, and save it.

This operation requires a restart of Redis to take effect.

After modification, only the native Redis can be accessed, or you can specify the access source IP to access the Redis.

Bind 192.168.1.100 10.0.0.1

Modify the default port 6379

Port 6377

Edit the configuration file redis.conf of the file redis, find the line containing port, change the default 6379 to the custom port number, and restart `redis to take effect `

Set firewall policy

If the Redis service needs to be accessed by other servers in normal business, you can use the iptables policy to allow only the specified IP to access the Redis service.

Iptables-An INPUT-s x.x.x.x-p tcp-- dport 6379-j ACCEPT

Account number and authentication

Set the access password: find the requirepass field in redis.conf, uncomment it, and fill in the required password later. The Redis client also needs this password to access the Redis service.

Open the / etc/redis/redis.conf configuration file:

Requirepass www.dgstack.cn12332 percent percent

Ensure the complexity of the password. Restart the service after configuration.

Minimization of service operation permissions

Use root to switch to redis user to start the service:

Useradd-s / sbin/nolog-M redis sudo-u redis / / redis-server / / redis.conf

Note: this operation requires a restart of Redis to take effect.

Disable or rename dangerous commands

Hide important commands: Redis has no right to separate, and there is no obvious difference between its administrator account and ordinary account. * * users can perform any operation after logging in, so the following important commands need to be hidden: FLUSHDB, FLUSHALL, KEYS,PEXPIRE, DEL, CONFIG, SHUTDOWN, BGREWRITEAOF, BGSAVE, SAVE, SPOP, SREM, RENAME,DEBUG.

In addition, there is a sandbox escape vulnerability in Redis 2.8.1 and Redis 3.x (less than 3.0.2), through which * * users can execute arbitrary Lua code.

The following configuration sets config/flushdb/flushall to empty, which disables the command; it can also be set to some complex, hard-to-guess name.

Rename-command FLUSHALL "" rename-command FLUSHDB "" rename-command CONFIG "" rename-command KEYS "" rename-command SHUTDOWN "" rename-command DEL "" rename-command ""

Then restart redis.

Renaming to "" means to disable the command. If you want to keep the command, you can rename it to a string that cannot be guessed, such as:

Rename-command FLUSHALL joYAPNXRPmcarcR4ZDgC

Turn on protected mode

Redis enables protected mode by default. If bind and password are not specified in the configuration, when this parameter is enabled, redis can only be accessed locally and external access is denied.

Redis.conf security settings: # turn on protected mode protected-mode yes

Security patch

Pay regular attention to the latest software version and upgrade Redis to the latest version in time to prevent new vulnerabilities from being maliciously exploited.

The idea of troubleshooting virus (mining virus)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report