lumina/SECURITY_FIX.md
2025-11-30 04:03:12 +03:00

117 lines
3.3 KiB
Markdown

# ⚠️ CRITICAL SECURITY ISSUE - EXPOSED CREDENTIALS
## What Was Found
Your API keys and database credentials were committed to git history:
1. **OpenRouter API Key**: `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`
2. **MongoDB Credentials**:
- Username: `subasiarhan3_db_user`
- Password: `ETKnWiMmraGFX5P`
- Database: `lumina.vcg0rkz.mongodb.net`
## What Has Been Fixed
✅ **Updated .gitignore files** to exclude `.env` files:
- Created root `.gitignore`
- Updated `ui/.gitignore`
- Updated `api/.gitignore`
✅ **Removed .env files from git tracking** (files still exist locally)
## ⚠️ IMMEDIATE ACTION REQUIRED
### 1. Rotate All Exposed Credentials
**OpenRouter API Key:**
- Go to https://openrouter.ai/keys
- Revoke/delete the exposed key: `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`
- Create a new API key
- Update your local `.env` files with the new key
**MongoDB Credentials:**
- Go to MongoDB Atlas dashboard
- Change the password for user `subasiarhan3_db_user`
- Update your local `.env` files with the new password
### 2. Remove Credentials from Git History
If this repository is public or shared, you need to remove the credentials from git history:
**Option A: Using git filter-repo (Recommended)**
```bash
# Install git-filter-repo if needed
pip install git-filter-repo
# Remove the API key from history
git filter-repo --invert-paths --path api/.env --path ui/.env
# Force push (WARNING: This rewrites history)
git push origin --force --all
```
**Option B: Using BFG Repo-Cleaner**
```bash
# Download BFG from https://rtyley.github.io/bfg-repo-cleaner/
# Create a file with secrets to remove
echo "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" > secrets.txt
echo "ETKnWiMmraGFX5P" >> secrets.txt
# Run BFG
java -jar bfg.jar --replace-text secrets.txt
# Clean up
git reflog expire --expire=now --all
git gc --prune=now --aggressive
```
**Option C: If repository is new/not shared**
```bash
# Nuclear option: Start fresh (only if no one else has cloned)
rm -rf .git
git init
git add .
git commit -m "Initial commit (credentials removed)"
```
### 3. Verify .env Files Are Ignored
```bash
# Check that .env files are ignored
git status | grep .env
# Should show nothing (or only .env.example files)
# Verify .env files exist locally but are ignored
ls -la ui/.env api/.env
# Files should exist locally
```
### 4. Update .env Files with New Credentials
After rotating credentials, update:
- `ui/.env` - Add new `REACT_APP_OPENROUTER_API_KEY`
- `api/.env` - Add new `OPENROUTER_API_KEY` and MongoDB credentials
### 5. Check for Other Exposed Secrets
```bash
# Search for other potential secrets in git history
git log --all --full-history -p | grep -i "password\|secret\|key\|token" | grep -v "example\|placeholder\|your-"
```
## Prevention
✅ `.env` files are now in `.gitignore`
✅ Always use `.env.example` files for templates
✅ Never commit actual credentials
✅ Use environment variables or secret management services in production
## Next Steps
1. **IMMEDIATELY** rotate the OpenRouter API key
2. **IMMEDIATELY** change MongoDB password
3. Remove credentials from git history if repository is shared
4. Update local `.env` files with new credentials
5. Verify `.env` files are not tracked: `git status`