Skip to content

chore(config): add secret detection and security validation for config files #30

@kriscoleman

Description

@kriscoleman

While the current config design correctly uses api_key_env to store environment variable names (not actual keys), there's no runtime validation to catch accidental secret leakage. A user could unknowingly paste an actual API key into a template variable or config field.

Add a validation layer that detects potential secrets in config values and warns users before saving.

Acceptance Criteria

  • Add a ValidateConfig() function to pkg/config/ that scans all string values in the config for patterns that look like secrets:
    • sk- prefix (OpenAI/Anthropic API keys)
    • ghp_ prefix (GitHub personal access tokens)
    • gho_, ghu_, ghs_ prefixes (GitHub OAuth/user/server tokens)
    • xoxb-, xoxp- prefixes (Slack tokens)
    • Long base64-like strings (>40 chars, high entropy)
  • Run validation during config.SaveConfig() -- warn the user before writing if potential secrets are detected
  • Run validation during ailloy customize interactive mode -- warn immediately when a suspicious value is entered
  • Warnings are non-blocking (user can proceed) but clearly explain the risk
  • Add unit tests for secret pattern detection with true/false positive cases
  • Audit existing config paths to confirm api_key_env is never used to store actual key values

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions