SEC-013 P2: SSL Pinning 在 DEBUG 中禁用安全檢查

Resolved 💬 2 comments Opened Mar 22, 2026 by stephen-taipei Closed Mar 25, 2026

問題描述

DEBUG 構建在 localhost 和 .local 域名上允許繞過 SSL pinning,若開發者設備被攻擊,HTTPS 流量可被攔截。

檔案位置

ios-swift/Connectors/Services/SSLPinningDelegate.swift:74-81

詳細說明

#if DEBUG
if allowInsecureInDevelopment {
    if host == \"localhost\" || host == \"127.0.0.1\" || host.hasSuffix(\".local\") {
        completionHandler(.useCredential, URLCredential(trust: serverTrust))
        return  // 跳過 pinning 驗證
    }
}
#endif

風險評估

  • 開發者設備的 HTTPS 流量可被中間人代理攔截
  • 敏感數據(token、使用者資訊)可被竊取
  • 開發構建可能意外在生產環境使用

解決方案

  1. 改用特定的測試憑證而非禁用 pinning
  2. 提供開發者安全的本地 CA 簽名憑證
  3. 在 Release build 中強制啟用 pinning
  4. 不允許 DEBUG 構建連線到實際生產 API

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗