Lesson Learned #124: Secret Exposure Incident - Jan 9, 2026
Incident Summary
Date: January 9, 2026
Severity: P0 - Critical Security Incident
Detection: GitGuardian automated secret scanning
Commit: 53d5b99 (PR #1343)
What Happened
Claude (CTO) committed a shell script scripts/fix_paper_trading.sh that contained hardcoded Alpaca API credentials:
-
ALPACA_API_KEY(paper trading) -
ALPACA_SECRET_KEY(paper trading)
The script was created to help debug paper trading issues but violated fundamental security practices.
Root Cause Analysis
- Time pressure: Trying to quickly help CEO debug trading issues
- Poor judgment: Thought "it's just paper trading credentials" (WRONG - all credentials are sensitive)
- No pre-commit scanning: No local secret detection before commit
- Rushed PR: Did not review the diff carefully before merging
Impact
- API credentials exposed in public GitHub repository
- Credentials remain in git history even after file deletion
- Required immediate credential rotation
Remediation Steps
- [x] Delete the file from repository
- [ ] Rotate Alpaca API credentials
- [ ] Update GitHub secrets with new credentials
- [x] Document lesson learned
- [ ] Consider BFG Repo-Cleaner to scrub git history
Prevention Measures
- NEVER hardcode credentials - Use environment variables, .env files (gitignored), or secret managers
- Add pre-commit hooks - Implement git-secrets or detect-secrets pre-commit hook
-
Review all diffs - Before committing, always
git diffand look for sensitive data - GitGuardian integration - Ensure GitGuardian alerts are acted upon immediately
Pre-commit Hook Configuration (TODO)
# Install git-secrets
brew install git-secrets
# Configure for this repo
git secrets --install
git secrets --register-aws # Catches AWS patterns
git secrets --add 'ALPACA_.*KEY.*=.*[A-Za-z0-9]+' # Custom Alpaca pattern
CEO Directive
All future scripts that need credentials MUST:
- Read from environment variables
- Have a
.env.examplefile showing required variables (no actual values) - Be reviewed for secrets before commit
Related Lessons
- ll_009: CI syntax failure incident
- ll_118: Data integrity lies
- ll_119: False PR merge claims
Tags
security, secrets, alpaca, gitguardian, p0-incident
This lesson was auto-published from our AI Trading repository.
More lessons: rag_knowledge/lessons_learned
Top comments (0)