開發階段的弱點與漏洞分析
是什麼?
Important
在 Clause 8 的持續性弱點管理之外,Clause 10.4.4 要求在開發階段主動發現可能的 weakness / vulnerability。
「事前發現」比「事後修補」便宜。
與 Clause 8 的差異
| 比較 | Clause 8 | Clause 10.4.4 |
|---|---|---|
| 時機 | 全生命週期持續 | 開發階段主動 |
| 觸發 | 外部情報 / 監控 | 開發活動本身 |
| 對象 | 已 Release 產品 | 開發中的產品 |
| 工具 | CVE、CERT、ISAC | SAST、Code Review、Threat Modeling |
Tip
兩者互補——10.4.4 在 Release 前發現,Clause 8 在 Release 後持續監控。
開發階段弱點來源
1. Code Quality(程式碼缺陷)
├── Memory safety (buffer overflow, use-after-free)
├── Concurrency (race conditions)
├── Crypto misuse
├── Input validation
└── Error handling
2. Design Flaws(設計缺陷)
├── 缺少 Trust Boundary 驗證
├── 不安全的預設值
├── 過度權限
└── 通訊未加密
3. Configuration(配置缺陷)
├── Default credentials
├── Debug mode 留下
├── 不必要功能未關閉
└── 過度寬鬆權限
4. Dependency(依賴缺陷)
├── OTS 元件已知 CVE
├── 過時版本
└── 不安全的呼叫方式
分析方法
1. Threat Modeling Review
針對設計(在實作前):
- STRIDE per element
- 攻擊樹更新
- 對應新的 Threat Scenario
2. Static Application Security Testing (SAST)
# Coverity 範例
cov-analyze --dir /path/to/build \
--security \
--enable-cwe \
--misra-c-2012
cov-format-errors --html-output /path/to/report
針對程式碼,自動偵測:
- Buffer overflows (CWE-119)
- SQL injection (CWE-89)
- Crypto issues (CWE-310)
- Use-after-free (CWE-416)
- Race conditions (CWE-362)
- Etc.
3. Software Composition Analysis (SCA)
針對依賴:
- SBOM 對照 CVE 資料庫
- 授權合規
- 版本過時警告
工具:Black Duck、Snyk、OWASP Dependency-Check。
4. Code Review (Manual)
| 重點區域 | 為什麼 |
|---|---|
| 加密實作 | SAST 抓不到誤用 |
| 邊界檢查 | 邏輯錯誤 |
| 認證流程 | 設計層面 |
| 錯誤處理 | 資訊洩漏 |
| 預設值 | 工具難偵測 |
5. Dynamic Analysis (DAST) / Fuzzing
對執行中的元件:
- Fuzz testing
- Memory error detection(如 AddressSanitizer、Valgrind)
- 異常輸入測試
Weakness → Vulnerability 判斷
偵測到 Weakness(如 buffer overflow)
↓
判斷可利用性:
├── 攻擊者可達?
├── 輸入可控?
├── 防護機制存在?
└── 影響範圍?
↓
若可利用 → Vulnerability
若不可利用 → Weakness(記錄但不必立即修)
Warning
不可立即修不代表永不修。後續環境變化可能讓 weakness 變成 vulnerability。
分析紀錄
weakness_analysis:
id: WA-2026-042
found_in: "Bootloader signature verification routine"
detection_method: "Code Review + SAST"
weakness:
cwe: "CWE-130 (Improper Handling of Length Parameter)"
description: "Length field from input used without validation"
exploitability_analysis:
attack_vector: "Local (via OTA injection)"
pre_conditions:
- "Attacker has compromised OTA delivery channel"
- "OTA signature verification first happens, but length parsed before"
feasibility: Medium
decision: "VULNERABILITY (will fix)"
severity: High
priority: P1
remediation:
- "Add bounds check before length usage"
- "Add fuzz test case"
- "Update unit test"
target_release: "FW v2.3.1"
與 TARA 的關係
Weakness Analysis 發現
↓
新的攻擊路徑 ?
↓
├── 是 → 更新 TARA
│ ├── 新增 Threat Scenario
│ ├── 更新 Attack Path
│ └── 重新評估 Risk
│
└── 否 → 補丁 + 記錄
└── 不需 TARA 大幅變動
CWE Top 25 與汽車
汽車軟體最常見的 CWE:
| CWE | 名稱 | 汽車相關性 |
|---|---|---|
| CWE-787 | Out-of-bounds Write | 通訊解析、parser |
| CWE-79 | XSS | Web Dashboard |
| CWE-89 | SQL Injection | OEM 後端 |
| CWE-20 | Improper Input Validation | CAN/Ethernet handler |
| CWE-125 | Out-of-bounds Read | 同上 |
| CWE-78 | OS Command Injection | OEM/Tier-1 後端 |
| CWE-416 | Use After Free | 記憶體管理 |
| CWE-22 | Path Traversal | OTA、log 系統 |
| CWE-352 | CSRF | Web 介面 |
| CWE-434 | Unrestricted File Upload | OTA、診斷 |
| CWE-862 | Missing Authorization | 診斷服務 |
| CWE-476 | NULL Pointer Dereference | C/C++ 常見 |
| CWE-287 | Improper Authentication | UDS Security Access |
| CWE-732 | Incorrect Permission | OS 配置 |
證照考點
高頻考點
- Weakness ≠ Vulnerability(再次強調)
- Clause 10.4.4 是開發階段主動分析
- 與 Clause 8 互補(事前 vs 事後)
- 方法:Threat Modeling、SAST、SCA、Code Review、DAST/Fuzz
- SBOM 是 SCA 基礎
- 重大發現可能觸發 TARA 更新
Related Notes
- 07-Product-Development/01-Design-Requirements
- 07-Product-Development/02-Integration-Verification
- 05-Continual-Cybersecurity/03-Vulnerability-Analysis
- 05-Continual-Cybersecurity/04-Vulnerability-Management