NEVER commit any of the following to version control, even if commented out:
- API keys (Gemini, Google Cloud, etc.)
- Service account private keys
- OAuth tokens
- Database passwords
- Any form of authentication credentials
All sensitive credentials MUST be stored using Google Apps Script's Properties Service:
// Correct way - using SecureConfig
const apiKey = SecureConfig.getGeminiAPIKey();
// WRONG - Never hardcode credentials
const apiKey = 'AIzaSy...' // NEVER DO THIS- Run
SecureConfig.initialize()from the Apps Script editor - Enter credentials when prompted
- Credentials are securely stored in Script Properties
- Never create files like Variables.js, secrets.js, or config.secret.js
Immediate Actions Required:
-
Revoke the compromised credential immediately
- Go to the service provider's console
- Revoke or delete the exposed key
- Generate a new key
-
Remove from repository
# Delete the file git rm <filename> git commit -m "Remove exposed credential"
-
Clean git history (coordinate with team)
# Install BFG Repo-Cleaner java -jar bfg.jar --delete-files <filename> # Or use git filter-branch git filter-branch --force --index-filter \ "git rm --cached --ignore-unmatch <filename>" \ --prune-empty --tag-name-filter cat -- --all # Force push (CAUTION: This rewrites history) git push --force --all git push --force --tags
-
Update credentials
- Generate new API key/credential
- Update SecureConfig with new credential
- Test to ensure everything works
- Review changed files for credentials
- Check for hardcoded API keys, even in comments
- Ensure .gitignore is properly configured
- Use
git diffto review changes
Always apply restrictions to API keys:
- IP restrictions: Limit to known IPs when possible
- API restrictions: Only enable required APIs
- Referrer restrictions: For browser keys
- Application restrictions: For mobile/server keys
Monthly tasks:
- Review Google Cloud Console for unusual activity
- Check billing for unexpected charges
- Rotate API keys if feasible
- Review access logs
Quarterly tasks:
- Full credential rotation
- Review and update security policies
- Check for exposed credentials on GitHub
Use these tools to scan for exposed credentials:
-
git-secrets - Prevents committing secrets
git secrets --install git secrets --register-aws # or other providers -
truffleHog - Scans git history for secrets
trufflehog git https://github.com/your-repo
-
GitHub Secret Scanning - Automatic detection (for public repos)
If credentials are exposed:
- Assess - Determine what was exposed and potential impact
- Revoke - Immediately revoke compromised credentials
- Replace - Generate and deploy new credentials
- Review - Check logs for any unauthorized usage
- Report - Notify team and affected parties if necessary
- Learn - Update processes to prevent recurrence
For security concerns or incidents:
- Project Owner: [Your Contact]
- Security Team: [Security Contact]
- Google Cloud Support: https://cloud.google.com/support
Last Updated: September 30, 2025 Version: 1.0