Your config.env file with real credentials may already be in your Git history. To remove it:
# Remove config.env from Git history (BE CAREFUL - this rewrites history)
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch config.env" \
--prune-empty --tag-name-filter cat -- --all
# Or use BFG Repo-Cleaner (faster and safer):
# 1. Download BFG from https://rtyley.github.io/bfg-repo-cleaner/
# 2. Run: java -jar bfg.jar --delete-files config.env
# 3. Run: git reflog expire --expire=now --all && git gc --prune=now --aggressiveconfig.env:
- MongoDB Password: Change
mongoindex55on MongoDB Atlas- Go to: Database Access β Edit User β Change Password
- Email Password: Change or rotate
Morocontact55*- For Gmail: Generate a new App Password
- Settings β Security β 2-Step Verification β App passwords
- JWT Secret: Generate a new random secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
After changing credentials:
- Copy
.env.exampletoconfig.env - Fill in your NEW credentials
- Test your application
- NEVER commit
config.envagain
# Check if config.env is ignored
git status
# config.env should NOT appear in untracked files
# Force remove if still tracked
git rm --cached config.env
git commit -m "Remove config.env from tracking"- β
Use
.env.exampleas a template - β
Keep
config.envin.gitignore - β Use different credentials for dev/staging/production
- β Rotate secrets regularly (every 90 days)
- β Use strong, unique passwords (32+ characters)
- β Use password managers
- β Enable 2FA on all services
- β Never hardcode credentials in code
- β Use IP whitelist on MongoDB Atlas
- β Create separate users for dev/prod
- β Use least privilege principle
- β Enable audit logs
- β Use long, random JWT secrets
- β Set appropriate expiration times
- β Use HTTPS in production
- β Store tokens securely (httpOnly cookies)
- Remove all hardcoded credentials
- Verify
.gitignoreis working - Check Git history for sensitive data
- Change all exposed passwords
- Use environment variables
- Enable rate limiting (β Already implemented)
- Use HTTPS in production
- Set up proper CORS (β Already implemented)
- Keep dependencies updated
- Enable security headers (β Already implemented with Helmet)
If you've already pushed to GitHub:
- Delete the repository on GitHub
- Clean your local Git history (see above)
- Change ALL passwords
- Create a new repository
- Push cleaned code
If you discover a security vulnerability, please email: your-security-email@example.com
Last Updated: January 31, 2026