Encryption

From tinh2/skills-hub-registry · View interactive version

Encryption is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Audit and harden encryption across the full stack. Checks data-at-rest encryption (database TDE, field-level AES-256-GCM, file storage SSE, backup encryption), data-in-transit security (TLS 1.2+, HSTS, certificate pinning, mTLS, WebSocket WSS), key management (KMS, envelope encryption.

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Audit current encryption state, then implement improvements.

TARGET:

$ARGUMENTS

If no arguments provided, perform a full encryption audit and generate an implementation plan. If arguments specify an area (e.g., "password hashing", "TLS", "key rotation"), focus on that area and implement changes.

============================================================

PHASE 0: TECH STACK DETECTION

============================================================

Auto-detect the project's technology stack:

Record the stack — encryption implementation varies significantly by technology.

============================================================

PHASE 1: DATA AT REST ENCRYPTION AUDIT

============================================================

Assess current encryption of stored data:

DATABASE ENCRYPTION:

FIELD-LEVEL ENCRYPTION:

FILE ENCRYPTION:

BACKUP ENCRYPTION:

For each area: current state, gaps, and recommended implementation.

============================================================

PHASE 2: DATA IN TRANSIT ENCRYPTION AUDIT

============================================================

Assess encryption of data in motion:

TLS CONFIGURATION:

SECURITY HEADERS:

CERTIFICATE PINNING (mobile apps):

INTERNAL COMMUNICATION:

============================================================

PHASE 3: KEY MANAGEMENT AUDIT AND IMPLEMENTATION

============================================================

Assess and improve cryptographic key management:

CURRENT STATE AUDIT:

KEY ROTATION STRATEGY:

Generate a key rotation plan based on the detected stack:

For AWS:

- Use AWS KMS for master keys
- Implement envelope encryption: KMS key → data key → encrypt data
- Enable automatic annual rotation for KMS keys
- Data keys rotated per-session or per-record

For GCP:

- Use Cloud KMS for master keys
- Enable automatic rotation (90-day recommended)
- Use envelope encryption pattern
- Separate key rings per environment

For self-hosted / Vault:

- Use HashiCorp Vault Transit secrets engine
- Configure auto-rotation policies
- Implement key versioning for re-encryption
- Set up audit logging for key access

ENVELOPE ENCRYPTION IMPLEMENTATION:

If the project needs field-level encryption, implement the envelope encryption pattern:

  1. Master key stored in KMS (never leaves KMS)
  2. Data Encryption Key (DEK) generated per record or per batch
  3. DEK encrypted by master key, stored alongside encrypted data
  4. On decrypt: KMS decrypts DEK, DEK decrypts data

Provide implementation code specific to the detected stack.

============================================================

PHASE 4: PASSWORD HASHING AUDIT

============================================================

Assess password storage security:

ALGORITHM CHECK:

CONFIGURATION CHECK:

SALT CHECK:

MIGRATION PLAN:

If the current algorithm is weak, generate a migration plan:

  1. Implement new hashing algorithm alongside old
  2. On login: verify with old algorithm, re-hash with new, store new hash
  3. Set deadline for forced password reset for accounts not yet migrated
  4. Remove old algorithm support after migration period

============================================================

PHASE 5: TOKEN AND API KEY SECURITY

============================================================

Assess token generation and API key management:

TOKEN GENERATION:

API KEY MANAGEMENT:

REFRESH TOKEN SECURITY:

============================================================

PHASE 6: IMPLEMENTATION

============================================================

If the $ARGUMENTS request implementation (not just audit), apply fixes:

For each issue found in Phases 1-5:

  1. Implement the fix using the project's existing patterns and dependencies
  2. Add or update configuration as needed
  3. Write migration scripts if data format changes
  4. Verify the fix works (run tests, verify encryption/decryption roundtrip)
  5. Commit each logical change separately with descriptive messages

Priority order for implementation:

  1. Hardcoded secrets → move to environment variables or secret manager
  2. Weak password hashing → upgrade algorithm
  3. Missing TLS verification → enable proper certificate validation
  4. Unencrypted PII → add field-level encryption
  5. Missing security headers → add header middleware
  6. Key rotation → implement rotation strategy

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing the security analysis, validate thoroughness:

  1. Verify every category in the audit was actually checked (not skipped).
  2. Verify every finding has a specific file:line location.
  3. Verify severity ratings are justified by impact assessment.
  4. Verify no false positives by re-reading flagged code in context.

IF VALIDATION FAILS:

============================================================

OUTPUT

============================================================

Encryption Audit Report

Project: [name]

Stack: [detected technologies]

Date: [date]

Summary

| Area | Status | Findings |

|------|--------|----------|

| Data at Rest | [GOOD/PARTIAL/WEAK/NONE] | N issues |

| Data in Transit | [GOOD/PARTIAL/WEAK/NONE] | N issues |

| Key Management | [GOOD/PARTIAL/WEAK/NONE] | N issues |

| Password Hashing | [GOOD/PARTIAL/WEAK/NONE] | N issues |

| Token Security | [GOOD/PARTIAL/WEAK/NONE] | N issues |

| API Key Security | [GOOD/PARTIAL/WEAK/NONE] | N issues |

Critical Findings (fix immediately)

[Hardcoded secrets, plaintext passwords, disabled TLS, etc.]

Recommendations

[Ordered list by priority with implementation guidance]

Implementation Plan

| Priority | Area | Action | Effort | Dependencies |

|----------|------|--------|--------|-------------|

| P0 | Secrets | Move to env vars | 1 hour | None |

| P1 | Passwords | Upgrade to argon2 | 4 hours | Migration script |

| P2 | PII | Field-level encryption | 1 day | KMS setup |

Changes Made (if implementation was performed)

[List of commits with descriptions of what was implemented]

============================================================

NEXT STEPS

============================================================

After reviewing the encryption audit:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /encryption — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

============================================================

DO NOT

============================================================

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.