B16 · 資安(後端視角) 詳細 ROADMAP

計畫文件,不會被 Quartz 渲染。 回主 roadmap → backend/ROADMAP.md


章節目標

本章只放後端特有資安議題——SQL Injection / Command Injection / SSRF / Path Traversal / Deserialization 等後端端的攻擊面、OWASP Top 10 的後端視角、API 安全(CSRF / CORS / Rate Limit)、secret / key 管理。通用資安概念(red/blue team、SDLC)屬於 security/ 系列。


🌱 基本介紹

#主題SlugStage大綱
01後端資安獨特的威脅面01-backend-threat-surface🌱Server-side 特有攻擊 vs client-side;「你的後端是整個系統的最後一道防線」

❓ 為什麼需要

#主題SlugStage大綱
02為什麼「前端驗就好」是地雷02-why-client-side-validation-not-enough🌱任何 HTTP client 都能繞前端;Postman 直接打、自製 script、MITM proxy
03為什麼 Secret 不能進 git03-why-secrets-not-in-git🌱歷史記錄永遠存在、fork / clone 帶走、公開 repo 洩漏實際案例

🕰️ 演進

#主題SlugStage大綱
04OWASP Top 10 演進04-owasp-evolution🌱2013 / 2017 / 2021 / 2024 的變化;SSRF 進榜、XXE 下榜
05供應鏈攻擊興起05-supply-chain-attack🌱event-stream / ua-parser-js / SolarWinds / xz utils(2024);為什麼 lockfile 是防線

🧠 知識型

F16-A OWASP Top 10 後端視角

#主題SlugStage大綱
06OWASP Top 10(web security)⛔️ security/03-web-security🌿跨系列
07A01 Broken Access Control07-broken-access-control🌱IDOR、權限 bypass、後端 /admin 沒驗;跟 B10 授權連動
08A02 Cryptographic Failures08-crypto-failures🌱敏感資料沒加密、弱演算法(MD5 / SHA1 存密碼)、key 管理失敗
09A03 Injection09-injection🌱SQL / Command / LDAP / NoSQL injection;parameterized query 是標配
10A04 Insecure Design10-insecure-design🌱設計層面就錯(threat modeling 沒做)、跟 code-level 漏洞的差別
11A05 Security Misconfiguration11-misconfiguration🌱預設帳密、debug 模式開在 prod、過度寬鬆的 CORS
12A06 Vulnerable Components12-vulnerable-dependencies🌱舊版 package 有 CVE、自動掃描工具、patch 節奏
13A07 Auth Failures13-auth-failures🌱Session fixation、timing attack、enumeration;跟 B10 Auth 連動
14A08 Software & Data Integrity Failures14-integrity-failures🌱CI/CD supply chain、unsigned deserialization、updates without verification
15A09 Logging & Monitoring Failures15-logging-failures🌱沒 log auth 失敗、log 洩漏 PII、沒 alert
16A10 SSRF16-ssrf🌱後端幫前端抓 URL 的功能被利用打內網;metadata endpoint(169.254.169.254)風險

F16-B 後端特有攻擊

#主題SlugStage大綱
17SQL Injection 深入17-sqli-deep🌱各種變體(union / time-based / boolean blind)、ORM 不自動等於免疫
18Command Injection18-command-injection🌱os.system / subprocess.call / shell=True 坑、輸入轉義困難
19Path Traversal19-path-traversal🌱上傳檔案覆蓋、下載 /../../etc/passwd;白名單 vs 黑名單
20Deserialization 攻擊20-deserialization🌱Java / PHP / Python pickle;pickle.loads 是 RCE 等級危險
21XXE(XML External Entity)21-xxe🌱XML 解析器預設行為、讀檔 / SSRF / DoS

F16-C API 與 Web 安全

#主題SlugStage大綱
22CORS 深入22-cors-deep🌱Preflight / credential / origin 設計、常見誤解(* + credentials: include
23CSRF 後端防禦23-csrf-backend🌱SameSite cookie、CSRF token、double-submit;API-only 場景怎麼想
24Rate Limiting 作為資安工具24-rate-limit-security🌱防 brute force / DoS、帳號鎖定策略
25Idempotency 作為資安保護25-idempotency-security🌱避免重複扣款攻擊、replay 防護
25-2微服務資安全景⛔️ micro-service/50-microservice-security🌿跨系列
25-3API Gateway 資安⛔️ micro-service/51-api-gateway-security🌿跨系列

F16-D Secret 管理

#主題SlugStage大綱
26Secret 管理基礎⛔️ infra/09-secrets-config🌿跨系列
27Secret 憑證管理深入⛔️ infra/27-secrets-certificate-management🌿跨系列
28Vault / KMS / SOPS28-secret-tools🌱HashiCorp Vault / AWS KMS / Mozilla SOPS;dev 流程整合
29Key rotation 策略29-key-rotation🌱怎麼做 zero-downtime rotation、JWT key rotation

F16-E 依賴與供應鏈

#主題SlugStage大綱
30Dependency Scanning⛔️ infra/26-security-scanning🌿跨系列
31SBOM(Software Bill of Materials)31-sbom🌱為什麼需要、SPDX / CycloneDX、跟 CI 整合
32lockfile 是安全防線32-lockfile-security🌱package-lock.json / uv.lock / poetry.lock 的角色、pinned dependencies

F16-F 合規與 DDoS 防禦

#主題SlugStage大綱
33GDPR 後端實作33-gdpr-backend🌱Data subject rights(存取 / 刪除 / 可攜帶)、consent management、data retention、跟 B03 Multi-tenancy 連動
34SOC 2 / ISO 27001 後端34-soc2-iso27001🌱Audit trail、access control、encryption at rest/in transit、跟 B07 audit log + B17 observability 配合
35HIPAA / PCI-DSS 後端35-hipaa-pci🌱醫療 / 金流特殊要求;PHI / cardholder data 處理;tokenization;scope reduction 策略
36DDoS 防禦分層36-ddos-defense-layers🌱Layer 3/4(volumetric)vs Layer 7(application)攻擊;CloudFlare / AWS Shield / Akamai;app 層配合(rate limit / CAPTCHA)
37Audit Trail 合規設計37-audit-trail-compliance🌱不可竄改 log(append-only)、保留期限、事件覆蓋範圍;跟 B07 #30 audit service 擴充

🔧 小實作注意事項

#主題SlugStage大綱
38Security Headers 中介層38-security-headers-middleware🌱proto middleware/security_headers.py 案例
39Threat Modeling 實戰39-threat-modeling🌱STRIDE 方法、Data Flow Diagram、何時該做

💣 Anti-pattern

#主題SlugStage大綱
40後端資安 Anti-patterns40-backend-security-antipatterns🌱SQL 字串拼接、密碼 MD5、JWT expiration 無限、只信任 X-Forwarded-For、用 eval / exec、CORS *、log 印 password、secret 寫死在 code

🧰 對應檢查工具

#主題SlugStage大綱
41後端資安工具41-backend-security-tooling🌱SAST(Semgrep / CodeQL)、DAST(OWASP ZAP)、SCA(Snyk / Socket / Dependabot)、secret scanning(TruffleHog / gitleaks)

📎 補充

#主題SlugStage大綱
S01Prompt Injection(AI 後端時代)s01-prompt-injection🌱LLM 輸出被注入、跟傳統 injection 的差別、defense-in-depth
S02Red / Blue Team 後端視角⛔️ security/02-red-blue-team🌿跨系列
S03SDLC 後端實踐⛔️ security/04-secure-development-lifecycle🌿跨系列

章節進度統計

  • 知識主題:36 + 3 補充 = 39 項
  • 🌿 growing:5(跨系列)
  • 🌱 seed:34

跨系列連結

  • security/ 系列(1–4,通用資安)
  • infra/09、26、27、30-application-security
  • backend/auth/ B10(auth 本身就是資安)
  • backend/api-design/ B09(rate limit / idempotency)
  • backend/conventions/ B07 #24 security headers middleware
  • standards/(好的 infra / CI/CD 含資安檢查)