Skip to content

Security: kelleyblackmore/Automatic-Secret-Rotation

SECURITY.md

Security Summary

Security Assessment for Automatic Secret Rotation Tool

Overview

This document summarizes the security considerations and measures implemented in the automatic secret rotation tool.

Security Measures Implemented

1. Cryptographically Secure Random Generation

  • Implementation: Uses rand::thread_rng() with secure random number generation
  • Character Set: Includes uppercase, lowercase, numbers, and special characters
  • Default Length: 32 characters (configurable)
  • Location: src/rotation.rs::generate_secret()

2. Secure Communication with Vault

  • TLS Support: Fully supports HTTPS endpoints for Vault
  • Token Security: Tokens are never logged or displayed
  • Environment Variables: Supports secure token passing via environment
  • No Hardcoded Secrets: All sensitive data comes from config or environment

3. Metadata-Based Tracking

  • No Secret Storage: Rotation metadata doesn't contain actual secrets
  • Timestamps Only: Only stores rotation dates and periods
  • Vault-Native: Uses Vault's built-in metadata system

4. Error Handling

  • No Secret Leakage: Error messages don't expose secret values
  • Context Preservation: Errors include helpful context without secrets
  • Proper Propagation: Uses anyhow for error handling

Known Security Considerations

Cleartext Output (By Design)

Status: Intentional Feature with Warnings

The following commands intentionally display secrets in cleartext:

  • asr rotate <path> - Shows newly rotated secret
  • asr read <path> - Shows secret values

Justification:

  • Users need to see rotated secrets to update applications
  • This is the primary use case for manual rotation

Mitigations Implemented:

  1. Security warnings displayed before and after showing secrets
  2. Output to stderr for warnings (separate from secret data)
  3. Documentation clearly explains security implications
  4. Recommendation to use auto command for automated rotation (no cleartext output)
  5. Best practices documented in README and USAGE guides

Warnings Added:

WARNING: Secret value will be displayed. Ensure this output is secured.
WARNING: Please update your application with the new secret and clear your terminal history.

CodeQL Findings

Finding: Cleartext Logging Alert Location: src/main.rs - rotate and read commands Status: Acknowledged and Mitigated

Analysis:

  • This is an intentional design decision for a CLI tool
  • Users explicitly request to view secrets
  • Security warnings have been added
  • Documentation updated with security best practices

No Code Changes Required: The cleartext output is necessary functionality Mitigation: Education and warnings to users

Security Best Practices Documented

The following security best practices are documented in README.md:

  1. Vault Token Security

    • Use environment variables for tokens
    • Store tokens in CI/CD secret management
    • Never commit tokens to source control
  2. TLS Communication

    • Use HTTPS for production Vault endpoints
    • Verify TLS certificates
  3. Terminal Security

    • Clear terminal history after viewing secrets
    • Use secure environments only
    • Avoid logging command output containing secrets
  4. Vault Permissions

    • Use minimal required permissions
    • Separate tokens for different environments
    • Regular token rotation
  5. Audit Logging

    • Enable Vault audit logging
    • Monitor rotation operations
    • Track access patterns
  6. Automation Security

    • Use auto command in CI/CD (no cleartext output)
    • Secure CI/CD secret storage
    • Limit token scope and lifetime

Dependencies Security

All dependencies are from trusted sources (crates.io):

  • Regular security updates via Cargo
  • No known vulnerabilities in current versions
  • Minimal dependency tree to reduce attack surface

Recommended Usage Patterns

Secure (Automated)

# CI/CD pipeline - no cleartext output
asr auto

Less Secure (Manual)

# Manual rotation - displays secret
# Use only in secure terminals
asr rotate app/password

Security Checklist for Users

  • Use HTTPS Vault endpoints in production
  • Store Vault tokens securely (environment variables or secret management)
  • Enable Vault audit logging
  • Use minimal required permissions for Vault tokens
  • Clear terminal history after viewing secrets
  • Use auto command for automation (avoids cleartext output)
  • Never log or redirect output containing secrets to files
  • Regularly rotate Vault tokens themselves
  • Monitor and review audit logs

Conclusion

The automatic secret rotation tool implements industry-standard security practices:

  • Cryptographically secure random generation
  • Secure communication with Vault (TLS support)
  • No secret storage in metadata
  • Proper error handling without secret leakage
  • Clear security warnings when secrets are displayed
  • Comprehensive security documentation

The intentional cleartext output for rotate and read commands is a necessary feature for a CLI tool, with appropriate warnings and documentation to ensure users understand the security implications.

Future Security Enhancements

Potential future improvements:

  1. Add option to copy secrets to clipboard instead of displaying
  2. Add secret masking option (show partial values only)
  3. Add output encryption for secret values
  4. Implement secret verification post-rotation
  5. Add webhook support for secret distribution (avoid manual viewing)

There aren’t any published security advisories