SEC-006 P1: Telegram Auth 狀態儲存於 UserDefaults
Resolved 💬 2 comments Opened Mar 22, 2026 by stephen-taipei Closed Mar 25, 2026
問題描述
TelegramAuthService 的 checkExistingCredentials() 從 UserDefaults 讀取使用者身份資訊(userId, userName, avatar, username)。使用者身份洩漏可能導致帳戶盜用。
檔案位置
ios-swift/Connectors/Services/SocialAuth/TelegramAuthService.swift:233-243
詳細說明
private func checkExistingCredentials() {
if let userId = UserDefaults.standard.string(forKey: userIdKey) {
currentUser = SocialAuthResult(
userId: userId,
name: UserDefaults.standard.string(forKey: userNameKey),
avatarURL: UserDefaults.standard.string(forKey: userAvatarKey),
rawData: ["username": UserDefaults.standard.string(forKey: usernameKey)]
)
}
}
風險評估
- 使用者身份資訊未加密存儲
- 認證過期時間戳未安全存儲
- 可能被其他應用程式或備份工具訪問
解決方案
- 所有 Telegram auth 狀態遷移至 Keychain
- 移除不必要的個人資訊快取
- 定期自動清除過期認證資料(24 小時)
- 認證過期後強制重新登入
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗