Secret Masking Configuration
Atmos provides provably safe secrets maskingβall output channels route through the masking layer to ensure secrets never leak through any path. Sensitive data (secrets, API keys, tokens) is automatically masked in all terminal output to prevent accidental exposure in logs, screenshots, or CI/CD pipelines.
Overviewβ
Secret masking operates at the I/O layer, intercepting all output before it reaches stdout/stderr. This ensures secrets are masked regardless of:
- Output format (plain text, JSON, YAML)
- Output destination (terminal, file, pipe)
- Command type (terraform, helmfile, custom commands)
Quick Startβ
Enable Masking (Default)β
Masking is enabled by default with 8 built-in patterns for common secrets:
# atmos.yaml
settings:
terminal:
mask:
enabled: true # Default: true
Disable Masking for Debuggingβ
Use the CLI flag to disable masking temporarily:
atmos terraform plan --mask=false
Configurationβ
Full Configuration Exampleβ
# atmos.yaml
settings:
terminal:
mask:
enabled: true # Enable/disable masking (default: true)
replacement: "[REDACTED]" # Custom replacement text (default: ***MASKED***)
patterns: # Custom regex patterns
- 'demo-key-[A-Za-z0-9]{16}'
- 'internal-[a-f0-9]{32}'
- 'tkn_(live|test)_[a-zA-Z0-9]{24}'
literals: # Exact string matches
- "super-secret-demo-value"
- "my-api-key-12345"
Configuration Optionsβ
enabledEnable or disable secret masking globally.
- Type: boolean
- Default:
true - Example:
enabled: false
replacementText to replace masked secrets with.
- Type: string
- Default:
"***MASKED***" - Example:
replacement: "[REDACTED]"
patternsCustom regex patterns to match organization-specific secrets. Patterns are added to the built-in patterns, not replacing them.
- Type: array of strings
- Default:
[] - Example:
patterns:
- 'mycompany-key-[A-Za-z0-9]{16}'
- 'internal-[a-f0-9]{32}'
literalsExact string values to mask. Use for known sensitive values that don't follow a pattern.
- Type: array of strings
- Default:
[] - Example:
literals:
- "my-hardcoded-secret"
- "test-api-key-12345"
Custom Patternsβ
Beyond the built-in patterns, you can define organization-specific patterns to mask internal tokens, API keys, or secrets that follow your naming conventions.
Regex Patternsβ
Use the patterns option to define regex patterns:
settings:
terminal:
mask:
patterns:
# Internal API tokens
- 'mycompany-api-[A-Za-z0-9]{32}'
# Service account keys
- 'svc_[a-z]+_[A-Za-z0-9]{24}'
# Custom JWT-like tokens
- 'tkn_(live|test)_[a-zA-Z0-9]{24}'
Literal Valuesβ
Use the literals option for exact string matches:
settings:
terminal:
mask:
literals:
- "known-secret-value"
- "hardcoded-test-key"
This is useful for:
- Test secrets that don't follow patterns
- Known sensitive values from configuration
- Legacy credentials with unusual formats
Built-In Patternsβ
Atmos includes 8 built-in patterns for common secret formats:
-
GitHub Personal Access Tokens
- Classic format:
ghp_[A-Za-z0-9]{36} - OAuth format:
gho_[A-Za-z0-9]{36} - New format:
github_pat_[A-Za-z0-9]{22}_[A-Za-z0-9]{59}
- Classic format:
-
GitLab Personal Access Tokens
- Format:
glpat-[A-Za-z0-9\-_]{20}
- Format:
-
OpenAI API Keys
- Format:
sk-[A-Za-z0-9]{48}
- Format:
-
AWS Access Key ID
- Format:
AKIA[0-9A-Z]{16}
- Format:
-
AWS Secret Access Key
- Format: 40-character base64 string
-
Bearer Tokens
- Format:
Bearer [A-Za-z0-9\-._~+/]+=*
- Format:
Auto-Masked Environment Variablesβ
The following environment variables are automatically detected and masked:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_SESSION_TOKENGITHUB_TOKENGH_TOKENGITLAB_TOKENCI_JOB_TOKENDATADOG_API_KEYDD_API_KEYANTHROPIC_API_KEY
CLI Flagsβ
--maskβ
Enable or disable masking for a single command:
# Disable masking for debugging
atmos terraform plan --mask=false
# Explicitly enable masking (default)
atmos terraform plan --mask=true
How It Worksβ
Masking Flowβ
- Initialization - Atmos loads masking configuration on startup
- Pattern Registration - Built-in patterns and env var values are registered
- Output Interception - All output goes through the masking engine
- Secret Detection - Regex patterns and literal values are matched
- Replacement - Matched secrets are replaced with
***MASKED***
Format-Aware Maskingβ
Secrets are detected in multiple formats:
- Plain text:
sk-abc123def456 - JSON:
{"api_key": "sk-abc123def456"} - YAML:
api_key: sk-abc123def456 - URL-encoded:
key=sk%2Dabc123def456 - Base64:
c2stYWJjMTIzZGVmNDU2 - Hex:
736b2d616263313233646566343536
Performanceβ
Masking has minimal performance impact:
- Initialization: <50ms
- Per-operation: <3ΞΌs (no secrets), <16ΞΌs (with secrets)
- Memory: ~100KB for pattern storage
Use Casesβ
Production Deploymentsβ
Prevent secrets from appearing in CI/CD logs:
# atmos.yaml
settings:
terminal:
mask:
enabled: true
# Run deployment - secrets automatically masked
atmos terraform apply
Local Developmentβ
Disable masking for debugging:
# See full output for troubleshooting
atmos terraform plan --mask=false
Screenshot Generationβ
Enable masking when generating documentation screenshots:
settings:
terminal:
mask:
enabled: true
# Generate screenshots with masked secrets
atmos terraform plan | screenshot-tool
Security Considerationsβ
What Gets Maskedβ
- AWS credentials (access keys, secret keys, session tokens)
- GitHub/GitLab tokens and PATs
- OpenAI API keys
- Bearer tokens
- Values from configured environment variables
What Does NOT Get Maskedβ
- Non-secret configuration values
- Resource names and identifiers
- Public URLs and endpoints
- Log messages and status text
False Positivesβ
If legitimate values are incorrectly masked:
-
Disable masking temporarily:
atmos terraform plan --mask=false -
Report pattern issue: Open an issue with the false positive pattern
False Negativesβ
If secrets are NOT being masked:
- Check pattern coverage: Built-in patterns may not cover your secret format
- Add custom patterns: Define patterns in
atmos.yamlfor organization-specific secrets - Use literals: Add exact values to the
literalsconfiguration - Contribute patterns: Consider contributing common patterns to Atmos
Troubleshootingβ
Secrets Not Being Maskedβ
Problem: Expected secrets appear in output.
Solutions:
-
Verify masking is enabled:
settings:
terminal:
mask:
enabled: true -
Check if secret format matches built-in patterns
-
Add custom patterns for organization-specific secrets:
settings:
terminal:
mask:
patterns:
- 'your-secret-pattern-[A-Za-z0-9]+'
literals:
- "known-secret-value" -
Check environment variables are set correctly
Legitimate Values Maskedβ
Problem: Non-secret values are being masked.
Solutions:
-
Temporarily disable masking for debugging:
atmos terraform plan --mask=false -
Report false positive pattern
Performance Issuesβ
Problem: Masking slows down output.
Solutions:
- Check for extremely large output (>10MB)
- Disable masking if performance is critical:
atmos terraform plan --mask=false
Exampleβ
See Alsoβ
- Terminal Configuration - Terminal settings and options