Redis
database.redis
Protects against destructive Redis operations like FLUSHALL, FLUSHDB, and mass key deletion
- 14blocking rules
- 6safe patterns
- 5Critical
- 8High
- 1Medium
[packs]
enabled = ["database.redis"]Evaluated when a command contains redis, valkey, keydb, FLUSHALL, FLUSHDB, DEBUG.
Recorded verdicts
redis-cli FLUSHALLBlockeddatabase.redis:flushall
Blocking rules
Each rule ID is database.redis:<name>. Use it in allowlists and [policy.rules].
Criticalconfig-dangerousCONFIG SET for dir/dbfilename/slaveof can be used for security attacks.
Explanation
These CONFIG SET options are commonly exploited in Redis attacks: - dir + dbfilename: Can write arbitrary files (RCE vector) - slaveof/replicaof: Can exfiltrate data to attacker's server Attack example: 1. CONFIG SET dir /var/spool/cron 2. CONFIG SET dbfilename root 3. SET payload '* * * * * malicious-command' 4. BGSAVE Disable in production: rename-command CONFIG "" # In redis.conf Use ACLs to restrict these commands.
Criticalconfig-set-maxmemoryCONFIG SET maxmemory can trigger immediate mass key eviction if new limit is below current usage.
Explanation
Lowering maxmemory below current usage causes Redis to evict keys immediately according to the active eviction policy: - volatile-lru/allkeys-lru: Silently deletes keys to fit budget - noeviction: Returns OOM errors on writes Check current usage first: INFO memory # Look at used_memory vs maxmemory Prefer gradual reduction or off-peak changes.
Criticalconfig-set-maxmemory-policyCONFIG SET maxmemory-policy changes how Redis evicts keys, risking silent data loss.
Explanation
Switching eviction policy can silently delete keys: - noeviction -> allkeys-lru: Enables silent key deletion - volatile-* -> allkeys-*: Extends eviction to non-expiring keys Check current policy: CONFIG GET maxmemory-policy Ensure application logic handles the new eviction behavior.
Criticaldebug-crashDEBUG SEGFAULT/CRASH will crash the Redis server.
Explanation
DEBUG SEGFAULT/CRASH intentionally crashes the Redis server: - Server process terminates immediately - All connections are dropped - Unsaved data may be lost - Services depending on Redis fail This is meant for testing crash recovery, not production use. These commands should be disabled in production: CONFIG SET debug-command no rename-command DEBUG "" # In redis.conf
CriticalflushallFLUSHALL permanently deletes ALL keys in ALL databases.
Explanation
FLUSHALL removes every key from every database (0-15 by default): - All cached data is lost - All session data is gone - All queues are emptied - Affects ALL databases, not just current This is instant and cannot be undone. RDB/AOF backups are not affected until the next save. Check database sizes first: INFO keyspace DBSIZE Consider: FLUSHDB # Only current database DEL key1 key2 # Specific keys
Highconfig-rewriteCONFIG REWRITE persists all runtime CONFIG SET changes to redis.conf permanently.
Explanation
CONFIG REWRITE writes current runtime config back to redis.conf: - Makes all CONFIG SET changes survive restarts - Can persist dangerous temporary changes permanently - No undo: must manually edit redis.conf to revert Review current runtime changes first: CONFIG GET * # Compare with original redis.conf Ensure no dangerous CONFIG SET changes are pending before rewriting.
Highconfig-set-appendonlyCONFIG SET appendonly can disable AOF persistence, risking data loss on restart.
Explanation
Disabling AOF without RDB means zero persistence: - CONFIG SET appendonly no: Stops AOF logging - Combined with disabled RDB: complete data loss on crash/restart Check other persistence mechanisms: CONFIG GET save CONFIG GET appendonly Ensure at least one persistence mechanism remains active.
Highconfig-set-saveCONFIG SET save can disable RDB persistence entirely, risking data loss on restart.
Explanation
CONFIG SET save "" disables all RDB snapshots: - No automatic persistence to disk - All data lost on restart unless AOF is enabled - Existing RDB file may become stale Check current persistence: CONFIG GET save CONFIG GET appendonly Ensure at least one persistence mechanism remains active.
Highdebug-sleepDEBUG SLEEP blocks the Redis server and can cause availability issues.
Explanation
DEBUG SLEEP blocks the Redis server for the specified duration: - All client connections freeze - No commands are processed - Cluster may mark node as failed - Can trigger failover in Sentinel setups This is meant for testing timeouts, not production use. Disable in production: CONFIG SET debug-command no
HighflushdbFLUSHDB permanently deletes ALL keys in the current database.
Explanation
FLUSHDB removes all keys from the currently selected database: - All keys in this database are deleted - Other databases (0-15) are unaffected - Instant execution, no confirmation - Cannot be undone Check current database and key count: CLIENT INFO # Shows current DB DBSIZE # Keys in current DB KEYS '*' | head -20 # Sample keys (slow on large DBs) Prefer audited per-key cleanup with a dry run and backup.
Highmass-delete-pipelineRedis KEYS/SCAN piped to DEL/UNLINK can delete many keys at once.
Explanation
Piping Redis key enumeration into DEL or UNLINK can delete every matching key: - redis-cli KEYS '*' | xargs redis-cli DEL removes all returned keys - redis-cli --scan --pattern 'prefix:*' | xargs redis-cli UNLINK removes a whole key namespace - This bypasses Redis's lack of wildcard DEL by expanding keys client-side Safer alternatives: redis-cli --scan --pattern 'prefix:*' | head -50 # inspect first Count and back up affected keys before selective deletion Prefer application-owned cleanup tooling with dry-run support
HighshutdownSHUTDOWN stops the Redis server. SHUTDOWN NOSAVE risks data loss.
Explanation
SHUTDOWN stops the Redis server: - SHUTDOWN SAVE: Saves RDB before exit (default) - SHUTDOWN NOSAVE: Exits immediately, no save - All client connections are closed - Services depending on Redis fail Check for unsaved changes: INFO persistence # Look at rdb_changes_since_last_save Ensure proper restart mechanism exists (systemd, Docker, etc.).
Highstdin-unverifiedredis-cli receives indirect input that dcg cannot statically verify.
Explanation
Materialize and review the exact Redis commands before piping or redirecting them into the client.
Mediumconfig-resetstatCONFIG RESETSTAT clears Redis runtime counters and can hide recent incidents.
Explanation
CONFIG RESETSTAT resets Redis statistics reported by INFO: - Command counters and error counters are cleared - Recent operational evidence can be lost - Capacity and incident analysis becomes harder Capture INFO and monitoring data first, then run this manually only when resetting observability counters is intentional.
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
redis-getredis-scanredis-inforedis-keysredis-dbsizeredis-config-get