Marketplace

secrets-management

Use when designing secret storage, rotation, or credential management systems. Covers HashiCorp Vault patterns, AWS Secrets Manager, Azure Key Vault, secret rotation, and zero-knowledge architectures.

allowed_tools: Read, Glob, Grep

$ Instalar

git clone https://github.com/melodic-software/claude-code-plugins /tmp/claude-code-plugins && cp -r /tmp/claude-code-plugins/plugins/systems-design/skills/secrets-management ~/.claude/skills/claude-code-plugins

// tip: Run this command in your terminal to install the skill


name: secrets-management description: Use when designing secret storage, rotation, or credential management systems. Covers HashiCorp Vault patterns, AWS Secrets Manager, Azure Key Vault, secret rotation, and zero-knowledge architectures. allowed-tools: Read, Glob, Grep

Secrets Management

Comprehensive guide to managing secrets, credentials, and sensitive configuration - from storage to rotation to access control.

When to Use This Skill

  • Designing secret storage architecture
  • Implementing secret rotation
  • Integrating applications with secret stores
  • Managing API keys, passwords, certificates
  • Understanding Vault, AWS Secrets Manager, Azure Key Vault
  • Zero-knowledge and envelope encryption patterns

Secrets Management Fundamentals

What Are Secrets?

Types of Secrets:

Credentials:
โ”œโ”€โ”€ Database passwords
โ”œโ”€โ”€ API keys
โ”œโ”€โ”€ OAuth client secrets
โ”œโ”€โ”€ SSH private keys
โ””โ”€โ”€ Service account tokens

Certificates:
โ”œโ”€โ”€ TLS certificates and private keys
โ”œโ”€โ”€ Code signing certificates
โ”œโ”€โ”€ Client certificates
โ””โ”€โ”€ CA certificates

Encryption Keys:
โ”œโ”€โ”€ Data encryption keys (DEK)
โ”œโ”€โ”€ Key encryption keys (KEK)
โ”œโ”€โ”€ HMAC keys
โ””โ”€โ”€ Signing keys

Sensitive Configuration:
โ”œโ”€โ”€ Connection strings
โ”œโ”€โ”€ License keys
โ”œโ”€โ”€ Webhook URLs with tokens
โ””โ”€โ”€ Third-party credentials

Secrets Lifecycle

Secret Lifecycle:

1. Generation
   โ””โ”€โ”€ Create with sufficient entropy
   โ””โ”€โ”€ Use cryptographic randomness
   โ””โ”€โ”€ Appropriate key length

2. Storage
   โ””โ”€โ”€ Encrypt at rest
   โ””โ”€โ”€ Access control
   โ””โ”€โ”€ Audit logging

3. Distribution
   โ””โ”€โ”€ Secure transport (TLS)
   โ””โ”€โ”€ Just-in-time access
   โ””โ”€โ”€ Minimize copies

4. Usage
   โ””โ”€โ”€ Memory protection
   โ””โ”€โ”€ Minimize exposure window
   โ””โ”€โ”€ Clear after use

5. Rotation
   โ””โ”€โ”€ Regular schedule
   โ””โ”€โ”€ Zero-downtime rotation
   โ””โ”€โ”€ Update all consumers

6. Revocation
   โ””โ”€โ”€ Immediate effect
   โ””โ”€โ”€ Propagate to all systems
   โ””โ”€โ”€ Audit trail

7. Destruction
   โ””โ”€โ”€ Secure deletion
   โ””โ”€โ”€ Verify removal
   โ””โ”€โ”€ Clear backups

Architecture Patterns

Centralized Secret Store

Centralized Architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Secret Store                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  โ€ข Encrypted storage                    โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Access control                       โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Audit logging                        โ”‚    โ”‚
โ”‚  โ”‚  โ€ข Rotation management                  โ”‚    โ”‚
โ”‚  โ”‚  โ€ข High availability                    โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚             โ”‚             โ”‚
   โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”
   โ”‚ App A   โ”‚  โ”‚ App B   โ”‚  โ”‚ App C   โ”‚
   โ”‚         โ”‚  โ”‚         โ”‚  โ”‚         โ”‚
   โ”‚Fetches  โ”‚  โ”‚Fetches  โ”‚  โ”‚Fetches  โ”‚
   โ”‚secrets  โ”‚  โ”‚secrets  โ”‚  โ”‚secrets  โ”‚
   โ”‚on start โ”‚  โ”‚on demandโ”‚  โ”‚cached   โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Benefits:
+ Single source of truth
+ Centralized audit
+ Consistent policies
+ Easier rotation

Challenges:
- Single point of failure
- Network dependency
- Latency for secret access

Envelope Encryption

Envelope Encryption:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 Key Hierarchy                    โ”‚
โ”‚                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                โ”‚
โ”‚  โ”‚ Master Key  โ”‚  (Never leaves KMS)            โ”‚
โ”‚  โ”‚   (KEK)     โ”‚                                โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                โ”‚
โ”‚         โ”‚ Encrypts                              โ”‚
โ”‚         โ–ผ                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                โ”‚
โ”‚  โ”‚  Data Key   โ”‚  (Wrapped/encrypted)           โ”‚
โ”‚  โ”‚   (DEK)     โ”‚                                โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                โ”‚
โ”‚         โ”‚ Encrypts                              โ”‚
โ”‚         โ–ผ                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                โ”‚
โ”‚  โ”‚    Data     โ”‚  (Your secrets/data)           โ”‚
โ”‚  โ”‚             โ”‚                                โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Flow:
1. Generate DEK locally
2. Encrypt data with DEK
3. Send DEK to KMS for wrapping with KEK
4. Store: encrypted data + wrapped DEK
5. To decrypt: unwrap DEK with KMS, decrypt data

Benefits:
- Master key never exposed
- Can rotate DEK without re-encrypting all data
- Distributed encryption (KMS not a bottleneck)

Zero-Knowledge Architecture

Zero-Knowledge Secret Access:

                                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                    โ”‚    Client    โ”‚
                                    โ”‚              โ”‚
                                    โ”‚ Has: secret  โ”‚
                                    โ”‚ key derived  โ”‚
                                    โ”‚ from passwordโ”‚
                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                           โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚                   Server                      โ”‚
                    โ”‚                                               โ”‚
                    โ”‚  Stores: encrypted secrets                    โ”‚
                    โ”‚  Cannot decrypt (doesn't have key)            โ”‚
                    โ”‚                                               โ”‚
                    โ”‚  User's secrets = Encrypt(data, userDerivedKey)โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Properties:
- Server cannot read secrets even if compromised
- User password never transmitted
- Key derived client-side using KDF
- Server only sees encrypted blobs

Trade-offs:
+ Maximum privacy
+ Server breach doesn't expose secrets
- Can't recover if user forgets password
- Can't audit what's stored
- Server can't validate secrets

HashiCorp Vault

Vault Architecture

Vault Components:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Vault                            โ”‚
โ”‚                                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚                 API Layer                     โ”‚  โ”‚
โ”‚  โ”‚  (HTTP/HTTPS interface for all operations)   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                        โ”‚                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚              Auth Methods                     โ”‚  โ”‚
โ”‚  โ”‚  Token โ”‚ OIDC โ”‚ LDAP โ”‚ K8s โ”‚ AWS โ”‚ Azure    โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                        โ”‚                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚             Secrets Engines                   โ”‚  โ”‚
โ”‚  โ”‚  KV โ”‚ Database โ”‚ PKI โ”‚ Transit โ”‚ AWS โ”‚ SSH   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                        โ”‚                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚              Storage Backend                  โ”‚  โ”‚
โ”‚  โ”‚  Consul โ”‚ Raft โ”‚ S3 โ”‚ DynamoDB โ”‚ etcd        โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Vault Secrets Engines

Common Secrets Engines:

1. KV (Key-Value)
   - Static secrets storage
   - Versioning support
   - Simplest engine

2. Database
   - Dynamic database credentials
   - Auto-rotation
   - Short-lived credentials

   vault write database/roles/my-role \
     db_name=my-database \
     creation_statements="CREATE USER..." \
     default_ttl="1h" \
     max_ttl="24h"

3. PKI
   - Certificate authority
   - Issue short-lived certificates
   - Auto-renewal

4. Transit
   - Encryption as a service
   - Key management
   - Sign/verify operations

5. AWS/Azure/GCP
   - Dynamic cloud credentials
   - IAM role assumption
   - Temporary access

Vault Authentication

Auth Method Selection:

Kubernetes:
- Best for: Pods in Kubernetes
- Identity: Service account token
- Config: Bound namespace/SA

vault auth enable kubernetes
vault write auth/kubernetes/config \
  kubernetes_host="https://kubernetes:443" \
  kubernetes_ca_cert=@ca.crt

AppRole:
- Best for: CI/CD, applications
- Identity: Role ID + Secret ID
- Config: Bound CIDR, metadata

vault auth enable approle
vault write auth/approle/role/my-app \
  token_ttl=1h \
  token_max_ttl=4h \
  secret_id_num_uses=1

OIDC:
- Best for: Human users
- Identity: JWT from IdP
- Config: OIDC provider connection

Cloud Secret Managers

AWS Secrets Manager

AWS Secrets Manager Features:

Capabilities:
โ”œโ”€โ”€ Automatic rotation (Lambda-based)
โ”œโ”€โ”€ Cross-region replication
โ”œโ”€โ”€ IAM integration
โ”œโ”€โ”€ CloudTrail auditing
โ””โ”€โ”€ Resource policies

Rotation Flow:
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ 1. createSecret   - Create new secret version  โ”‚
โ”‚ 2. setSecret      - Update resource (RDS, etc) โ”‚
โ”‚ 3. testSecret     - Verify new secret works    โ”‚
โ”‚ 4. finishSecret   - Mark rotation complete     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Access Pattern:
aws secretsmanager get-secret-value \
  --secret-id my-secret \
  --version-stage AWSCURRENT

SDK Integration:
client = boto3.client('secretsmanager')
response = client.get_secret_value(SecretId='my-secret')
secret = json.loads(response['SecretString'])

Azure Key Vault

Azure Key Vault Features:

Object Types:
โ”œโ”€โ”€ Secrets - Generic key/value
โ”œโ”€โ”€ Keys - Cryptographic keys (HSM-backed)
โ””โ”€โ”€ Certificates - X.509 certificates

Access Control:
- RBAC (recommended)
- Access policies (legacy)
- Managed identities for Azure resources

Soft Delete + Purge Protection:
- Deleted secrets retained for recovery period
- Purge protection prevents permanent deletion
- Required for compliance scenarios

Integration:
// .NET example with DefaultAzureCredential
var client = new SecretClient(
    new Uri("https://my-vault.vault.azure.net/"),
    new DefaultAzureCredential());

KeyVaultSecret secret = await client.GetSecretAsync("my-secret");

GCP Secret Manager

GCP Secret Manager Features:

Capabilities:
โ”œโ”€โ”€ Automatic replication (regional/global)
โ”œโ”€โ”€ IAM integration
โ”œโ”€โ”€ Audit logging
โ”œโ”€โ”€ Secret versioning
โ””โ”€โ”€ Expiration support

Access Control:
- roles/secretmanager.secretAccessor
- roles/secretmanager.admin
- IAM conditions for fine-grained access

Workload Identity:
- GKE pods use service accounts
- No credential files needed
- Automatic token refresh

Access Pattern:
gcloud secrets versions access latest --secret=my-secret

# Python
from google.cloud import secretmanager
client = secretmanager.SecretManagerServiceClient()
response = client.access_secret_version(name=secret_version_name)
secret = response.payload.data.decode('UTF-8')

Secret Rotation

Zero-Downtime Rotation

Dual-Version Strategy:

Phase 1: Create New Version
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Secret Store                     โ”‚
โ”‚ โ”œโ”€โ”€ Version 1 (current) โœ“       โ”‚
โ”‚ โ””โ”€โ”€ Version 2 (pending)  NEW    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase 2: Update Consumers
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Apps accept: Version 1 OR 2     โ”‚
โ”‚ Resource updated to Version 2   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase 3: Verify New Version
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Test connections with Version 2 โ”‚
โ”‚ Monitor for errors              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase 4: Deprecate Old Version
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Secret Store                     โ”‚
โ”‚ โ”œโ”€โ”€ Version 1 (deprecated)      โ”‚
โ”‚ โ””โ”€โ”€ Version 2 (current) โœ“       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Phase 5: Remove Old Version
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Secret Store                     โ”‚
โ”‚ โ””โ”€โ”€ Version 2 (current) โœ“       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Database Credential Rotation

Database Rotation Pattern:

Approach 1: Dual Users
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Database has TWO users for the app:            โ”‚
โ”‚ - app_user_a (current)                          โ”‚
โ”‚ - app_user_b (standby)                          โ”‚
โ”‚                                                 โ”‚
โ”‚ Rotation:                                       โ”‚
โ”‚ 1. Generate new password for app_user_b        โ”‚
โ”‚ 2. Update secret to point to app_user_b        โ”‚
โ”‚ 3. Apps pick up new credentials                โ”‚
โ”‚ 4. Change app_user_a password (now standby)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Approach 2: Dynamic Credentials (Vault)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Each credential request creates new user:       โ”‚
โ”‚ - v-app-abc123-ttl-1h (expires in 1 hour)      โ”‚
โ”‚                                                 โ”‚
โ”‚ Benefits:                                       โ”‚
โ”‚ - No rotation needed                            โ”‚
โ”‚ - Automatic cleanup                             โ”‚
โ”‚ - Per-request credentials                       โ”‚
โ”‚                                                 โ”‚
โ”‚ Vault handles:                                  โ”‚
โ”‚ - Creating users                                โ”‚
โ”‚ - Setting expiration                            โ”‚
โ”‚ - Revoking expired credentials                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Application Integration

Sidecar Pattern

Sidecar Secret Injection:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Pod                           โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Vault Agent   โ”‚  โ”‚      App            โ”‚  โ”‚
โ”‚  โ”‚   (Sidecar)     โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ”‚                 โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ”‚  - Authenticatesโ”‚  โ”‚  Reads secrets from โ”‚  โ”‚
โ”‚  โ”‚  - Fetches      โ”‚โ”€โ”€โ–บ  /vault/secrets/    โ”‚  โ”‚
โ”‚  โ”‚  - Renders      โ”‚  โ”‚  (shared volume)    โ”‚  โ”‚
โ”‚  โ”‚  - Refreshes    โ”‚  โ”‚                     โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚            โ”‚                    โ”‚               โ”‚
โ”‚            โ–ผ                    โ”‚               โ”‚
โ”‚     [Shared Volume]โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”‚
โ”‚     /vault/secrets/                             โ”‚
โ”‚     โ””โ”€โ”€ db-password                             โ”‚
โ”‚     โ””โ”€โ”€ api-key                                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

CSI Driver Pattern

Secrets Store CSI Driver:

apiVersion: v1
kind: Pod
spec:
  containers:
  - name: app
    volumeMounts:
    - name: secrets
      mountPath: "/mnt/secrets"
      readOnly: true
  volumes:
  - name: secrets
    csi:
      driver: secrets-store.csi.k8s.io
      readOnly: true
      volumeAttributes:
        secretProviderClass: "vault-database"

---
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: vault-database
spec:
  provider: vault
  parameters:
    vaultAddress: "https://vault:8200"
    roleName: "db-role"
    objects: |
      - objectName: "db-password"
        secretPath: "secret/data/db"
        secretKey: "password"

Best Practices

Security Best Practices:

1. Never Store Secrets In:
   โŒ Source code
   โŒ Environment variables (visible in logs)
   โŒ Container images
   โŒ Kubernetes ConfigMaps
   โŒ Plain text files

2. Access Control:
   โ–ก Least privilege access
   โ–ก Service-specific credentials
   โ–ก Time-limited access where possible
   โ–ก Regular access reviews

3. Audit and Monitoring:
   โ–ก Log all secret access
   โ–ก Alert on unusual patterns
   โ–ก Regular audit reviews
   โ–ก Compliance reporting

4. Rotation:
   โ–ก Automate all rotations
   โ–ก Short credential lifetimes
   โ–ก Test rotation procedures
   โ–ก Document emergency rotation

5. High Availability:
   โ–ก Secret store must be HA
   โ–ก Cache secrets for availability
   โ–ก Graceful degradation plan
   โ–ก Recovery procedures documented

Related Skills

  • zero-trust-architecture - Overall security architecture
  • api-security - API authentication and authorization
  • mtls-service-mesh - Certificate management for services
  • container-orchestration - Kubernetes secrets integration

Repository

melodic-software
melodic-software
Author
melodic-software/claude-code-plugins/plugins/systems-design/skills/secrets-management
3
Stars
0
Forks
Updated3d ago
Added1w ago