Vu Minh Chien commited on
Commit
bcff5f9
·
1 Parent(s): 6687395

Add security incident response guide for Firebase key exposure

Browse files
Files changed (1) hide show
  1. SECURITY-INCIDENT-RESPONSE.md +115 -0
SECURITY-INCIDENT-RESPONSE.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🚨 SECURITY INCIDENT RESPONSE - Firebase Service Account Key Exposed
2
+
3
+ ## ❗ TRẠNG THÁI HIỆN TẠI
4
+ - ✅ **File đã được xóa khỏi Git history**
5
+ - ✅ **Force push completed** - History đã clean
6
+ - ✅ **File added to .gitignore** - Tránh upload lại
7
+ - ❌ **Firebase Service Account Key vẫn ACTIVE** - CẦN ROTATE NGAY!
8
+
9
+ ## 🔄 BƯỚC TIẾP THEO QUAN TRỌNG
10
+
11
+ ### 1. **ROTATE Firebase Service Account Key (KHẨN CẤP)**
12
+
13
+ #### Bước 1: Vào Firebase Console
14
+ 1. Truy cập: https://console.firebase.google.com/
15
+ 2. Chọn project của bạn
16
+ 3. Vào **Project Settings** ⚙️
17
+ 4. Tab **Service Accounts**
18
+
19
+ #### Bước 2: Tạo Service Account Key mới
20
+ 1. Click **Generate new private key**
21
+ 2. Confirm tạo key mới
22
+ 3. **Download file JSON** - Lưu an toàn
23
+ 4. **QUAN TRỌNG**: Không upload lên Git!
24
+
25
+ #### Bước 3: Xóa Service Account Key cũ
26
+ 1. Trong Firebase Console
27
+ 2. Vào **IAM & Admin** → **Service Accounts**
28
+ 3. Tìm service account cũ
29
+ 4. **Delete** hoặc **Disable** key cũ
30
+
31
+ ### 2. **Cấu hình Hugging Face Spaces Secret**
32
+
33
+ #### Bước 1: Vào Space Settings
34
+ 1. Truy cập: https://huggingface.co/spaces/Detomo/houzou-notification-server
35
+ 2. Click **Settings** tab
36
+ 3. Chọn **Secrets and variables**
37
+
38
+ #### Bước 2: Thêm/Cập nhật Secret
39
+ 1. **Nếu chưa có**: Click **Add secret**
40
+ 2. **Nếu đã có**: Click **Edit** secret hiện tại
41
+ 3. **Name**: `FIREBASE_SERVICE_ACCOUNT`
42
+ 4. **Value**: Copy toàn bộ content của file JSON mới
43
+ 5. **Save**
44
+
45
+ #### Bước 3: Restart Space
46
+ 1. Vào **Settings** → **Restart Space**
47
+ 2. Hoặc push một commit mới để trigger rebuild
48
+
49
+ ### 3. **Kiểm tra hoạt động**
50
+
51
+ ```bash
52
+ # Test server
53
+ curl https://detomo-houzou-notification-server.hf.space/
54
+
55
+ # Test Firebase connectivity
56
+ curl https://detomo-houzou-notification-server.hf.space/test-firebase
57
+
58
+ # Expected response:
59
+ {
60
+ "success": true,
61
+ "message": "Firebase connectivity OK",
62
+ "projectId": "your-project-id"
63
+ }
64
+ ```
65
+
66
+ ## 📋 CHECKLIST BẢO MẬT
67
+
68
+ ### ✅ Đã hoàn thành:
69
+ - [x] Xóa file khỏi Git history
70
+ - [x] Force push remote repository
71
+ - [x] Thêm vào .gitignore
72
+ - [x] Xóa file local
73
+
74
+ ### ❌ Cần làm NGAY:
75
+ - [ ] **Rotate Firebase Service Account Key**
76
+ - [ ] **Cập nhật secret trong Hugging Face Space**
77
+ - [ ] **Test Firebase connectivity**
78
+ - [ ] **Verify notifications vẫn hoạt động**
79
+
80
+ ## 🔐 PHÒNG CHỐNG TƯƠNG LAI
81
+
82
+ ### 1. **Không bao giờ commit sensitive files**
83
+ ```bash
84
+ # Kiểm tra trước khi commit
85
+ git status
86
+ git diff --cached
87
+
88
+ # Nếu có file không mong muốn:
89
+ git reset HEAD firebase-service-account.json
90
+ ```
91
+
92
+ ### 2. **Sử dụng environment variables**
93
+ ```bash
94
+ # Development
95
+ export FIREBASE_SERVICE_ACCOUNT="$(cat firebase-service-account.json)"
96
+
97
+ # Production
98
+ # Set trong Hugging Face Spaces Secrets
99
+ ```
100
+
101
+ ### 3. **Regular security audit**
102
+ - Kiểm tra Git history định kỳ
103
+ - Review permissions của service accounts
104
+ - Monitor Firebase console cho unusual activity
105
+
106
+ ## 🆘 LIÊN HỆ HỖ TRỢ
107
+
108
+ Nếu gặp vấn đề:
109
+ 1. **Firebase Support**: https://firebase.google.com/support
110
+ 2. **Hugging Face Support**: https://huggingface.co/support
111
+ 3. **Security team**: Báo cáo incident nếu cần
112
+
113
+ ---
114
+
115
+ **⚠️ QUAN TRỌNG**: Thực hiện rotate key NGAY LẬP TỨC để đảm bảo bảo mật!