Summary
Add detection for AWS ARN (Amazon Resource Name) patterns to prevent accidental exposure of AWS resource identifiers in commits.
Background
This is a long-standing request from Issue #68 (opened April 2022). AWS ARNs can reveal:
- AWS account IDs (12-digit identifiers)
- Region information
- Resource naming patterns
- Service usage details
While ARNs don't directly expose credentials, they provide valuable reconnaissance information for attackers.
Impact Analysis
Scanned local cloud.gov repositories for existing ARN patterns:
| Repository |
ARN Matches |
Notes |
| caulking |
0 |
Clean |
| pre-commit-templates |
0 |
Clean |
| style-management-service |
0 |
Clean |
| cg-scripts |
2 |
Both use ${ACCOUNT_ID} variables, not hardcoded |
Finding: Very low false positive risk. Existing ARNs use variable interpolation.
Proposed Implementation
Detection Pattern
arn:aws(-us-gov|-cn)?:[^:]+:[^:]*:[0-9]{12}:[^:\s]+
Key constraint: Only flag ARNs with literal 12-digit account IDs.
Allowlist Patterns
ARNs using variable interpolation should be allowed:
arn:aws:iam::${ACCOUNT_ID}:role/ServiceRole
arn:aws-us-gov:es:${REGION}:${ACCOUNT_ID}:domain/${TAG}
Configuration
Add to ~/.config/gitleaks/config.toml:
[[rules]]
id = "aws-arn-with-account-id"
description = "AWS ARN with hardcoded account ID"
regex = '''arn:aws(-us-gov|-cn)?:[^:]+:[^:]*:[0-9]{12}:[^:\s]+'''
keywords = ["arn:aws"]
[rules.allowlist]
regexes = [
'''\$\{.*ACCOUNT.*\}''', # Variable interpolation
'''arn:aws[^:]*:[^:]+:[^:]*:\*:''', # Wildcard account
]
Implementation Phases
- Phase 1: Add rule as
warning level (non-blocking)
- Phase 2: Monitor false positive rate across cloud.gov repos
- Phase 3: Promote to blocking if FP rate acceptable
Acceptance Criteria
Security Considerations
- ARN exposure risk: Medium (reconnaissance value)
- False positive risk: Low (impact analysis shows minimal existing usage)
- Recommended level:
warning initially
References
Labels
Co-authored-by: OpenCode Agent agent@gsa.gov
Summary
Add detection for AWS ARN (Amazon Resource Name) patterns to prevent accidental exposure of AWS resource identifiers in commits.
Background
This is a long-standing request from Issue #68 (opened April 2022). AWS ARNs can reveal:
While ARNs don't directly expose credentials, they provide valuable reconnaissance information for attackers.
Impact Analysis
Scanned local cloud.gov repositories for existing ARN patterns:
${ACCOUNT_ID}variables, not hardcodedFinding: Very low false positive risk. Existing ARNs use variable interpolation.
Proposed Implementation
Detection Pattern
Key constraint: Only flag ARNs with literal 12-digit account IDs.
Allowlist Patterns
ARNs using variable interpolation should be allowed:
arn:aws:iam::${ACCOUNT_ID}:role/ServiceRolearn:aws-us-gov:es:${REGION}:${ACCOUNT_ID}:domain/${TAG}Configuration
Add to
~/.config/gitleaks/config.toml:Implementation Phases
warninglevel (non-blocking)Acceptance Criteria
aws-us-gov)docs/blocked-files.mdSecurity Considerations
warninginitiallyReferences
Labels
Co-authored-by: OpenCode Agent agent@gsa.gov