search
HomeDatabaseRedisWhat are the reinforcement measures for Redis cache database?

Sensitive data and encryption protection

1. Password saving (important)

Security issue: The native Redis server password requirepass and masterauth are saved in clear text to redis. conf.

Solution: The server password is encrypted with PBKDF2 and saved to redis.conf.

Considering the performance issues, it will be time-consuming to use PBKDF2 for each authentication. After review, after the first authentication is successful, the memory will be cached with SHA256, and subsequent requests will be verified using SHA256 first.

2. Support key replacement (important)

Security issues: The secret keys involved in encryption and decryption cannot be hard-coded into the code.

Solution: The secret key supports regular replacement.

➤redis server redis-server:

Add configuration item to configuration file: cipher-dir

Configure to the full directory of the folder where redis_shared.key and root.key are located Path, for example: cipher-dir /opt/redis/etc/cipher

➤redis client: redis-cli

Add parameter -cipherdir, pointing to where redis_shared.key and root.key are located Full path to the folder

For example: redis-cli -h 127.0.0.1 -cipherdir /opt/redis/etc/cipher -a sessionrdb@dbuser@Changeme_123 -p 32091

➤redis client End SDK: jedis*.jar

In the same process, the Jedis interface is string, dbname@user@pwd, because the third-party interface (similar to Jdbc) cannot be encrypted.

3. Password transmission (important)

Security issue: Native Redis may obtain sensitive information on the server through the config get command.

Solution: It is forbidden to transmit sensitive information such as passwords to the client, so functions such as config get requirepas/masterauth/requireuserpass need to be disabled.

4. Password modification (important)

Security issue: Change password plain text transmission: config set masterauth pwd

Solution: Redis memory saves plain text password problem: masterauth uses AES128 Encrypted, the password is saved in AES128

Password security

1. The product enables the database password complexity check function by default

Security issue: Redis password change There is no complexity check.

Solution: Provide a separate Redis modification tool to modify the password, pay special attention to the following points:

1. Perform a password complexity check.

2. When entering an incorrect username or password, no overly clear reason prompts such as "Password is wrong" or "Username does not exist" should appear to prevent attackers from guessing the system username/password.

3. To change the password, verify the old password.

4. The database password cannot be the same as the username.

5. Hide the password when changing the password interactively.

6. It is recommended in the documentation to change the password interactively.

2. To prevent brute force cracking, configure the number of failed account login attempts

Security issue: The native version of Redis has brute force cracking.

Solution: Maximum number of failures: maxauthfailtimes (unit times, valid range (0,100,000], default value 10,000)

This setting can only be passed through the redis.conf file at startup Configuration cannot be achieved through dynamic modification, and the corresponding config set operation is disabled.

does not support setting to 0: means not to lock any IP.

3. Configure the automatic unlocking time after the account is locked

Authentication failure lock time: authfaillocktime (unit minute, valid range [0~999], default value 10)

When set to 0, it means permanent locking.

Note: This configuration item only supports redis.conf configuration at startup, and does not support dynamic modification. The corresponding config set is blocked.

4. Check the locked IP

Problem: You need to check the IP after it is locked Locked IP.

Solution:

Only administrators can view the locked IP list, the separator is an English colon (:)
Example 1: config get lockedips
Return: 10.67.147.111;10.67.147.112;
Example 2: config get lockedips
Return: 10.67.147.111;
Note: config set lockedips is not supported. If forced, an error is returned: ERR Unsupported CONFIG parameter : lockedips

5. Unlocking manually locked IP

Only the administrator can execute the command to unlock the locked IP, and only supports unlocking a single IP or unlocking all IPs
Solution:

Example 1, unlock a single IP: config set unlockips 10.67.147.111
Example 2, unlock all IPs: config set unlockips “all”
Description: config get unlockips is not supported, if forced, return empty, redis-cli prompt: (empty list or set)
If there is no exception in the IP in the parameter, unlocking failure will be returned, for example:
(error) ERR Invalid argument '10.67.147.111' for CONFIG SET 'unlockips '

Perform manual unlocking and record trace, for example:
For example: 26 Dec 03:15:19.958 * 10.67.147.113 unlocked by 10.67.147.111:59417 Log audit

6. Security Audit

Redis itself supports logging to the system log, such as /var/log/localmessage. But it needs to be configured as follows in redis.conf:

syslog-enabled yes

syslog-ident redis

syslog-facility local0

2. Customer Log in to the client and record client IP, account and other information.

3. Relevant maintenance operations must have detailed log records.

Example: 29118:S 26 Nov 11:19:29.100 * The readdbuser logged in successfully;10.145.93.119:52817;

7. Operation log dump

Security Problem: The official version of Redis logs will not be dumped, and the disk may be full when running for a long time.

Solution: Run the tracemonitor process (python version) separately, and regularly manage the Redis log file size, mainly log compression and regular deletion, to avoid taking up too much disk.

Note: The current platform defaults to a detection every 60 seconds, the logs can be compressed to 20M, and the maximum number of logs is 50.

The above is the detailed content of What are the reinforcement measures for Redis cache database?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
Redis: Exploring Its Core Functionality and BenefitsRedis: Exploring Its Core Functionality and BenefitsApr 30, 2025 am 12:22 AM

Redis's core functions include memory storage and persistence mechanisms. 1) Memory storage provides extremely fast read and write speeds, suitable for high-performance applications. 2) Persistence ensures that data is not lost through RDB and AOF, and the choice is based on application needs.

Redis's Server-Side Operations: What It OffersRedis's Server-Side Operations: What It OffersApr 29, 2025 am 12:21 AM

Redis'sServer-SideOperationsofferFunctionsandTriggersforexecutingcomplexoperationsontheserver.1)FunctionsallowcustomoperationsinLua,JavaScript,orRedis'sscriptinglanguage,enhancingscalabilityandmaintenance.2)Triggersenableautomaticfunctionexecutionone

Redis: Database or Server? Demystifying the RoleRedis: Database or Server? Demystifying the RoleApr 28, 2025 am 12:06 AM

Redisisbothadatabaseandaserver.1)Asadatabase,itusesin-memorystorageforfastaccess,idealforreal-timeapplicationsandcaching.2)Asaserver,itsupportspub/submessagingandLuascriptingforreal-timecommunicationandserver-sideoperations.

Redis: The Advantages of a NoSQL ApproachRedis: The Advantages of a NoSQL ApproachApr 27, 2025 am 12:09 AM

Redis is a NoSQL database that provides high performance and flexibility. 1) Store data through key-value pairs, suitable for processing large-scale data and high concurrency. 2) Memory storage and single-threaded models ensure fast read and write and atomicity. 3) Use RDB and AOF mechanisms to persist data, supporting high availability and scale-out.

Redis: Understanding Its Architecture and PurposeRedis: Understanding Its Architecture and PurposeApr 26, 2025 am 12:11 AM

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

Redis vs. SQL Databases: Key DifferencesRedis vs. SQL Databases: Key DifferencesApr 25, 2025 am 12:02 AM

The main difference between Redis and SQL databases is that Redis is an in-memory database, suitable for high performance and flexibility requirements; SQL database is a relational database, suitable for complex queries and data consistency requirements. Specifically, 1) Redis provides high-speed data access and caching services, supports multiple data types, suitable for caching and real-time data processing; 2) SQL database manages data through a table structure, supports complex queries and transaction processing, and is suitable for scenarios such as e-commerce and financial systems that require data consistency.

Redis: How It Acts as a Data Store and ServiceRedis: How It Acts as a Data Store and ServiceApr 24, 2025 am 12:08 AM

Redisactsasbothadatastoreandaservice.1)Asadatastore,itusesin-memorystorageforfastoperations,supportingvariousdatastructureslikekey-valuepairsandsortedsets.2)Asaservice,itprovidesfunctionalitieslikepub/submessagingandLuascriptingforcomplexoperationsan

Redis vs. Other Databases: A Comparative AnalysisRedis vs. Other Databases: A Comparative AnalysisApr 23, 2025 am 12:16 AM

Compared with other databases, Redis has the following unique advantages: 1) extremely fast speed, and read and write operations are usually at the microsecond level; 2) supports rich data structures and operations; 3) flexible usage scenarios such as caches, counters and publish subscriptions. When choosing Redis or other databases, it depends on the specific needs and scenarios. Redis performs well in high-performance and low-latency applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment