Skip to content

Commit 17faa8d

Browse files
valkirilovclaude
andcommitted
feat(redis-security): add spec-compliant skill for production hardening
Introduces skills/redis-security/ covering the three security-* rules from skills/redis-development/rules/ in agentskills.io spec layout: security-auth → references/auth.md security-acls → references/acls.md security-network → references/network.md SKILL.md frames the skill around three layers that all need to be in place for a production-grade deployment: authentication + TLS, ACL- based least-privilege users, and network exposure controls (bind + firewall + rename-command). References carry the full Python and Java code samples and configuration snippets. Additive only: the source security-*.md rules under skills/redis-development/ remain in place so the legacy compiled AGENTS.md continues to serve existing plugin consumers unchanged. They are removed in the final cleanup PR alongside the rest of the rules/ tree. Validation: - skill-validator check skills/redis-security → passed (0 warnings) - npm run validate → rules + plugin validators green Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9d76cea commit 17faa8d

4 files changed

Lines changed: 247 additions & 0 deletions

File tree

skills/redis-security/SKILL.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: redis-security
3+
description: Redis security guidance covering authentication (requirepass and ACL users), TLS, ACL-based least-privilege access control, restricting network exposure via bind and protected-mode, firewall rules, and disabling dangerous commands. Use when deploying Redis to production, defining ACL users for an application, configuring TLS connections, locking down a Redis instance behind a firewall, or auditing a Redis deployment for security hardening.
4+
license: MIT
5+
metadata:
6+
author: Redis, Inc.
7+
version: "0.1.0"
8+
---
9+
10+
# Redis Security
11+
12+
Production hardening for Redis: authentication, ACL-based access control, and network exposure. Cover all three together — any one of them on its own leaves an exploitable gap.
13+
14+
## When to apply
15+
16+
- Deploying or reviewing a Redis instance destined for production.
17+
- Setting up application credentials beyond a shared password.
18+
- Auditing a Redis deployment against a security checklist.
19+
- Receiving "Redis exposed to the internet" findings from a scanner.
20+
21+
## 1. Always authenticate (and use TLS)
22+
23+
Never run a production Redis without a password. Pair authentication with TLS so credentials and data aren't sent in clear text.
24+
25+
```
26+
# redis.conf
27+
requirepass your-strong-password
28+
tls-port 6380
29+
tls-cert-file /path/to/redis.crt
30+
tls-key-file /path/to/redis.key
31+
```
32+
33+
```python
34+
r = redis.Redis(
35+
host="localhost",
36+
port=6380,
37+
password="your-strong-password",
38+
ssl=True,
39+
ssl_cert_reqs="required",
40+
)
41+
```
42+
43+
If you can use ACL users (next section) instead of the single `requirepass`, do — `requirepass` is effectively the legacy "default user" shortcut.
44+
45+
See [references/auth.md](references/auth.md).
46+
47+
## 2. ACLs for least-privilege access
48+
49+
The `default` user with a shared password is fine for development. For production, give each application a dedicated ACL user with only the commands and key patterns it actually needs.
50+
51+
```
52+
# Cache-only reader
53+
ACL SETUSER app_readonly on >password ~cache:* +get +mget +scan
54+
55+
# Writer that can't run dangerous ops
56+
ACL SETUSER app_writer on >password ~* +@all -@dangerous
57+
58+
# Admin (use sparingly, never for application traffic)
59+
ACL SETUSER admin on >strong-password ~* +@all
60+
```
61+
62+
Useful command categories:
63+
64+
| Category | What it covers |
65+
|---|---|
66+
| `@read` | Read commands (`GET`, `MGET`, `HGET`, ...) |
67+
| `@write` | Write commands (`SET`, `DEL`, `XADD`, ...) |
68+
| `@dangerous` | `FLUSHALL`, `DEBUG`, `KEYS`, etc. |
69+
| `@admin` | Administrative commands |
70+
71+
If app credentials leak, a tight ACL bounds the blast radius — the attacker can't `FLUSHALL` your DB just because they grabbed a cache reader's password.
72+
73+
See [references/acls.md](references/acls.md).
74+
75+
## 3. Restrict network access
76+
77+
The most common Redis breach is a public-internet Redis with no auth. Avoid that with three layers:
78+
79+
```
80+
# redis.conf — bind to specific interfaces, keep protected-mode on
81+
bind 127.0.0.1 192.168.1.100
82+
protected-mode yes
83+
```
84+
85+
```bash
86+
# Firewall — allow only application subnets
87+
iptables -A INPUT -p tcp --dport 6379 -s 192.168.1.0/24 -j ACCEPT
88+
iptables -A INPUT -p tcp --dport 6379 -j DROP
89+
```
90+
91+
Anti-pattern: `bind 0.0.0.0` + `protected-mode no` — exposes Redis to the whole network without protection.
92+
93+
Optional but recommended: rename or disable destructive commands so a compromised client can't trash the DB:
94+
95+
```
96+
rename-command FLUSHALL ""
97+
rename-command DEBUG ""
98+
rename-command CONFIG ""
99+
```
100+
101+
See [references/network.md](references/network.md).
102+
103+
## References
104+
105+
- [Redis: Security](https://redis.io/docs/latest/operate/oss_and_stack/management/security/)
106+
- [Redis: ACL](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Use ACLs for Fine-Grained Access Control
2+
3+
Create users with only the permissions they need (principle of least privilege).
4+
5+
**Correct:** Create specific users with limited permissions.
6+
7+
```
8+
# Read-only user for cache access
9+
ACL SETUSER app_readonly on >password ~cache:* +get +mget +scan
10+
11+
# Writer that can't run dangerous commands
12+
ACL SETUSER app_writer on >password ~* +@all -@dangerous
13+
14+
# Admin user (use sparingly)
15+
ACL SETUSER admin on >strong-password ~* +@all
16+
```
17+
18+
**Incorrect:** Using the default user for everything.
19+
20+
```
21+
# Bad: Single password for all access
22+
requirepass shared-password
23+
```
24+
25+
**ACL categories:**
26+
- `@read` - Read commands
27+
- `@write` - Write commands
28+
- `@dangerous` - Commands like FLUSHALL, DEBUG
29+
- `@admin` - Administrative commands
30+
31+
Reference: [Redis ACL](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Always Use Authentication in Production
2+
3+
Never run Redis without authentication in production environments.
4+
5+
**Correct:** Use password and TLS.
6+
7+
**Python** (redis-py):
8+
```python
9+
r = redis.Redis(
10+
host='localhost',
11+
port=6379,
12+
password='your-strong-password',
13+
ssl=True,
14+
ssl_cert_reqs='required'
15+
)
16+
```
17+
18+
**Java** (Jedis):
19+
```java
20+
import redis.clients.jedis.*;
21+
import javax.net.ssl.*;
22+
import java.security.KeyStore;
23+
24+
// Create SSL context with trust store and key store
25+
KeyStore trustStore = KeyStore.getInstance("jks");
26+
trustStore.load(new FileInputStream("./truststore.jks"), "password".toCharArray());
27+
28+
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
29+
tmf.init(trustStore);
30+
31+
SSLContext sslContext = SSLContext.getInstance("TLS");
32+
sslContext.init(null, tmf.getTrustManagers(), null);
33+
34+
JedisClientConfig config = DefaultJedisClientConfig.builder()
35+
.ssl(true)
36+
.sslSocketFactory(sslContext.getSocketFactory())
37+
.user("redisUser")
38+
.password("redisPassword")
39+
.build();
40+
41+
JedisPooled jedis = new JedisPooled(new HostAndPort("redis-host", 6379), config);
42+
```
43+
44+
**Incorrect:** Connecting without authentication.
45+
46+
**Python** (redis-py):
47+
```python
48+
# Bad: No authentication
49+
r = redis.Redis(host='localhost', port=6379)
50+
```
51+
52+
**Java** (Jedis):
53+
```java
54+
// Bad: No authentication or TLS
55+
UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379");
56+
```
57+
58+
**Configuration:**
59+
60+
```
61+
# redis.conf
62+
requirepass your-strong-password
63+
tls-port 6380
64+
tls-cert-file /path/to/redis.crt
65+
tls-key-file /path/to/redis.key
66+
```
67+
68+
Reference: [Redis Security](https://redis.io/docs/latest/operate/oss_and_stack/management/security/)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Secure Network Access
2+
3+
Restrict network access to Redis to only trusted sources.
4+
5+
**Correct:** Bind to specific interfaces.
6+
7+
```
8+
# redis.conf
9+
bind 127.0.0.1 192.168.1.100
10+
protected-mode yes
11+
```
12+
13+
**Correct:** Use firewall rules.
14+
15+
```bash
16+
# Allow only application servers
17+
iptables -A INPUT -p tcp --dport 6379 -s 192.168.1.0/24 -j ACCEPT
18+
iptables -A INPUT -p tcp --dport 6379 -j DROP
19+
```
20+
21+
**Incorrect:** Exposing Redis to the internet.
22+
23+
```
24+
# Bad: Binds to all interfaces
25+
bind 0.0.0.0
26+
protected-mode no
27+
```
28+
29+
**Security checklist:**
30+
- Use TLS for connections
31+
- Bind to specific interfaces, not `0.0.0.0`
32+
- Use firewall rules to restrict access
33+
- Disable dangerous commands in production
34+
35+
```
36+
# Disable dangerous commands
37+
rename-command FLUSHALL ""
38+
rename-command DEBUG ""
39+
rename-command CONFIG ""
40+
```
41+
42+
Reference: [Redis Security](https://redis.io/docs/latest/operate/oss_and_stack/management/security/)

0 commit comments

Comments
 (0)