<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Supply-Chain on Tarragon</title><link>https://tarrragon.github.io/blog/tags/supply-chain/</link><description>Recent content in Supply-Chain on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Thu, 21 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/supply-chain/index.xml" rel="self" type="application/rss+xml"/><item><title>Model Supply-Chain Trust</title><link>https://tarrragon.github.io/blog/llm/knowledge-cards/model-supply-chain-trust/</link><pubDate>Thu, 14 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/llm/knowledge-cards/model-supply-chain-trust/</guid><description>&lt;p>Model supply-chain trust 的核心概念是「&lt;strong>把模型權重來源、量化者、registry 與本機檔案都視為信任邊界&lt;/strong>」。本地 LLM 下載的是可影響模型行為的 &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/gguf/" data-link-title="GGUF" data-link-desc="llama.cpp 生態定義的模型權重格式：把權重、tokenizer、metadata 打包成單一檔案">GGUF&lt;/a> 或其他權重檔，來源與完整性會直接影響安全與可靠性。&lt;/p>
&lt;h2 id="概念位置">概念位置&lt;/h2>
&lt;p>它位在模型層與安全治理交界，跟 &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card&lt;/a> 不同：model card 提供 metadata，supply-chain trust 判斷來源、hash、量化流程、namespace 與散發路徑是否可信。&lt;/p>
&lt;h2 id="可觀察訊號與例子">可觀察訊號與例子&lt;/h2>
&lt;p>官方 organization、知名量化者、verified registry、可比對 hash、清楚 license 與 model card 都提升信任；個人上傳、來源不明、檔案被替換、缺 metadata 都降低信任。GGUF、Safetensors、Ollama registry、Hugging Face Hub 都在這條鏈上。&lt;/p>
&lt;h2 id="設計責任">設計責任&lt;/h2>
&lt;p>下載模型前確認來源；下載後記錄 SHA-256、檔案大小與版本；第三方量化要看量化者信譽與社群採用。MCP server 與 plugin 是另一條可執行程式碼供應鏈，要用更高權限標準判讀。&lt;/p></description><content:encoded><![CDATA[<p>Model supply-chain trust 的核心概念是「<strong>把模型權重來源、量化者、registry 與本機檔案都視為信任邊界</strong>」。本地 LLM 下載的是可影響模型行為的 <a href="/blog/llm/knowledge-cards/gguf/" data-link-title="GGUF" data-link-desc="llama.cpp 生態定義的模型權重格式：把權重、tokenizer、metadata 打包成單一檔案">GGUF</a> 或其他權重檔，來源與完整性會直接影響安全與可靠性。</p>
<h2 id="概念位置">概念位置</h2>
<p>它位在模型層與安全治理交界，跟 <a href="/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card</a> 不同：model card 提供 metadata，supply-chain trust 判斷來源、hash、量化流程、namespace 與散發路徑是否可信。</p>
<h2 id="可觀察訊號與例子">可觀察訊號與例子</h2>
<p>官方 organization、知名量化者、verified registry、可比對 hash、清楚 license 與 model card 都提升信任；個人上傳、來源不明、檔案被替換、缺 metadata 都降低信任。GGUF、Safetensors、Ollama registry、Hugging Face Hub 都在這條鏈上。</p>
<h2 id="設計責任">設計責任</h2>
<p>下載模型前確認來源；下載後記錄 SHA-256、檔案大小與版本；第三方量化要看量化者信譽與社群採用。MCP server 與 plugin 是另一條可執行程式碼供應鏈，要用更高權限標準判讀。</p>
]]></content:encoded></item><item><title>6.0 模型供應鏈與信任邊界</title><link>https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/</guid><description>&lt;p>&lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/model-supply-chain-trust/" data-link-title="Model Supply-Chain Trust" data-link-desc="判斷模型權重、量化版本、registry 與本機檔案是否可信的供應鏈信任框架">模型供應鏈信任&lt;/a> 從本地 LLM 的最上游開始：模型權重本身就是第一個信任邊界。本章把「該不該裝這個模型」「裝下來的檔案有沒有被動過」「ollama pull / hf download 拉到的是不是作者發布的版本」這類問題、整理成可操作的判讀。判讀的主要資訊來源是 &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card&lt;/a>；通用 artifact 信任機制見 backend &lt;a href="https://tarrragon.github.io/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact-provenance&lt;/a> 卡片。本章 framing 是個人 dev 視角；production 部署的模型供應鏈見 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/llm-deployment-supply-chain/" data-link-title="LLM Deployment 供應鏈完整性" data-link-desc="把 LLM 模型權重、推論伺服器、第三方 plugin 三條 production 供應鏈納入既有 artifact trust 框架的判讀">backend/07 LLM Deployment 供應鏈&lt;/a>。&lt;/p>
&lt;p>讀完本章後、你應該能對自己用的模型回答：來源是不是作者本人 / 官方鏡像、檔案完整性怎麼驗、量化版本是不是社群常用的、第三方再上傳的版本該不該用。&lt;/p>
&lt;h2 id="本章目標">本章目標&lt;/h2>
&lt;ol>
&lt;li>認識本地 LLM 模型供應鏈的角色：原始作者 → 官方 release → 第三方量化 → registry 散發。&lt;/li>
&lt;li>知道個人 dev 場景的信任邊界跟驗證手段。&lt;/li>
&lt;li>區分「官方版本」、「社群熱門量化」、「個人上傳」三種來源的信任等級。&lt;/li>
&lt;li>用 GGUF 檔案完整性檢查（hash、檔案大小、metadata）建立基本驗證流程。&lt;/li>
&lt;li>認識 Ollama / Hugging Face / LM Studio model browser 的供應鏈差異。&lt;/li>
&lt;/ol>
&lt;h2 id="本地-llm-模型供應鏈的角色鏈">本地 LLM 模型供應鏈的角色鏈&lt;/h2>





&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="ln">1&lt;/span>&lt;span class="cl">原始作者（如 Meta、Google、Qwen 團隊）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">2&lt;/span>&lt;span class="cl"> ↓ 發布原始權重（safetensors / pt、通常 fp16 或 bf16）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">3&lt;/span>&lt;span class="cl">官方 Hugging Face organization
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">4&lt;/span>&lt;span class="cl"> ↓ 第三方量化者（如 bartowski、TheBloke、unsloth）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">5&lt;/span>&lt;span class="cl">量化版本 GGUF（Q4_K_M、Q5_K_M 等）
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">6&lt;/span>&lt;span class="cl"> ↓ Ollama 收進 registry 或社群上傳
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">7&lt;/span>&lt;span class="cl">Ollama registry / LM Studio 內建瀏覽器
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">8&lt;/span>&lt;span class="cl"> ↓ 使用者拉下來
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="ln">9&lt;/span>&lt;span class="cl">本機 GGUF 檔案&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>每一層都是潛在的信任邊界：&lt;/p>
&lt;ol>
&lt;li>&lt;strong>原始作者&lt;/strong>：信任假設是「作者發布的權重就是訓練出來的權重、沒被植入後門」。個人 dev 場景下、選主流作者（Meta、Google、Qwen、Mistral 等）的官方發布通常是合理起點。&lt;/li>
&lt;li>&lt;strong>量化者&lt;/strong>：把官方 fp16 權重壓成 Q4 / Q5 等 GGUF 格式的人。社群常見熱門量化者（如 bartowski、unsloth）有公開的量化腳本與長期信譽、但仍是個人或小團隊、不是企業簽章。&lt;/li>
&lt;li>&lt;strong>registry 散發&lt;/strong>：Ollama registry、HF Hub、LM Studio 內建瀏覽器是分發層。可能被搶 namespace、可能有人偽造「官方」名義上傳。&lt;/li>
&lt;li>&lt;strong>本機儲存&lt;/strong>：下載完的 GGUF 檔案在硬碟、後續執行時權重本身就是程式邏輯的一部分（透過 inference 影響輸出）。&lt;/li>
&lt;/ol>
&lt;blockquote>
&lt;p>&lt;strong>事實查核註&lt;/strong>：上面的角色鏈是 2026 年 5 月的常見運作模式。具體量化者、registry 政策、模型分發流程依平台變化、建議引用前以 Hugging Face、Ollama、LM Studio 各自的&lt;a href="https://huggingface.co/docs/hub/security">安全公告與 community guidelines&lt;/a> 為準。&lt;/p>&lt;/blockquote>
&lt;h2 id="三種來源的信任等級">三種來源的信任等級&lt;/h2>
&lt;p>個人 dev 場景下、常見的模型來源可以分成三個信任等級：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>來源類型&lt;/th>
 &lt;th>例子&lt;/th>
 &lt;th>信任等級&lt;/th>
 &lt;th>建議的驗證動作&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>官方作者發布&lt;/td>
 &lt;td>&lt;code>meta-llama/Llama-3.3-70B-Instruct&lt;/code>（HF）&lt;/td>
 &lt;td>較高&lt;/td>
 &lt;td>確認 org 是 verified、看 model card 引用&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>知名社群量化者&lt;/td>
 &lt;td>&lt;code>bartowski/Qwen3-30B-A3B-GGUF&lt;/code>（HF）&lt;/td>
 &lt;td>中等&lt;/td>
 &lt;td>看量化者過往作品、確認量化腳本是否公開&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>個人上傳 / 不明來源&lt;/td>
 &lt;td>隨意搜尋到的個人 repo、論壇下載的 GGUF&lt;/td>
 &lt;td>較低&lt;/td>
 &lt;td>個人 dev 場景下建議避開、無法確認權重來源跟修改&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>「中等」跟「較高」的差別主要在「企業簽章」這個維度——Hugging Face verified organization 對應「該組織確實是 Meta / Google / Qwen 等主體」、但不對「該組織內部 release process 是否安全」做擔保。即使是官方發布、仍是「人類團隊發布的權重」、不是密碼學意義的零信任。&lt;/p></description><content:encoded><![CDATA[<p><a href="/blog/llm/knowledge-cards/model-supply-chain-trust/" data-link-title="Model Supply-Chain Trust" data-link-desc="判斷模型權重、量化版本、registry 與本機檔案是否可信的供應鏈信任框架">模型供應鏈信任</a> 從本地 LLM 的最上游開始：模型權重本身就是第一個信任邊界。本章把「該不該裝這個模型」「裝下來的檔案有沒有被動過」「ollama pull / hf download 拉到的是不是作者發布的版本」這類問題、整理成可操作的判讀。判讀的主要資訊來源是 <a href="/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card</a>；通用 artifact 信任機制見 backend <a href="/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact-provenance</a> 卡片。本章 framing 是個人 dev 視角；production 部署的模型供應鏈見 <a href="/blog/backend/07-security-data-protection/llm-deployment-supply-chain/" data-link-title="LLM Deployment 供應鏈完整性" data-link-desc="把 LLM 模型權重、推論伺服器、第三方 plugin 三條 production 供應鏈納入既有 artifact trust 框架的判讀">backend/07 LLM Deployment 供應鏈</a>。</p>
<p>讀完本章後、你應該能對自己用的模型回答：來源是不是作者本人 / 官方鏡像、檔案完整性怎麼驗、量化版本是不是社群常用的、第三方再上傳的版本該不該用。</p>
<h2 id="本章目標">本章目標</h2>
<ol>
<li>認識本地 LLM 模型供應鏈的角色：原始作者 → 官方 release → 第三方量化 → registry 散發。</li>
<li>知道個人 dev 場景的信任邊界跟驗證手段。</li>
<li>區分「官方版本」、「社群熱門量化」、「個人上傳」三種來源的信任等級。</li>
<li>用 GGUF 檔案完整性檢查（hash、檔案大小、metadata）建立基本驗證流程。</li>
<li>認識 Ollama / Hugging Face / LM Studio model browser 的供應鏈差異。</li>
</ol>
<h2 id="本地-llm-模型供應鏈的角色鏈">本地 LLM 模型供應鏈的角色鏈</h2>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln">1</span><span class="cl">原始作者（如 Meta、Google、Qwen 團隊）
</span></span><span class="line"><span class="ln">2</span><span class="cl">  ↓ 發布原始權重（safetensors / pt、通常 fp16 或 bf16）
</span></span><span class="line"><span class="ln">3</span><span class="cl">官方 Hugging Face organization
</span></span><span class="line"><span class="ln">4</span><span class="cl">  ↓ 第三方量化者（如 bartowski、TheBloke、unsloth）
</span></span><span class="line"><span class="ln">5</span><span class="cl">量化版本 GGUF（Q4_K_M、Q5_K_M 等）
</span></span><span class="line"><span class="ln">6</span><span class="cl">  ↓ Ollama 收進 registry 或社群上傳
</span></span><span class="line"><span class="ln">7</span><span class="cl">Ollama registry / LM Studio 內建瀏覽器
</span></span><span class="line"><span class="ln">8</span><span class="cl">  ↓ 使用者拉下來
</span></span><span class="line"><span class="ln">9</span><span class="cl">本機 GGUF 檔案</span></span></code></pre></div><p>每一層都是潛在的信任邊界：</p>
<ol>
<li><strong>原始作者</strong>：信任假設是「作者發布的權重就是訓練出來的權重、沒被植入後門」。個人 dev 場景下、選主流作者（Meta、Google、Qwen、Mistral 等）的官方發布通常是合理起點。</li>
<li><strong>量化者</strong>：把官方 fp16 權重壓成 Q4 / Q5 等 GGUF 格式的人。社群常見熱門量化者（如 bartowski、unsloth）有公開的量化腳本與長期信譽、但仍是個人或小團隊、不是企業簽章。</li>
<li><strong>registry 散發</strong>：Ollama registry、HF Hub、LM Studio 內建瀏覽器是分發層。可能被搶 namespace、可能有人偽造「官方」名義上傳。</li>
<li><strong>本機儲存</strong>：下載完的 GGUF 檔案在硬碟、後續執行時權重本身就是程式邏輯的一部分（透過 inference 影響輸出）。</li>
</ol>
<blockquote>
<p><strong>事實查核註</strong>：上面的角色鏈是 2026 年 5 月的常見運作模式。具體量化者、registry 政策、模型分發流程依平台變化、建議引用前以 Hugging Face、Ollama、LM Studio 各自的<a href="https://huggingface.co/docs/hub/security">安全公告與 community guidelines</a> 為準。</p></blockquote>
<h2 id="三種來源的信任等級">三種來源的信任等級</h2>
<p>個人 dev 場景下、常見的模型來源可以分成三個信任等級：</p>
<table>
  <thead>
      <tr>
          <th>來源類型</th>
          <th>例子</th>
          <th>信任等級</th>
          <th>建議的驗證動作</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>官方作者發布</td>
          <td><code>meta-llama/Llama-3.3-70B-Instruct</code>（HF）</td>
          <td>較高</td>
          <td>確認 org 是 verified、看 model card 引用</td>
      </tr>
      <tr>
          <td>知名社群量化者</td>
          <td><code>bartowski/Qwen3-30B-A3B-GGUF</code>（HF）</td>
          <td>中等</td>
          <td>看量化者過往作品、確認量化腳本是否公開</td>
      </tr>
      <tr>
          <td>個人上傳 / 不明來源</td>
          <td>隨意搜尋到的個人 repo、論壇下載的 GGUF</td>
          <td>較低</td>
          <td>個人 dev 場景下建議避開、無法確認權重來源跟修改</td>
      </tr>
  </tbody>
</table>
<p>「中等」跟「較高」的差別主要在「企業簽章」這個維度——Hugging Face verified organization 對應「該組織確實是 Meta / Google / Qwen 等主體」、但不對「該組織內部 release process 是否安全」做擔保。即使是官方發布、仍是「人類團隊發布的權重」、不是密碼學意義的零信任。</p>
<h2 id="gguf-檔案完整性的基本檢查"><a href="/blog/llm/knowledge-cards/gguf/" data-link-title="GGUF" data-link-desc="llama.cpp 生態定義的模型權重格式：把權重、tokenizer、metadata 打包成單一檔案">GGUF</a> 檔案完整性的基本檢查</h2>
<p>下載完 GGUF 檔案後、可以做幾個輕量檢查確認檔案完整性：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln"> 1</span><span class="cl"><span class="c1"># 1. 比對檔案 SHA-256（HF / Ollama 通常會列出官方 hash）</span>
</span></span><span class="line"><span class="ln"> 2</span><span class="cl">shasum -a <span class="m">256</span> ~/.ollama/models/blobs/sha256-xxx
</span></span><span class="line"><span class="ln"> 3</span><span class="cl"><span class="c1"># 或</span>
</span></span><span class="line"><span class="ln"> 4</span><span class="cl">sha256sum Qwen3-30B-A3B-Q4_K_M.gguf
</span></span><span class="line"><span class="ln"> 5</span><span class="cl">
</span></span><span class="line"><span class="ln"> 6</span><span class="cl"><span class="c1"># 2. 看檔案大小是否跟 model card 標示一致</span>
</span></span><span class="line"><span class="ln"> 7</span><span class="cl">ls -la Qwen3-30B-A3B-Q4_K_M.gguf
</span></span><span class="line"><span class="ln"> 8</span><span class="cl">
</span></span><span class="line"><span class="ln"> 9</span><span class="cl"><span class="c1"># 3. 用 llama.cpp 的工具看 GGUF metadata</span>
</span></span><span class="line"><span class="ln">10</span><span class="cl">./gguf-dump.py Qwen3-30B-A3B-Q4_K_M.gguf <span class="p">|</span> head -50
</span></span><span class="line"><span class="ln">11</span><span class="cl"><span class="c1"># 確認 architecture、context_length、量化等級跟預期一致</span></span></span></code></pre></div><p>這些檢查能擋住：</p>
<ol>
<li><strong>下載中斷導致檔案不完整</strong>：hash 不對、跑不起來、不是安全議題但會誤導判讀。</li>
<li><strong>CDN / 鏡像中間人替換</strong>：理論可能、實務上 Hugging Face 跟 Ollama 走 HTTPS、TLS 完整性是基礎防護；hash 比對是額外確認。</li>
<li><strong>誤拉到不同量化版本</strong>：例如想拉 Q4_K_M 結果拉到 Q4_0、檔案大小跟 metadata 會反映出來。</li>
</ol>
<p>擋不住：</p>
<ol>
<li><strong>量化者本身在量化過程做了手腳</strong>：hash 對得上、但權重已經被改過。這需要回到原始作者的權重重新量化、屬於進階驗證、個人 dev 場景通常不做。</li>
<li><strong>作者本身在發布的權重裡植入後門</strong>：個人 dev 場景的 threat model 假設主流作者不會做這件事；若不信任、不應該用該模型。</li>
</ol>
<blockquote>
<p><strong>事實查核註</strong>：GGUF 檔案的完整性檢查工具跟流程依 llama.cpp 版本變化、<code>gguf-dump.py</code> 等腳本路徑可能改名或棄用、以實際 llama.cpp release 跟 <a href="https://github.com/ggml-org/llama.cpp/blob/master/docs/development/gguf-llama-cpp.md">GGUF 規格</a> 為準。</p></blockquote>
<h2 id="ollama--hugging-face--lm-studio-的供應鏈差異">Ollama / Hugging Face / LM Studio 的供應鏈差異</h2>
<p>三個 registry 在實際拉模型的操作面（namespace、download 指令、本機儲存路徑）見對應安裝章節：<a href="/blog/llm/01-local-llm-services/ollama/" data-link-title="1.0 Ollama：主流推論伺服器" data-link-desc="一行 brew 裝完、ollama run 一鍵跑 Gemma 4 MTP、OpenAI 相容 API on localhost:11434">1.0 Ollama</a>、<a href="/blog/llm/01-local-llm-services/lm-studio/" data-link-title="1.1 LM Studio：GUI 探索模型" data-link-desc="GUI 取向的本地推論伺服器：內建模型瀏覽器、speculative decoding 設定面板、適合探索新模型">1.1 LM Studio</a>、PC 場景的 LM Studio 見 <a href="/blog/llm/05-discrete-gpu/lm-studio-on-windows/" data-link-title="5.4 LM Studio 在 Windows" data-link-desc="Windows &#43; 獨立 GPU 場景用 LM Studio：CUDA / ROCm backend 選擇、GUI 內對應 -ngl / cache-type / cpu-moe 的設定位置">5.4</a>。本節聚焦三者在供應鏈管理上的相對位置：</p>
<table>
  <thead>
      <tr>
          <th>Registry</th>
          <th>供應鏈管理風格</th>
          <th>個人 dev 視角的注意點</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Ollama registry</td>
          <td>Ollama 團隊維護 official model 列表、社群可上傳 namespace</td>
          <td><code>library/qwen3</code> 是 official、<code>user/qwen3</code> 是社群、命名前綴要看清</td>
      </tr>
      <tr>
          <td>Hugging Face Hub</td>
          <td>organization + verified badge 機制、社群上傳量大</td>
          <td>認 organization 是不是 verified、看 download 數量跟下載趨勢</td>
      </tr>
      <tr>
          <td>LM Studio 瀏覽器</td>
          <td>內建瀏覽器接到 Hugging Face、用 HF 的信任機制</td>
          <td>視同 Hugging Face、跟 HF 走同一信任鏈</td>
      </tr>
  </tbody>
</table>
<p>實務上、社群常見的選擇路徑：</p>
<ul>
<li>想拉 official 模型：優先 Hugging Face official organization、或 Ollama <code>library/</code> namespace</li>
<li>想拉熱門量化：bartowski / unsloth 等知名量化者的 HF repo、Ollama 通常也會把熱門模型收進 official library</li>
<li>看到個人 repo 上傳的「特別優化版」：除非有明確來源說明、否則保守看待</li>
</ul>
<h2 id="量化版本污染的可能性">量化版本污染的可能性</h2>
<p>量化版本污染的具體威脅形態：</p>
<ol>
<li><strong>量化腳本被改過</strong>：量化者公開的腳本跟實際跑的腳本不一致、產出的權重跟「按公開腳本量化」會不同。</li>
<li><strong>量化過程引入後門</strong>：在量化的同時微調權重、在特定 prompt 下觸發特定行為。技術上可行、實務上社群罕見公開案例、但無法事前完全排除。</li>
<li><strong>量化版本被替換上傳</strong>：先上傳乾淨版本累積下載量、再替換成有問題的版本。HF / Ollama 都有 file history、但個人 dev 通常不會檢查。</li>
</ol>
<p>個人 dev 場景的合理應對：</p>
<ol>
<li><strong>優先用知名量化者的版本</strong>：bartowski / unsloth 等有長期紀錄的量化者、相對個人首次上傳信任度較高。</li>
<li><strong>下載後立刻記錄 hash</strong>：作為日後比對基準；若日後同一 model name 但 hash 變了、值得查 history。</li>
<li><strong>大型 codebase 任務前先用簡單 prompt 試模型</strong>：例如「<code>fn main() { println!(&quot;hi&quot;); }</code>」這類；確認模型行為基本合理、再用於真實任務。</li>
</ol>
<h2 id="第三方-plugin--mcp-server-的供應鏈">第三方 plugin / <a href="/blog/llm/knowledge-cards/mcp/" data-link-title="MCP（Model Context Protocol）" data-link-desc="LLM application ↔ 外部 tool server 之間的標準化協議、複用 OpenAI 相容 API 的成功模式">MCP server</a> 的供應鏈</h2>
<p>模型本身的供應鏈之外、Continue.dev / MCP server / Ollama plugin 等也構成供應鏈、且風險形態不同：</p>
<ol>
<li><strong>MCP server 多為可執行程式碼</strong>：安裝 MCP server 等於在本機跑第三方程式碼、權限影響大於 GGUF 檔案（GGUF 只在 inference 時影響輸出、MCP server 可以直接讀寫檔案、呼叫 shell）。</li>
<li><strong>Continue.dev 擴充套件</strong>：VS Code marketplace 有基本審查、但 community-published 擴充套件的供應鏈仍是個人視角。Continue.dev 安裝與 multi-provider 配置見 <a href="/blog/llm/01-local-llm-services/vscode-continue-integration/" data-link-title="1.3 VS Code &#43; Continue.dev 整合" data-link-desc="安裝 Continue 擴充套件、config.json 設定、Cmd&#43;L 對話 / Cmd&#43;I 行內編輯快捷鍵">1.3</a>。</li>
<li><strong>Ollama Modelfile 中的指令</strong>：Modelfile 內可以指定 template、system prompt 等、若使用社群分享的 Modelfile、要看完內容再用。</li>
</ol>
<p>MCP server 的權限模型詳見 <a href="/blog/llm/06-security/tool-use-permission-model/" data-link-title="6.2 tool use 與 MCP server 的權限模型" data-link-desc="個人 dev 場景下 tool use / MCP server 的副作用權限：檔案系統 / shell / 網路存取邊界、第三方 MCP 信任、副作用的可逆性">6.2 tool use 與 MCP server 的權限模型</a>。</p>
<blockquote>
<p><strong>事實查核註</strong>：MCP（Model Context Protocol）的安全模型仍在演進、各 MCP server 實作的權限粒度、認證機制依版本變化、建議引用前以 <a href="https://modelcontextprotocol.io">MCP 官方文件</a> 跟具體 MCP server 的 README 為準。</p></blockquote>
<h2 id="給讀者的判讀流程">給讀者的判讀流程</h2>
<p>實際下載 / 切換模型時的判讀流程：</p>
<ol>
<li><strong>確認來源 organization / namespace</strong>：是 official、知名量化者、還是個人上傳。</li>
<li><strong>比對檔案完整性</strong>：對主流量化等級、HF / Ollama 通常提供 hash；下載完做一次 hash 比對。</li>
<li><strong>記錄 hash 到本機 inventory</strong>：建一份 <code>~/models/inventory.md</code>、記錄每個 GGUF 的來源 URL、下載日期、SHA-256。</li>
<li><strong>試模型基本行為</strong>：用簡單 prompt 確認模型行為合理。</li>
<li><strong>若是新 MCP server</strong>：分開判讀供應鏈（看 6.2）、不要把 GGUF 跟 MCP 的信任邊界混在一起。</li>
</ol>
<h2 id="下一章">下一章</h2>
<p>下一章：<a href="/blog/llm/06-security/inference-server-binding/" data-link-title="6.1 推論伺服器的綁定與暴露範圍" data-link-desc="個人 dev 場景下 llama-server / Ollama / LM Studio 的 bind address 判讀：127.0.0.1 vs LAN vs 反代、預設安全、誤開放給內網的後果">6.1 推論伺服器的綁定與暴露範圍</a>、處理伺服器跑起來後的第一個對外接觸面。</p>
]]></content:encoded></item><item><title>Model Card</title><link>https://tarrragon.github.io/blog/llm/knowledge-cards/model-card/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/llm/knowledge-cards/model-card/</guid><description>&lt;p>Model card 的核心概念是「模型發布時附帶的 metadata 文件、列出模型的來源、訓練資料、預期用途、能力上限、已知限制跟授權條款」。Hugging Face 上每個 model repo 的 &lt;code>README.md&lt;/code> 就是 model card；它是個人 dev 跟 production 場景下判讀「該不該用這個模型」的最主要資訊來源。&lt;/p>
&lt;h2 id="概念位置">概念位置&lt;/h2>
&lt;p>典型的 model card 包含哪些區段（依平台跟模型而異）：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>區段&lt;/th>
 &lt;th>內容&lt;/th>
 &lt;th>對應的判讀&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>基本資訊&lt;/td>
 &lt;td>模型名稱、參數量、架構、發布者&lt;/td>
 &lt;td>確認是哪個 organization 發布&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Training data&lt;/td>
 &lt;td>訓練語料的來源、規模、語言分布&lt;/td>
 &lt;td>評估模型在自己語言 / 任務的適配性&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Intended use&lt;/td>
 &lt;td>預期用途、適合的應用場景&lt;/td>
 &lt;td>判讀模型是否符合自己工作流&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Out-of-scope use&lt;/td>
 &lt;td>不適合的用途、已知不擅長的任務&lt;/td>
 &lt;td>避免誤用&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Bias、ethical considerations&lt;/td>
 &lt;td>已知偏見、敏感議題的回應傾向&lt;/td>
 &lt;td>production 場景的合規評估&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Benchmark&lt;/td>
 &lt;td>在公開 benchmark 上的分數&lt;/td>
 &lt;td>跟其他模型對比&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>License&lt;/td>
 &lt;td>模型權重的使用授權&lt;/td>
 &lt;td>商用前必看&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Quantization 版本&lt;/td>
 &lt;td>該 repo 提供哪些量化版本&lt;/td>
 &lt;td>選對應 &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/gguf/" data-link-title="GGUF" data-link-desc="llama.cpp 生態定義的模型權重格式：把權重、tokenizer、metadata 打包成單一檔案">GGUF&lt;/a> 版本&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;blockquote>
&lt;p>&lt;strong>事實查核註&lt;/strong>：Hugging Face 推動 Model Card 規範跟 &lt;a href="https://github.com/huggingface/hub-docs">Model Card Toolkit&lt;/a>、但實際填寫品質依 organization 變化、部分 repo 的 model card 內容很簡略、不能 100% 依賴。引用前以該 repo 當前內容為準。&lt;/p>&lt;/blockquote>
&lt;h2 id="設計責任">設計責任&lt;/h2>
&lt;p>理解 model card 後可以解釋兩個現象：為什麼選模型不能只看名字（同個 base model 的不同 fine-tune 版本能力差很多）、為什麼商用前要看 license（Llama Community License、Apache 2.0、MIT 等差異大）。&lt;/p>
&lt;p>實務上選模型時、model card 是第一閱讀對象、其他資訊（社群評測、benchmark leaderboard）作為交叉驗證；引用模型時應該明確記下「base model + fine-tune 變體 + 量化版本」三層。詳見 &lt;a href="https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">6.0 模型供應鏈與信任邊界&lt;/a> 跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/llm-deployment-supply-chain/" data-link-title="LLM Deployment 供應鏈完整性" data-link-desc="把 LLM 模型權重、推論伺服器、第三方 plugin 三條 production 供應鏈納入既有 artifact trust 框架的判讀">LLM Deployment 供應鏈完整性&lt;/a>。&lt;/p></description><content:encoded><![CDATA[<p>Model card 的核心概念是「模型發布時附帶的 metadata 文件、列出模型的來源、訓練資料、預期用途、能力上限、已知限制跟授權條款」。Hugging Face 上每個 model repo 的 <code>README.md</code> 就是 model card；它是個人 dev 跟 production 場景下判讀「該不該用這個模型」的最主要資訊來源。</p>
<h2 id="概念位置">概念位置</h2>
<p>典型的 model card 包含哪些區段（依平台跟模型而異）：</p>
<table>
  <thead>
      <tr>
          <th>區段</th>
          <th>內容</th>
          <th>對應的判讀</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>基本資訊</td>
          <td>模型名稱、參數量、架構、發布者</td>
          <td>確認是哪個 organization 發布</td>
      </tr>
      <tr>
          <td>Training data</td>
          <td>訓練語料的來源、規模、語言分布</td>
          <td>評估模型在自己語言 / 任務的適配性</td>
      </tr>
      <tr>
          <td>Intended use</td>
          <td>預期用途、適合的應用場景</td>
          <td>判讀模型是否符合自己工作流</td>
      </tr>
      <tr>
          <td>Out-of-scope use</td>
          <td>不適合的用途、已知不擅長的任務</td>
          <td>避免誤用</td>
      </tr>
      <tr>
          <td>Bias、ethical considerations</td>
          <td>已知偏見、敏感議題的回應傾向</td>
          <td>production 場景的合規評估</td>
      </tr>
      <tr>
          <td>Benchmark</td>
          <td>在公開 benchmark 上的分數</td>
          <td>跟其他模型對比</td>
      </tr>
      <tr>
          <td>License</td>
          <td>模型權重的使用授權</td>
          <td>商用前必看</td>
      </tr>
      <tr>
          <td>Quantization 版本</td>
          <td>該 repo 提供哪些量化版本</td>
          <td>選對應 <a href="/blog/llm/knowledge-cards/gguf/" data-link-title="GGUF" data-link-desc="llama.cpp 生態定義的模型權重格式：把權重、tokenizer、metadata 打包成單一檔案">GGUF</a> 版本</td>
      </tr>
  </tbody>
</table>
<blockquote>
<p><strong>事實查核註</strong>：Hugging Face 推動 Model Card 規範跟 <a href="https://github.com/huggingface/hub-docs">Model Card Toolkit</a>、但實際填寫品質依 organization 變化、部分 repo 的 model card 內容很簡略、不能 100% 依賴。引用前以該 repo 當前內容為準。</p></blockquote>
<h2 id="設計責任">設計責任</h2>
<p>理解 model card 後可以解釋兩個現象：為什麼選模型不能只看名字（同個 base model 的不同 fine-tune 版本能力差很多）、為什麼商用前要看 license（Llama Community License、Apache 2.0、MIT 等差異大）。</p>
<p>實務上選模型時、model card 是第一閱讀對象、其他資訊（社群評測、benchmark leaderboard）作為交叉驗證；引用模型時應該明確記下「base model + fine-tune 變體 + 量化版本」三層。詳見 <a href="/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">6.0 模型供應鏈與信任邊界</a> 跟 <a href="/blog/backend/07-security-data-protection/llm-deployment-supply-chain/" data-link-title="LLM Deployment 供應鏈完整性" data-link-desc="把 LLM 模型權重、推論伺服器、第三方 plugin 三條 production 供應鏈納入既有 artifact trust 框架的判讀">LLM Deployment 供應鏈完整性</a>。</p>
]]></content:encoded></item><item><title>GitHub Advanced Security</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/</guid><description>&lt;p>GitHub Advanced Security（GHAS）是 GitHub 內建的 &lt;em>application security platform&lt;/em>、由四大模組組成：&lt;em>Code Scanning&lt;/em>（CodeQL 為預設 SAST、可接受第三方 SARIF）、&lt;em>Secret Scanning&lt;/em>（偵測 leaked credential、含 Push Protection 預防 push）、&lt;em>Dependency Review&lt;/em>（PR 級依賴變更 gate）、&lt;em>Dependabot&lt;/em>（自動化依賴 update + alert、細節見獨立 vendor 頁）。它跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &amp;#43; Code (SAST) &amp;#43; Container &amp;#43; IaC &amp;#43; Cloud (CSPM)、Reachability analysis">Snyk&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &amp;#43; Secret &amp;#43; License &amp;#43; SBOM、Apache 2.0、CI 友善">Trivy&lt;/a> 等獨立 SCA 工具的核心差異是 &lt;em>跟 GitHub workflow / PR / Security tab 深度整合&lt;/em> — security finding 直接出現在 PR review 跟 organization Security overview、不需另一個 dashboard。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>GHAS 的核心定位是 &lt;em>把 application security 控制面收斂回 GitHub 平台&lt;/em>：SAST、Secret Scanning、Dependency Review、Dependabot 共用 GitHub 的 identity / permission / PR / branch protection / Actions / Security tab，讓 security finding 跟 code review 在同一個 surface 上決策。這跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &amp;#43; Code (SAST) &amp;#43; Container &amp;#43; IaC &amp;#43; Cloud (CSPM)、Reachability analysis">Snyk&lt;/a> 走「跨 SCM、跨雲、自有 dashboard」是相反方向 — Snyk 把 security 抽到平台之上、GHAS 把 security 釘在 GitHub 之內。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &amp;#43; Secret &amp;#43; License &amp;#43; SBOM、Apache 2.0、CI 友善">Trivy&lt;/a> 比、定位差更遠。Trivy 主打 &lt;em>container image / IaC / SBOM scan&lt;/em>、open-source 免費、適合塞進任何 CI；GHAS 主打 &lt;em>source code + secret + dependency&lt;/em>、Enterprise 付費、container scan 有但偏弱。兩者通常 &lt;em>並存&lt;/em> — Trivy 跑 container artifact、GHAS 跑 source repo。&lt;/p></description><content:encoded><![CDATA[<p>GitHub Advanced Security（GHAS）是 GitHub 內建的 <em>application security platform</em>、由四大模組組成：<em>Code Scanning</em>（CodeQL 為預設 SAST、可接受第三方 SARIF）、<em>Secret Scanning</em>（偵測 leaked credential、含 Push Protection 預防 push）、<em>Dependency Review</em>（PR 級依賴變更 gate）、<em>Dependabot</em>（自動化依賴 update + alert、細節見獨立 vendor 頁）。它跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> / <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 等獨立 SCA 工具的核心差異是 <em>跟 GitHub workflow / PR / Security tab 深度整合</em> — security finding 直接出現在 PR review 跟 organization Security overview、不需另一個 dashboard。</p>
<h2 id="服務定位">服務定位</h2>
<p>GHAS 的核心定位是 <em>把 application security 控制面收斂回 GitHub 平台</em>：SAST、Secret Scanning、Dependency Review、Dependabot 共用 GitHub 的 identity / permission / PR / branch protection / Actions / Security tab，讓 security finding 跟 code review 在同一個 surface 上決策。這跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> 走「跨 SCM、跨雲、自有 dashboard」是相反方向 — Snyk 把 security 抽到平台之上、GHAS 把 security 釘在 GitHub 之內。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 比、定位差更遠。Trivy 主打 <em>container image / IaC / SBOM scan</em>、open-source 免費、適合塞進任何 CI；GHAS 主打 <em>source code + secret + dependency</em>、Enterprise 付費、container scan 有但偏弱。兩者通常 <em>並存</em> — Trivy 跑 container artifact、GHAS 跑 source repo。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a> 的關係是 <em>內含</em> — Dependabot 是 GHAS 四模組之一、跟 GHAS 同一個控制平面、跟 PR / Security tab 同一條 evidence chain。本頁聚焦 GHAS 整體 + Code Scanning / Secret Scanning / Dependency Review；Dependabot 的 update PR 政策、ecosystem 覆蓋、alert routing 細節留在該頁。</p>
<p>關鍵張力：GHAS 計費走 <em>per-active-committer + per-repo</em>、2024 後 Secret Scanning 跟 Code Scanning 拆開計費。大型 mono-repo 或 committer 數量膨脹的組織會撞到成本天花板、需要選擇性 enable repo + 拆模組買；同時、Push Protection 這類 <em>預防型</em> 控制只有 enable 後才有效、選擇性 enable 等於默認 risk 接受。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>GHAS 四大模組各自承擔哪段控制責任（SAST / Secret / PR-level dependency gate / 自動 update）、哪些跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> / <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 重疊或互補</li>
<li>CodeQL 跟 SARIF 標準的關係、為什麼第三方 SAST 工具的 finding 也能進 GHAS Security tab</li>
<li>Secret Scanning 的 <em>Push Protection</em>（預防 push）跟 <em>Secret Scanning Alert</em>（偵測 leaked）的職責差、partner pattern vs custom pattern 何時用</li>
<li>何時用 GHAS、何時改走 Snyk / Trivy / GitLab Ultimate（GitLab 自家相當品）</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 GHAS 配置是否健康、最少看四件事：</p>
<ul>
<li><strong>誰能 enable / disable</strong>：Organization owner / Security manager role 配置、enable GHAS 的 audit log 是否同步、誰能改 Code Scanning workflow（branch protection 是否擋住 workflow file 直接 push）</li>
<li><strong>哪些 repo 開啟</strong>：Org Security overview 看 <em>Code Scanning / Secret Scanning / Dependency Review coverage</em>、新建 repo 是否預設啟用（Organization-level default setting）、private / internal / public repo 是否一致開啟</li>
<li><strong>Push Protection 狀態</strong>：Secret Scanning Push Protection 是否 organization-wide enable、bypass 權限給誰（developer 個人 bypass vs 必須走 Security team approval）、bypass 事件是否進 audit</li>
<li><strong>Secret Scanning Coverage</strong>：partner pattern（AWS / GCP / Stripe / Slack 等預配）是否全開、custom pattern 是否涵蓋自家 internal token（service token、internal API key）、historical scan 是否跑過（不只新 commit、舊 commit 也要掃）</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/knowledge-cards/secret-management/" data-link-title="Secret Management" data-link-desc="說明 token、key、password 與憑證如何保存、輪替與撤銷">Secret Management</a> 跟 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">Supply Chain Integrity</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Code Scanning 走 SARIF 標準</strong>：Code Scanning 不只是 CodeQL 的 UI、是 <em>SAST aggregation layer</em>。所有 SAST 結果（CodeQL 預設、或 Semgrep / Snyk Code / Brakeman / Bandit / SonarCloud / Checkmarx 等第三方）以 SARIF（Static Analysis Results Interchange Format）upload 到 Code Scanning、Security tab 統一展示、PR review 統一標註。意義是 <em>組織可以用多個 SAST 工具但只看一個 dashboard</em> — 不需要每個 vendor 各自登入。多工具 SARIF upload 用 GitHub Actions 的 <code>github/codeql-action/upload-sarif</code> step。</p>
<p><strong>CodeQL 是 first-class query language</strong>：CodeQL 用 Datalog-like 語法寫 <em>自定 query</em>、可以檢測 <em>organization-specific anti-pattern</em>（例：禁用某內部 deprecated function、強制 input validation 在特定 trust boundary）。vendor-provided pack（GitHub 維護的 CodeQL pack）覆蓋 OWASP Top 10 / CWE Top 25、自定 query 補組織 idiomatic check。代價是 <em>CodeQL 學習曲線陡</em> — 不是 regex / AST pattern、是完整的 graph query language。</p>
<p><strong>Secret Scanning 三層職責</strong>：Secret Scanning 分三層。<em>Partner pattern</em> — GitHub 跟 AWS / GCP / Stripe / Slack / npm 等 vendor 預配 token pattern、預設 detection 範圍最大、leaked token 還會通知 vendor revoke。<em>Push Protection</em> — commit push 前 scan、發現 secret 直接 reject push、開發者必須先移除才能 push；這是 <em>預防</em> 不是 <em>偵測</em>、不需要等 leaked 後 rotation。<em>Custom pattern</em> — 組織自己的 internal token（service-to-service API key、legacy auth token）寫 regex pattern、配 validation endpoint 降 FP。</p>
<p><strong>Dependency Review 是 PR-level gate</strong>：每個 PR 跑 <em>新增 / 升級依賴的漏洞檢查 + license check</em>、把 <em>新引入 CVE</em> 列在 PR review、可設 branch protection 強制 PR 過 Dependency Review 才能 merge。這跟 <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a> 是互補關係：Dependabot 是 <em>已 merge 依賴的 update PR</em>（時間軸：merge 後 vuln 出現、自動發 update PR）、Dependency Review 是 <em>PR 加新依賴時的 gate</em>（時間軸：merge 前 vuln 已知、擋 PR）。兩條軸都要開。</p>
<p><strong>Security overview 是 org-level dashboard</strong>：Organization Security tab 看 <em>跨 repo</em> 的 Code Scanning / Secret Scanning / Dependency / Dependabot alert 彙整、用 repo / severity / age filter 排序。對於 <em>security team 不是 repo owner</em> 的組織、Security manager role 給 security team 跨 repo read + triage 權限、不需要 admin。</p>
<p><strong>Security Advisories（CVE 揭露 workflow）</strong>：自家 OSS / 商業 product 出 CVE 時、走 <em>GitHub Security Advisory</em> — 在 private fork 修補、coordinated disclosure 時間到公開 advisory、GitHub 自動向 <a href="https://www.cve.org/">CVE Numbering Authority</a> 申請 CVE ID。這條 workflow 是 <em>維護者視角</em>、不是 <em>使用者視角</em>；使用者收到的是其他人發的 advisory 進 Dependabot alert。</p>
<p><strong>SARIF integration 是 GHAS 的 <em>aggregation</em> 角色關鍵</strong>：GHAS 不強迫只用 CodeQL — Snyk Code / Semgrep / SonarCloud 等 SAST 工具跑完輸出 SARIF、CI 上傳到 GitHub、Security tab 集中展示。意義是 <em>組織用 Snyk 做 SAST、但 finding 走 GHAS UI</em> 是合法配置；GHAS 賣的不只是 CodeQL、是 SAST 統一視圖。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>GHAS</th>
          <th>Snyk</th>
          <th>Trivy</th>
          <th>Dependabot（GHAS 子模組）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>主要範圍</td>
          <td>Source code + secret + dependency（PR-level）</td>
          <td>SCA + Container + IaC + SAST（跨 SCM）</td>
          <td>Container image + IaC + SBOM scan</td>
          <td>依賴 update + alert（merged code）</td>
      </tr>
      <tr>
          <td>SCM 綁定</td>
          <td>緊綁 GitHub</td>
          <td>跨 GitHub / GitLab / Bitbucket / Azure Repos</td>
          <td>無 SCM 綁定、跑在 CI / artifact registry</td>
          <td>緊綁 GitHub</td>
      </tr>
      <tr>
          <td>SAST 引擎</td>
          <td>CodeQL 預設 + 第三方 SARIF aggregation</td>
          <td>Snyk Code（DeepCode）</td>
          <td>無 SAST</td>
          <td>無</td>
      </tr>
      <tr>
          <td>Secret Scanning</td>
          <td>Partner pattern + Push Protection + custom pattern</td>
          <td>Snyk Secret Scanning（較弱）</td>
          <td>有限（filesystem secret scan）</td>
          <td>無</td>
      </tr>
      <tr>
          <td>Container 強度</td>
          <td>中（Code Scanning 可掃 Dockerfile）</td>
          <td>強（Snyk Container 是主打）</td>
          <td>強（Trivy 是 container scan 標準）</td>
          <td>無</td>
      </tr>
      <tr>
          <td>License / SBOM</td>
          <td>有（Dependency Review 含 license）</td>
          <td>強（SBOM 生成、license compliance dashboard）</td>
          <td>強（SBOM 是 first-class）</td>
          <td>無</td>
      </tr>
      <tr>
          <td>PR 整合</td>
          <td>深 — Security tab + PR review 直連</td>
          <td>中 — GitHub Check + 跨 SCM PR comment</td>
          <td>中 — 第三方 Action 整合</td>
          <td>深 — 自動發 PR</td>
      </tr>
      <tr>
          <td>計費</td>
          <td>Per-active-committer + per-repo（Enterprise）</td>
          <td>Per-developer + tier</td>
          <td>Open source 免費（Aqua 商業版加值）</td>
          <td>GHAS 一部分</td>
      </tr>
      <tr>
          <td>適合</td>
          <td>GitHub-heavy org、想統一 PR + security UI</td>
          <td>多 SCM / 多雲、SCA + Container 一站、license 強需求</td>
          <td>Container / IaC scan 為主、CI pluggable</td>
          <td>GitHub repo 想要自動依賴 update</td>
      </tr>
      <tr>
          <td>不適合</td>
          <td>GitLab / Bitbucket / 自管 Git 為主</td>
          <td>GitHub-only 又要省成本</td>
          <td>需要 SAST + Secret Scanning</td>
          <td>不想自動產生 PR（噪音）</td>
      </tr>
  </tbody>
</table>
<p>選 GHAS 的核心訴求：<em>GitHub 是 SCM</em> + 想 <em>PR review 跟 security finding 合一</em> + Enterprise 預算可吸收 per-committer cost。GitLab 主要的組織直接走 GitLab Ultimate 的對等功能；多 SCM 或 container 為主走 Snyk + Trivy 組合。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>CodeQL custom query 開發</strong>：寫自定 query 用 CodeQL CLI 本地開發、跑 <code>codeql database analyze</code>、SARIF output 上傳。常見場景：禁用 internal deprecated API、特定 framework 的 misuse pattern、組織 idiomatic security check。Query pack 可以 publish 到 GitHub Container Registry 或 internal registry、跨 repo 復用。代價是 <em>維護成本</em> — CodeQL query language 學習曲線陡、組織需要至少 1-2 個 security engineer 專門養護。</p>
<p><strong>Push Protection bypass workflow</strong>：Push Protection reject push 後、developer 可以 <em>bypass</em>（標記 false positive / test data / 風險已知）。Bypass 權限治理是關鍵 — 開放給 developer 個人 bypass 失去預防意義、強制 Security team approval 又拖慢 dev velocity。常見折中：低風險 pattern（test fixture token）developer 可 bypass、高風險 pattern（production credential）必須 Security team approve；所有 bypass 事件進 audit log。</p>
<p><strong>跟 GitHub Actions 整合</strong>：Code Scanning 走 GitHub Actions workflow 跑 CodeQL — <code>github/codeql-action/init</code> + <code>github/codeql-action/analyze</code>。同 workflow 可以加 <code>upload-sarif</code> step 接第三方 SAST 結果。Actions 用 GitHub-hosted runner 跑 CodeQL 是預設、大型 repo 跑 CodeQL analyze 可能超時、需改 self-hosted runner（大 RAM / 多 CPU）— 但 self-hosted runner 自身是 supply chain 風險、需要 ephemeral runner + 限制 secret access。</p>
<p><strong>SARIF 多工具整合</strong>：第三方 SAST / SCA / Container scan 工具（Snyk / Semgrep / Trivy / Brakeman / Bandit / Gosec）跑完輸出 SARIF、CI 上傳到 GHAS。實務上組織常用 <em>CodeQL + Semgrep</em> 雙軌 — CodeQL 跑深度 graph query、Semgrep 跑快速 pattern 規則；finding 在 Security tab 用 <em>tool</em> filter 分開看。</p>
<p><strong>Secret Scanning partner pattern</strong>：GitHub 維護的 partner pattern list 涵蓋 AWS / GCP / Azure / Stripe / Slack / npm / Docker Hub / GitHub PAT 等。leaked token detect 後、GitHub 自動通知 vendor、vendor 端可選擇 <em>自動 revoke</em> 該 token。意義是 <em>組織不需要做 rotation</em> — vendor 已經把 leaked token 廢掉。custom pattern 則需要組織自己提供 validation endpoint、GHAS 呼叫驗證才確認是真 leak。</p>
<p><strong>GHAS Cloud-hosted vs Self-hosted Runner 治理</strong>：CodeQL 跑在 GitHub-hosted runner 是預設、所有 source code 上傳到 GitHub 運算環境。對 <em>source code 機密度高</em> 的組織（金融 / 國防 / 法規限制 source 出境）、需走 self-hosted runner。Self-hosted runner 的供應鏈風險見 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022</a> — runner token 是 supply chain entry、OIDC short-lived token 是建議方向。</p>
<p><strong>GHAS Enterprise pricing trap</strong>：Per-active-committer 計費、organization 內所有 <em>過去 90 天有 commit</em> 的 user 都算 active committer、即使只 commit 1 行也計費。大型公司容易超支；2024 後 Secret Scanning 跟 Code Scanning 拆開計費、可只買 Secret Scanning（單價較低）給全 org、Code Scanning 給關鍵 repo。Public repo 上 GHAS 功能多數免費（Code Scanning、Secret Scanning、Dependency Review）；GitHub Enterprise Cloud 的 internal / private repo 才落入 GHAS 計費範圍 — 兩者範圍不同、新組織常踩到把 private repo 全開的成本。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>新建 repo 沒自動開 GHAS</strong>：Organization-level default 沒設、新 repo 預設 disable — 開 Organization Security settings 的 <em>Enable for new repositories</em>、現有 repo 用 bulk enable</li>
<li><strong>Push Protection 大量誤殺</strong>：custom pattern regex 太寬、合法字串被當 secret — 加 validation endpoint 或收緊 regex、bypass 統計看 FP rate</li>
<li><strong>Secret Scanning 沒掃歷史 commit</strong>：只 enable 後新 commit 觸發、舊 commit leaked secret 沒被發現 — 跑 <em>historical scan</em>（enable 後 GitHub 自動掃過去全部 commit）、可能花數小時</li>
<li><strong>Dependency Review 沒擋住 vuln PR</strong>：Branch protection 沒加 <em>Dependency Review</em> required check — 加進 required status check、新 PR 才強制過</li>
<li><strong>Code Scanning workflow 跑很久 / 超時</strong>：repo 太大、GitHub-hosted runner RAM 不足 — 換 larger runner（GitHub Larger Runners）或 self-hosted、或只跑 changed file analysis</li>
<li><strong>Custom CodeQL query FP 多</strong>：query 寫得太寬、commit 都跳 alert — 加 <code>@precision high</code> 標籤、用 <code>Sink-Source</code> 分析降低 reach</li>
<li><strong>第三方 SAST SARIF 沒進 Security tab</strong>：upload-sarif step 沒設對 category 或 permissions — <code>security-events: write</code> permission 必須在 workflow 給；同 repo 多工具用不同 <code>category</code> 區分</li>
<li><strong>Bypass 沒進 audit</strong>：Push Protection bypass 沒同步到 SIEM — Enterprise audit log streaming 開、event filter 加 <code>secret_scanning.bypass</code></li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>多 SCM（GitHub + GitLab + Bitbucket）</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a></td>
      </tr>
      <tr>
          <td>Container image scan 為主</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 或 Snyk Container</td>
      </tr>
      <tr>
          <td>SBOM 生成 + license compliance</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft + Grype</a>（SBOM-first OSS）/ <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> + <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（SBOM 含在 scan）</td>
      </tr>
      <tr>
          <td>GitLab 為主</td>
          <td>GitLab Ultimate（SAST / Secret Detection / Dependency Scanning 內建）</td>
      </tr>
      <tr>
          <td>Secret scan 但不在 GitHub</td>
          <td>GitGuardian / Gitleaks</td>
      </tr>
      <tr>
          <td>Runtime detection（不只 source code）</td>
          <td><a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a> 系列工具</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>CodeQL 完整 query language reference</li>
<li>Dependabot 的 update PR 政策、ecosystem 覆蓋、grouped update（見 <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot vendor 頁</a>）</li>
<li>GHAS Enterprise Server（自管 GitHub）跟 Cloud GHAS 的功能差異</li>
<li>各語言 / 框架的 CodeQL pack 完整覆蓋表</li>
<li>GHAS 跟 GitHub Copilot Autofix 整合的 AI-assisted remediation 細節</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>GHAS 在 07 案例庫沒有 <em>直接 GHAS-level vendor 事件</em>。對照引用展示 GHAS 在 supply chain / source-level 控制的能力邊界：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 GHAS 的關係</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/log4shell-cve-2021-44228-component-chain/" data-link-title="7.R7.2.7 Log4Shell 2021：共用元件風險與修補鏈" data-link-desc="共用元件漏洞如何同步影響多服務，並迫使團隊建立依賴治理 workflow">Log4Shell CVE-2021-44228</a></td>
          <td>Dependency Review + Code Scanning 應覆蓋 transitive 依賴、不只 direct import；Security Advisory 是維護者揭露 CVE 的 workflow</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a></td>
          <td>對照啟示 — GHAS Dependency Review 看 <em>package version</em>、看不到 <em>maintainer takeover</em>；需補 release-tarball vs git tag 差異跟 maintainer trust baseline</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020 Sunburst</a></td>
          <td>對照啟示 — Code Scanning 是 source-level、看不到 build-time 植入；需配合 artifact provenance（SLSA L2+）+ reproducible build</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a></td>
          <td>對照啟示 — GHAS 自身 token / Actions 權限治理是 supply chain risk、Push Protection + OIDC trust（非長期 token）是 mitigation</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></td>
          <td>GHAS 是 supply chain 治理工具集、章節原則對應四模組 workflow</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a>、<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>、<a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a>、<a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft + Grype</a>（SBOM 走 SARIF 進 GHAS Code Scanning 是常見組合）</li>
<li>下游：<a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">7.6 秘密管理與機器憑證治理</a>（Secret Scanning 配 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> rotation）</li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a>（GHAS alert 進 SIEM 的 routing）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（leaked secret / SAST critical finding 進 IR 流程）</li>
<li>官方：<a href="https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security">GitHub Advanced Security Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>Snyk</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/</guid><description>&lt;p>Snyk 是 &lt;em>developer-first&lt;/em> 的 &lt;em>跨 SCM 多模組 application security platform&lt;/em>、把 SCA、SAST、Container scan、IaC scan、CSPM 整合到一個 dashboard、五大模組共用同一套 Project / Issue / Fix 模型。流量打到 GitHub / GitLab / Bitbucket / Azure Repos 任一 SCM、Snyk 拉取 repo、按 manifest 建 Project、發現 Issue 後送 PR 修補。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security&lt;/a> 比、Snyk &lt;em>跨 SCM&lt;/em> 跟 &lt;em>跨技術棧&lt;/em>；跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &amp;#43; Secret &amp;#43; License &amp;#43; SBOM、Apache 2.0、CI 友善">Trivy&lt;/a> 比、Snyk 是商業 SaaS、覆蓋面更廣、但年費按 Project 計價。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Snyk 的核心定位是 &lt;em>用一個工具一個 dashboard 同時管 SCA + SAST + IaC + Container + Cloud&lt;/em>。五大模組 — &lt;em>Snyk Open Source&lt;/em>（SCA、依賴漏洞）、&lt;em>Snyk Code&lt;/em>（SAST）、&lt;em>Snyk Container&lt;/em>（image scan）、&lt;em>Snyk IaC&lt;/em>（Terraform / CloudFormation / K8s manifest 安全）、&lt;em>Snyk Cloud&lt;/em>（CSPM、雲端配置 drift）— 共用 Project / Target / Organization / Issue 模型、Issue 跨模組可一起 prioritize。對 &lt;em>多 SCM + 多技術棧&lt;/em> 的組織、Snyk 比拼裝 GHAS + Trivy + Dependabot 更整合。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security&lt;/a> 的核心差異是 &lt;em>部署模型跟 SCM 範圍&lt;/em>：GHAS 綁 GitHub、走 GitHub Actions、PR 整合更深（Code Scanning alert 直接顯示在 PR review）；Snyk 走 SaaS、SCM 中立、但需要 OAuth 連到每個 repo。組織用 GitLab / Bitbucket / Azure Repos 或同時用多種 SCM、Snyk 是天然選擇。&lt;/p></description><content:encoded><![CDATA[<p>Snyk 是 <em>developer-first</em> 的 <em>跨 SCM 多模組 application security platform</em>、把 SCA、SAST、Container scan、IaC scan、CSPM 整合到一個 dashboard、五大模組共用同一套 Project / Issue / Fix 模型。流量打到 GitHub / GitLab / Bitbucket / Azure Repos 任一 SCM、Snyk 拉取 repo、按 manifest 建 Project、發現 Issue 後送 PR 修補。跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a> 比、Snyk <em>跨 SCM</em> 跟 <em>跨技術棧</em>；跟 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 比、Snyk 是商業 SaaS、覆蓋面更廣、但年費按 Project 計價。</p>
<h2 id="服務定位">服務定位</h2>
<p>Snyk 的核心定位是 <em>用一個工具一個 dashboard 同時管 SCA + SAST + IaC + Container + Cloud</em>。五大模組 — <em>Snyk Open Source</em>（SCA、依賴漏洞）、<em>Snyk Code</em>（SAST）、<em>Snyk Container</em>（image scan）、<em>Snyk IaC</em>（Terraform / CloudFormation / K8s manifest 安全）、<em>Snyk Cloud</em>（CSPM、雲端配置 drift）— 共用 Project / Target / Organization / Issue 模型、Issue 跨模組可一起 prioritize。對 <em>多 SCM + 多技術棧</em> 的組織、Snyk 比拼裝 GHAS + Trivy + Dependabot 更整合。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a> 的核心差異是 <em>部署模型跟 SCM 範圍</em>：GHAS 綁 GitHub、走 GitHub Actions、PR 整合更深（Code Scanning alert 直接顯示在 PR review）；Snyk 走 SaaS、SCM 中立、但需要 OAuth 連到每個 repo。組織用 GitLab / Bitbucket / Azure Repos 或同時用多種 SCM、Snyk 是天然選擇。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 比、Trivy 是 OSS、主 container + IaC、適合 CI 內 self-hosted；Snyk 商業 SaaS、覆蓋更廣（含 SAST 跟 Reachability）、適合 <em>組織級 governance + 跨團隊統一 dashboard</em>。Trivy 是 <em>跑工具</em>、Snyk 是 <em>買治理</em>。</p>
<p>關鍵張力：Snyk 的 <em>Project 是計費單位</em>。每個 manifest 算一個 Project（一個 repo 有 package.json + requirements.txt + Dockerfile = 3 Project）。大 monorepo 容易暴量、需要 <em>project filter / archive</em> 治理、否則年費失控。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>Snyk 五大模組在 application security stack 承擔哪一段、哪些靠其他工具</li>
<li>Project 計費模型、monorepo 跟 multi-manifest repo 的 Project 暴量風險跟治理路徑</li>
<li>Reachability analysis 的價值跟限制、何時減 noise、何時被誤判</li>
<li>何時用 Snyk、何時走 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS</a> / <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> / <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a> 的取捨</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 Snyk 配置是否健康、最少看四件事：</p>
<ul>
<li><strong>誰能 enable Snyk</strong>：Organization 的 admin / collaborator role 配置、Service Account token scope（不要用 personal API token 跑 CI、用 Service Account + scoped token）、Audit Log 是否同步到 SIEM</li>
<li><strong>Project import 治理</strong>：每個 SCM target 自動 import 哪些 manifest、是否有 <em>project filter</em> 排除 test fixture / vendored dependency、archived project 是否真的不計費、monorepo 是否走 <em>.snyk policy file</em> 控制</li>
<li><strong>Reachability analysis 是否啟用</strong>：Snyk Code + Open Source 整合、call graph 分析「我的 code 真的呼叫到 vulnerable 函式嗎」— 大幅減少 <em>transitive dep 但 unreachable</em> 的 noise、production 應該啟用</li>
<li><strong>SBOM export 是否走 release pipeline</strong>：CycloneDX / SPDX 格式是否定期匯出、是否進 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">supply chain integrity</a> 流程、合規要求（EO 14028 / NIS2）是否覆蓋</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/knowledge-cards/audit-log/" data-link-title="Audit Log" data-link-desc="說明高風險操作如何留下可追溯、可稽核的紀錄">Audit Log</a> 與 supply chain 治理邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Project / Target / Organization 模型</strong>：<em>Organization</em> 是計費跟 RBAC 邊界、對應一個團隊或一個 BU。<em>Target</em> 是一個 SCM 來源（一個 GitHub repo / 一個 container registry image / 一個 Terraform stack）。<em>Project</em> 是 Target 內的單一掃描單位（一個 manifest 或一個 image tag）。Issue 是發現的漏洞 / license / misconfig、有 severity（Critical / High / Medium / Low）、CVSS、exploit maturity、fix availability。Project 暴量的根因通常是 monorepo 內 nested manifest 全被 auto-import、用 <code>.snyk</code> 或 import filter 排除。</p>
<p><strong>五大模組分工</strong>：<em>Snyk Open Source</em>（SCA）掃 package manifest（npm、pip、Maven、Go modules、Composer、NuGet 等 20+ 生態）對 Snyk Vulnerability DB（自家維護、補強 NVD 延遲）。<em>Snyk Code</em>（SAST）掃源碼、symbolic execution + ML、覆蓋 OWASP Top 10 跟 CWE。<em>Snyk Container</em> 掃 image base layer + installed package、支援 Docker / OCI / ECR / GCR / Harbor。<em>Snyk IaC</em> 掃 Terraform / CloudFormation / K8s YAML / Helm chart 對 CIS Benchmark + custom policy。<em>Snyk Cloud</em>（2023 收購 Fugue 後加入）是 CSPM、scan AWS / Azure / GCP runtime 配置 + IaC drift detection（cloud 實際狀態 vs Terraform 狀態的差異）。</p>
<p><strong>Snyk Code (SAST) vs GHAS CodeQL</strong>：Snyk Code 走 <em>快速 inline scan</em>（秒級回饋、走 cloud inference）、適合 dev loop；CodeQL 走 <em>深度 dataflow query</em>（分鐘級、執行更慢但表達力更強）、適合 release gate。同時用兩者並不矛盾 — Snyk Code 在 IDE / PR 給快速訊號、CodeQL 在 release 前跑深度檢查。</p>
<p><strong>Reachability analysis</strong>：跟 <em>純 dependency list 比對 CVE</em> 不同、Snyk 結合 Snyk Code (SAST) 跟 Snyk Open Source (SCA)、做 <em>call graph 分析</em>、判斷「我的 code 是否真的呼叫到 vulnerable 函式」。實務影響：多數 transitive dependency 的 CVE 在你的 app 內 <em>不 reachable</em>（你引入的 lib 沒呼叫到那條 path）— Reachability 過濾後、可以從 <em>幾百個 Critical / High</em> 降到 <em>幾個真的 exploitable</em>。限制：只支援部分語言（Java / JS / Python / Go 較完整）、且 dynamic dispatch / reflection / runtime plugin load 會被當成 reachable（false positive）或 unreachable（false negative）— 不可全信、是 <em>prioritization signal</em> 不是 <em>binary verdict</em>。</p>
<p><strong>Fix advice / Auto PR</strong>：發現 vuln 後、Snyk 自動發 PR 升級到 <em>最小 fix version</em>（包含 transitive dep 的 root cause upgrade）。跟 <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a> 功能重疊、差異是 Snyk 跨 SCM（不只 GitHub）、且 fix advice 含 Reachability 標註（reachable vuln 的 PR 優先級高）。重複用兩者要關掉其一、否則 PR 量翻倍。</p>
<p><strong>跟 CI 整合</strong>：<code>snyk</code> CLI（<code>snyk test</code> / <code>snyk monitor</code> / <code>snyk container test</code> / <code>snyk iac test</code>）走 SNYK_TOKEN 環境變數、可在任何 CI 跑。官方 Snyk Action（GitHub Actions）跟 Jenkins / GitLab CI / CircleCI plugin 是 wrapper。release gate 推薦在 build 後跑 <code>snyk test --severity-threshold=high --fail-on=upgradable</code>、只擋 <em>可升級</em> 的 high+ vuln（無 fix 的 vuln 阻塞 release 沒意義、走 <em>.snyk policy</em> 暫時 ignore + alert）。</p>
<p><strong>SBOM export</strong>：<code>snyk sbom --format=cyclonedx1.4+json</code> / <code>--format=spdx2.3+json</code> 產 SBOM、支援 Snyk attestation（signed SBOM）。近年 supply chain compliance（US EO 14028、EU NIS2 / CRA）要求 SBOM、Snyk 是自動產線之一。SBOM 應該在 <em>release artifact 旁</em> 一起發布、走 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">supply chain integrity</a> 流程。</p>
<p><strong>License compliance</strong>：除了漏洞、Snyk 也掃 dependency license（GPL / AGPL / LGPL / proprietary / unknown）、可設 <em>license policy</em>（allow / disallow / require-review）、PR 引入違規 license 直接 fail check。對需要避開 copyleft license 的商業產品、license scan 跟 vulnerability scan 一樣關鍵。</p>
<p><strong>API token 治理</strong>：CI / 第三方 integration 用 <em>Service Account + scoped token</em>（限 Organization、限 permission）、不要用個人 personal token（離職就失效）。Token 進 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a> / <a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a> / <a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a>、定期 rotate。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Snyk</th>
          <th>GitHub Advanced Security</th>
          <th>Trivy</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>部署模型</td>
          <td>商業 SaaS</td>
          <td>GitHub 整合 SaaS</td>
          <td>OSS、self-hosted CLI</td>
      </tr>
      <tr>
          <td>SCM 範圍</td>
          <td>跨 SCM（GitHub / GitLab / Bitbucket / Azure Repos）</td>
          <td>GitHub only</td>
          <td>SCM 無關（CI / local 跑）</td>
      </tr>
      <tr>
          <td>SCA</td>
          <td>Snyk Open Source（含 Reachability）</td>
          <td>Dependabot（純 manifest 比對）</td>
          <td>是、限 OS package + language package</td>
      </tr>
      <tr>
          <td>SAST</td>
          <td>Snyk Code（fast inline）</td>
          <td>CodeQL（dataflow query）</td>
          <td>否</td>
      </tr>
      <tr>
          <td>Container scan</td>
          <td>Snyk Container</td>
          <td>透過 Dependabot + 第三方</td>
          <td>Trivy Container（主打）</td>
      </tr>
      <tr>
          <td>IaC scan</td>
          <td>Snyk IaC</td>
          <td>透過 Code Scanning + KICS / Checkov</td>
          <td>Trivy Config（主打）</td>
      </tr>
      <tr>
          <td>CSPM</td>
          <td>Snyk Cloud</td>
          <td>無</td>
          <td>無</td>
      </tr>
      <tr>
          <td>Reachability</td>
          <td>有（限部分語言）</td>
          <td>部分 CodeQL query 有</td>
          <td>無</td>
      </tr>
      <tr>
          <td>Auto-fix PR</td>
          <td>Snyk PR + fix advice</td>
          <td>Dependabot PR</td>
          <td>無</td>
      </tr>
      <tr>
          <td>計費模型</td>
          <td>按 Project（manifest）數</td>
          <td>GitHub seat-based</td>
          <td>免費</td>
      </tr>
      <tr>
          <td>學習曲線</td>
          <td>中 — UI 友善、CLI 直觀</td>
          <td>低 — 跟 GitHub 一體</td>
          <td>低 — 單一 binary、CLI 為主</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>多 SCM + 多 stack + 想統一 dashboard</td>
          <td>純 GitHub + 想跟 PR 深整合</td>
          <td>純 container / IaC + 想 OSS + 預算敏感</td>
      </tr>
  </tbody>
</table>
<p>選 Snyk 的核心訴求：<em>組織用多個 SCM 或多技術棧（後端 + 前端 + container + Terraform + cloud）</em> + 需要 <em>統一 dashboard + 跨團隊 prioritization</em> + 接受按 Project 計費的成本。純 GitHub 組織用 GHAS 更整合、純 container CI 用 Trivy 免費、極大型 monorepo 用 Snyk 容易爆 Project 數要小心。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Snyk Cloud (CSPM) 跟 IaC drift detection</strong>：Snyk Cloud 連 AWS / Azure / GCP read-only role、掃 runtime 配置（S3 bucket public、IAM over-permission、security group 0.0.0.0/0）對 CIS Benchmark + custom policy。跟 <em>Snyk IaC</em> 結合做 <em>drift detection</em> — Terraform 內定義是 private bucket、但 cloud 實際是 public（有人 console 手改）、Snyk 報 drift。對標 <a href="https://www.wiz.io/">Wiz</a> / Prisma Cloud / Lacework、Snyk Cloud 是 <em>跟 Snyk IaC 同源治理</em> 的優勢（同個 dashboard 看 IaC + runtime）。</p>
<p><strong>Custom Rule（Snyk IaC custom policy）</strong>：Snyk IaC 預設規則庫覆蓋 CIS Benchmark + AWS / GCP / Azure 最佳實踐、可寫 <em>custom policy</em>（Rego-like / SnykIQL）擴展。例：禁止 RDS 沒開 encryption-at-rest、禁止 S3 沒 versioning、禁止 K8s pod 跑 hostNetwork。Custom policy 走版控（git）跟 PR review、避免在 console 直接改。</p>
<p><strong>Reachability vs 純 static SCA</strong>：純 SCA（如 Dependabot / Trivy）只看 <em>manifest 中聲明的版本是否有 CVE</em>、不分 reachable / unreachable。結果是 Critical / High alert 大量、開發者 <em>alert fatigue</em> 後直接 ignore。Snyk Reachability 用 SAST + SCA 整合做 call graph、過濾掉 <em>vulnerable lib 載入了但 vulnerable 函式從未被呼叫</em> 的案例。限制：dynamic dispatch / reflection / 動態載入 plugin / native binding 都會讓 reachability 判斷失準、不可當成 binary truth。</p>
<p><strong>Snyk Insights（風險優先級 prioritization）</strong>：除了 CVSS、Snyk 加入 <em>exploit maturity</em>（exploit in-the-wild / PoC / no known exploit）、<em>fix availability</em>（有無 fix version）、<em>social trend</em>（CVE 被討論度）、<em>Reachability</em> 綜合算 <em>Priority Score</em>。production 用 Priority Score 排 backlog、而非單純 CVSS — 一個 <em>Critical 但 unreachable + no fix</em> 的 vuln 不該擋 release。</p>
<p><strong>SBOM 流程整合</strong>：把 <code>snyk sbom</code> 接到 CI release step、SBOM artifact 跟 release binary 一起進 registry / object store、走 <a href="https://in-toto.io/">in-toto attestation</a> 或 <a href="https://slsa.dev/">SLSA</a> provenance 流程、合規時可回溯。跟 <a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft + Grype</a> 流程的差異：Syft + Grype 是 OSS local-first + Unix philosophy、Snyk 是 SaaS、SBOM 含 Snyk Issue ID 跟 fix advice link。</p>
<p><strong>License policy enforcement</strong>：除了 vulnerability、license 違規（GPL / AGPL 引入到 proprietary product、unknown license dep）走同套 policy / PR fail-check 機制、production 應該把 license policy 跟 vulnerability policy 並列當 release gate。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>Project 暴量計費</strong>：monorepo 自動 import 把 test fixture / node_modules-vendored 全當 Project — 用 <em>.snyk</em> 跟 import filter 排除、archived project 確認真的不計費</li>
<li><strong>Reachability 漏判 / 誤判</strong>：dynamic dispatch / reflection / plugin load 讓 call graph 失準、Critical vuln 被標 unreachable 但實際 reachable — 對 framework-heavy code（Spring / Django middleware / Rails initializer）保守處理、不全信 Reachability</li>
<li><strong>PR noise</strong>：Snyk + Dependabot 同時開、依賴升級 PR 翻倍 — 二選一、或讓 Snyk 處理 vuln-driven upgrade、Dependabot 處理 routine version bump</li>
<li><strong>CI fail-on 設不對</strong>：<code>--severity-threshold=low</code> 把 release 整個擋死 / <code>--severity-threshold=critical</code> 漏 high — production 通常 <code>--severity-threshold=high --fail-on=upgradable</code>、再用 <code>.snyk</code> policy file 例外管理</li>
<li><strong>License check 誤殺</strong>：transitive dep 引入 LGPL 被當 GPL 阻擋 — 細分 license policy（allow LGPL-with-dynamic-linking、disallow GPL）、走 review workflow 而非 fail-fast</li>
<li><strong>API token over-scoped</strong>：CI 拿到 admin-level Service Account token、整 org Project 都能改 — 改 scoped token、限 Organization + 限 permission、進 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a></li>
<li><strong>SBOM 沒進 release pipeline</strong>：SBOM 只在 Snyk dashboard、release artifact 沒附 — 把 <code>snyk sbom</code> 加進 CI release step、SBOM 跟 binary 一起發</li>
<li><strong>Snyk Cloud drift 沒人看</strong>：CSPM alert 進 dashboard 但沒 routing 到 on-call — 接 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">SIEM</a> / Slack / PagerDuty、高 severity drift 觸發 ticket</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>純 GitHub + 想跟 PR / Action 深整合</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a></td>
      </tr>
      <tr>
          <td>純 container / IaC + OSS + 預算敏感</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a></td>
      </tr>
      <tr>
          <td>純 dependency 升級（routine version bump）</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a></td>
      </tr>
      <tr>
          <td>Secret scanning（leaked API key in repo）</td>
          <td>GitGuardian / Gitleaks（Snyk 不主打）</td>
      </tr>
      <tr>
          <td>Runtime container threat detection</td>
          <td>Falco / Cilium Tetragon</td>
      </tr>
      <tr>
          <td>深度 SAST（dataflow query / taint analysis）</td>
          <td>CodeQL / Semgrep（Snyk Code 偏 fast inline、深度查走 CodeQL）</td>
      </tr>
      <tr>
          <td>CSPM 跨 multi-cloud + asset inventory</td>
          <td>Wiz / Prisma Cloud / Lacework（Snyk Cloud 較新、功能仍在追）</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>Snyk 完整 pricing tier（Team / Business / Enterprise）跟 Project 計費細節</li>
<li>Snyk Vulnerability DB 跟 NVD / GHSA 的覆蓋差異對照</li>
<li>Snyk Code SAST 規則完整 reference</li>
<li>Snyk IaC 內建 policy 完整列表 + CIS Benchmark 對照</li>
<li>Snyk Cloud 多雲 onboarding 步驟（AWS / Azure / GCP read-only role 設置）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>Snyk 在 07 案例庫沒有直接 vendor-level 事件、但多個 supply chain 案例展示 Snyk 工具能力的 <em>範圍跟邊界</em>：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Snyk 的關係</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/log4shell-cve-2021-44228-component-chain/" data-link-title="7.R7.2.7 Log4Shell 2021：共用元件風險與修補鏈" data-link-desc="共用元件漏洞如何同步影響多服務，並迫使團隊建立依賴治理 workflow">Log4Shell CVE-2021-44228</a></td>
          <td>對照啟示 — Reachability analysis 能快速回答「我的 service 是否真用到 vulnerable JndiLookup」、減少 emergency triage 的 noise</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024 Open Source Supply Chain</a></td>
          <td>對照啟示 — Snyk 看 package version + CVE、看不到 maintainer takeover；需補 release-tarball 比對 + maintainer trust signal</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/3cx-2023-desktopapp-supply-chain/" data-link-title="7.R7.2.8 3CX 2023：桌面軟體更新鏈攻擊" data-link-desc="合法更新流程被植入後，桌面端供應鏈事件如何傳到企業端點">3CX 2023 Desktop App Supply Chain</a></td>
          <td>對照啟示 — Snyk Container 看 image 內 package CVE、看不到 update channel 被植入；需配合 artifact provenance / SLSA</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></td>
          <td>章節對應 — Snyk SBOM + License policy 是 supply chain governance 的工具、合規門檻（EO 14028 / NIS2）的標準產線之一</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a>、<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>、<a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a></li>
<li>下游：<a href="/blog/backend/07-security-data-protection/data-protection-and-masking-governance/" data-link-title="7.4 資料保護與遮罩治理" data-link-desc="以問題驅動方式整理資料分級、遮罩、匯出與備份治理">7.4 資料保護與遮罩治理</a>（vuln 阻擋不完全時、資料層也要遮罩）</li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a>、<a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a>（Snyk API token 存放）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（Critical CVE 揭露時的 emergency triage routing）</li>
<li>官方：<a href="https://docs.snyk.io/">Snyk Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>Dependabot</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/dependabot/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/dependabot/</guid><description>&lt;p>Dependabot 是 GitHub 內建的 &lt;em>依賴更新自動化&lt;/em> 工具、原為 Dependabot Inc.、2019 年被 GitHub 收購後改為 GitHub native feature、目前 public repo 免費、private repo 部分功能 (Alerts / Security Update) 也免費、Version Update 跟進階治理納入 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security&lt;/a> 套餐。它做三件事：&lt;em>Dependabot version updates&lt;/em>（定期 PR 升級依賴到最新 compatible 版本）、&lt;em>Dependabot security updates&lt;/em>（CVE 觸發的緊急 PR 升級到 fix version）、&lt;em>Dependabot alerts&lt;/em>（看到漏洞列在 Security tab、不一定自動 PR）。它的設計目標 &lt;em>狹窄而深&lt;/em> — 只做 GitHub repo 的依賴 PR 自動化、不做容器掃描、不做 IaC 掃描、不跨 SCM。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Dependabot 的核心定位是 &lt;em>把依賴升級從人工 ritual 變成 PR review 工作流&lt;/em>。它把「找新版」「跑 manifest update」「開 PR」「附 release note」自動化、剩下的 &lt;em>是否合併&lt;/em> 留給人類 / CI 判斷。這跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &amp;#43; Code (SAST) &amp;#43; Container &amp;#43; IaC &amp;#43; Cloud (CSPM)、Reachability analysis">Snyk&lt;/a> 看似重疊 — 兩者都會自動發升級 PR — 但 Snyk 是 &lt;em>跨 SCM + 多 stack&lt;/em>（GitHub / GitLab / Bitbucket、SCA + 容器 + IaC + Code）、Dependabot 是 &lt;em>GitHub-only + 純依賴&lt;/em>。多數組織選一個、混用兩者會在同一個 manifest 上各自開 PR、造成 noise。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS&lt;/a> 的關係比較細：Dependabot Alerts 跟 Security Updates 本身是 GHAS &lt;em>Dependabot&lt;/em> 子模組的核心、但功能上 &lt;em>Alerts 對所有 repo 免費&lt;/em>、Security Update 也免費自動發 PR、Version Update 也免費；GHAS 提供的是 &lt;em>Dependency Review&lt;/em>（PR-time gate、阻擋 PR 引入新漏洞依賴）、&lt;em>Security Overview&lt;/em>（org-wide dashboard）跟 enterprise-level 控制。Dependabot 是 &lt;em>background PR 工廠&lt;/em>、GHAS Dependency Review 是 &lt;em>PR-time blocker&lt;/em>、兩者互補不重疊。&lt;/p></description><content:encoded><![CDATA[<p>Dependabot 是 GitHub 內建的 <em>依賴更新自動化</em> 工具、原為 Dependabot Inc.、2019 年被 GitHub 收購後改為 GitHub native feature、目前 public repo 免費、private repo 部分功能 (Alerts / Security Update) 也免費、Version Update 跟進階治理納入 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a> 套餐。它做三件事：<em>Dependabot version updates</em>（定期 PR 升級依賴到最新 compatible 版本）、<em>Dependabot security updates</em>（CVE 觸發的緊急 PR 升級到 fix version）、<em>Dependabot alerts</em>（看到漏洞列在 Security tab、不一定自動 PR）。它的設計目標 <em>狹窄而深</em> — 只做 GitHub repo 的依賴 PR 自動化、不做容器掃描、不做 IaC 掃描、不跨 SCM。</p>
<h2 id="服務定位">服務定位</h2>
<p>Dependabot 的核心定位是 <em>把依賴升級從人工 ritual 變成 PR review 工作流</em>。它把「找新版」「跑 manifest update」「開 PR」「附 release note」自動化、剩下的 <em>是否合併</em> 留給人類 / CI 判斷。這跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> 看似重疊 — 兩者都會自動發升級 PR — 但 Snyk 是 <em>跨 SCM + 多 stack</em>（GitHub / GitLab / Bitbucket、SCA + 容器 + IaC + Code）、Dependabot 是 <em>GitHub-only + 純依賴</em>。多數組織選一個、混用兩者會在同一個 manifest 上各自開 PR、造成 noise。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS</a> 的關係比較細：Dependabot Alerts 跟 Security Updates 本身是 GHAS <em>Dependabot</em> 子模組的核心、但功能上 <em>Alerts 對所有 repo 免費</em>、Security Update 也免費自動發 PR、Version Update 也免費；GHAS 提供的是 <em>Dependency Review</em>（PR-time gate、阻擋 PR 引入新漏洞依賴）、<em>Security Overview</em>（org-wide dashboard）跟 enterprise-level 控制。Dependabot 是 <em>background PR 工廠</em>、GHAS Dependency Review 是 <em>PR-time blocker</em>、兩者互補不重疊。</p>
<p>跟 <a href="https://docs.renovatebot.com/">Renovate</a>（Mend 維護的 OSS）的差異：Renovate 配置更彈性、跨 SCM、支援 ecosystem 數量多（含 Helm chart、Docker tag、ArgoCD 等）、Grouped Updates 規則更細；Dependabot 整合 GitHub 原生 UI（Security tab、Dependency graph、PR diff）更深、設定簡單。需要 <em>跨 SCM</em> 或 <em>Helm / ArgoCD / 自訂 ecosystem</em> 走 Renovate；單純 GitHub-only 加 npm / Maven / pip 等主流 ecosystem、Dependabot 配置成本更低。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>Dependabot 在 supply chain 防護裡承擔哪一段（背景 PR 升級）、哪些不在它責任內（容器掃描、IaC 掃描、PR-time gate）</li>
<li><code>dependabot.yml</code> 的關鍵配置面：ecosystem、schedule、open-pull-requests-limit、groups、reviewers</li>
<li>Version Update vs Security Update vs Alerts 三個功能何時開、PR noise 怎麼控制</li>
<li>Auto-merge 政策的邊界：哪種更新可以全自動、哪種要保留 human approval</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷一個 repo 的 Dependabot 配置是否健康、最少看四件事：</p>
<ul>
<li><strong><code>dependabot.yml</code> 配置</strong>：repo 是否有 <code>.github/dependabot.yml</code>、ecosystem 是否覆蓋所有 manifest（npm / Maven / pip / Docker / GitHub Actions / Terraform）、<code>directory</code> 路徑對不對（monorepo 各 sub-package 是否獨立配置）</li>
<li><strong>Update Schedule</strong>：<code>schedule.interval</code> 是 daily / weekly / monthly、<code>open-pull-requests-limit</code> 是否合理（預設 5、太低會卡住 backlog、太高會 PR noise）、Grouped Updates 是否啟用（減少 minor / patch PR 數量）</li>
<li><strong>Auto-merge 政策</strong>：branch protection 是否設「CI green + required reviewer」、auto-merge 是否限定 <em>patch + minor</em> 自動、<em>major</em> 強制 human review、production 跟 staging branch 是否有差異化規則</li>
<li><strong>Token 治理</strong>：repo secrets 是否被 Dependabot PR 誤用、Dependabot secrets（私有 registry credential）是否獨立配置、PR 觸發的 Actions 是否假設 read-only token</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">Supply Chain Integrity</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong><code>dependabot.yml</code> 是版控的配置檔</strong>：放在 <code>.github/dependabot.yml</code>、跟 manifest 同 repo、所有變更走 PR review。不在 GitHub UI 直接改 — UI 只能 <em>啟用 / 停用</em> Dependabot 本身、細節必須 commit 進 repo。Monorepo 結構（例：<code>/services/api</code>、<code>/services/web</code> 各自 <code>package.json</code>）每個 sub-package 寫一個 entry、<code>directory</code> 指到 sub-package 根目錄、<code>package-ecosystem</code> 標 manifest 類型。<code>schedule.interval</code> 一般 weekly 開始、daily 適合高活躍度團隊但 PR noise 高、monthly 適合穩定 lib 但 CVE 延遲風險高。</p>
<p><strong>Version Update vs Security Update 分開</strong>：Version Update 是 <em>定期掃 manifest 看有沒有 newer compatible 版本</em>、不分 CVE、是 hygiene 工作；Security Update 是 <em>Dependabot 偵測到 CVE 且 manifest 指到 vulnerable 範圍時自動發 PR 升級到 fix version</em>、是 incident 工作。多數組織開 Security Update 全 repo + 選擇性開 Version Update（核心服務開、archived repo 不開）— 避免 PR noise 淹沒緊急 PR。Security Update 預設啟用、Version Update 要 explicit 在 <code>dependabot.yml</code> 寫 entry 才會跑。</p>
<p><strong>Grouped Updates</strong>：2023 推出、單一 PR 含多個 minor / patch 升級（例：一個 PR 升 10 個 npm package）、PR 數量從 10 個降到 1 個。配置在 <code>dependabot.yml</code> 的 <code>groups</code> 區、可以按 dependency name pattern（例：<code>@types/*</code> 一組、<code>eslint*</code> 一組）或 update-type（<code>patch</code> / <code>minor</code> 分組）。Major version 仍分開 PR — 因 breaking change 風險、需要單獨 review。Grouped Updates 配 auto-merge 是 <em>minor / patch 全自動</em> 的標準配置。</p>
<p><strong>Auto-merge 是 PR 級、不是 commit 級</strong>：Dependabot 發 PR、搭配 GitHub branch protection 設「CI green + 1 approver」就 auto-merge — GitHub <code>gh pr merge --auto</code> 或 Actions workflow（<code>peter-evans/enable-pull-request-automerge</code>）都行。production 環境應該保留 human approval（至少對 major version）、staging / dev 可以全自動。常見模式：staging branch 全自動合（patch + minor）+ 自動 deploy；production branch 走 staging → cherry-pick / promote 流程、human approve。</p>
<p><strong>Reviewer / Assignee / Label 自動標記</strong>：<code>dependabot.yml</code> 的 <code>reviewers</code> / <code>assignees</code> / <code>labels</code> 欄位讓 Dependabot 開 PR 時自動標 reviewer 跟 label。實務上配 <code>labels: [&quot;dependencies&quot;]</code> 讓 Dependabot PR 在 PR list 跟一般 feature PR 分開、CI workflow 可以針對 <code>dependencies</code> label 跑特化 lint（例：跑完整 e2e、不只 unit test）。</p>
<p><strong>Token 治理</strong>：Dependabot PR 跑 GitHub Actions 時、<code>secrets.GITHUB_TOKEN</code> 是 <em>read-only</em>（GitHub 設計上限制、防 PR 觸發 supply chain attack）— 這代表 Dependabot PR 不能跑需要 write permission 的 job（推 image / 改 status / comment）。需要的話用 <code>pull_request_target</code> event（用 base branch 的 workflow + 完整 secrets）、但這也是 supply chain attack 高風險面、必須 <em>最少 permission</em>。私有 registry credential（npm private registry token、Maven private repo password）用 <em>Dependabot secrets</em>（org / repo level）配置、跟 GitHub Actions secrets 是 <em>不同 namespace</em>、不會互相讀到。</p>
<p><strong>跟 GHAS Dependency Review 搭配</strong>：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Dependency Review</a> 在 PR-time 看 manifest diff 阻擋 <em>引入新漏洞依賴</em>、Dependabot Security Update 在 background <em>升級舊有漏洞依賴</em>、兩個方向互補。production repo 標準配置：GHAS Dependency Review 設 high severity block + Dependabot Security Update 全開 + Dependabot Version Update 選擇性開。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Dependabot</th>
          <th>Snyk</th>
          <th>Renovate</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SCM 範圍</td>
          <td>GitHub only</td>
          <td>GitHub / GitLab / Bitbucket / Azure DevOps</td>
          <td>GitHub / GitLab / Bitbucket / Azure DevOps / Gitea</td>
      </tr>
      <tr>
          <td>涵蓋面</td>
          <td>純依賴（SCA）</td>
          <td>SCA + 容器 + IaC + Code</td>
          <td>純依賴（SCA）+ Docker tag / Helm / 自訂</td>
      </tr>
      <tr>
          <td>Ecosystem 數量</td>
          <td>主流（npm / Maven / pip / Docker / Actions / Terraform 等 20+）</td>
          <td>主流相近 + 商業資料庫優先</td>
          <td>多（含 Helm / ArgoCD / preCommit / 自訂 regex）</td>
      </tr>
      <tr>
          <td>Grouped Updates</td>
          <td>有（2023+、按 pattern / update-type）</td>
          <td>有（按 type）</td>
          <td>有（規則最細、按 manager / depType / pattern）</td>
      </tr>
      <tr>
          <td>Auto-merge</td>
          <td>走 GitHub branch protection + auto-merge</td>
          <td>Snyk 自家 PR + 走 SCM auto-merge</td>
          <td>內建 <code>automerge</code> 配置、規則細</td>
      </tr>
      <tr>
          <td>漏洞資料庫</td>
          <td>GitHub Advisory Database（公開 + 私有）</td>
          <td>Snyk Intel（商業、揭露快、加入專屬 advisory）</td>
          <td>OSV / NVD / GitHub Advisory（聚合）</td>
      </tr>
      <tr>
          <td>PR 整合深度</td>
          <td>GitHub Security tab / Dependency graph 原生</td>
          <td>Snyk UI 為主、SCM PR 是延伸</td>
          <td>SCM PR 原生、Renovate dashboard issue 集中管理</td>
      </tr>
      <tr>
          <td>設定方式</td>
          <td><code>dependabot.yml</code>（簡單）</td>
          <td>UI + <code>.snyk</code> policy file（漏洞例外）</td>
          <td><code>renovate.json</code>（極彈性、配置複雜）</td>
      </tr>
      <tr>
          <td>商業成本</td>
          <td>GitHub 免費（Version Update / Security Update / Alerts 都免費）</td>
          <td>商業授權（含免費 tier、規模上來付費）</td>
          <td>OSS 免費、Mend 商業版加分析 dashboard</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>GitHub-only + 純依賴 + 設定要簡單</td>
          <td>跨 SCM、要容器 / IaC、商業 advisory 加值</td>
          <td>跨 SCM 或要 Helm / ArgoCD / 自訂 ecosystem</td>
      </tr>
  </tbody>
</table>
<p>選 Dependabot 的核心訴求：<em>GitHub-only</em> + 只要依賴 PR 自動化、不要容器 / IaC scan、配置成本要低、整合 GitHub Security tab。要跨 SCM 或多 stack 走 Snyk、要彈性 ecosystem / Helm chart / ArgoCD 走 Renovate。混用 Dependabot + Snyk 對同一 manifest 自動 PR 會 noise、二選一。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Multi-ecosystem repo</strong>：一個 repo 同時有 npm + Docker + Terraform + GitHub Actions、<code>dependabot.yml</code> 寫四個 entry、各自 schedule。實務常見配置：application 依賴（npm / pip）weekly、base image（Docker）weekly、IaC（Terraform provider）monthly、GitHub Actions（CI workflow）weekly。Actions ecosystem 要特別注意 — Dependabot 升級 <code>uses:</code> 指向的 action version、可以同時 pin commit hash（防 tag re-publish 攻擊）、但 pin hash 後 release note 看不到 — 取捨 <em>安全 vs 可讀性</em>。</p>
<p><strong>Private registry support</strong>：私有 npm registry（GitHub Packages / Artifactory / Nexus）、私有 Maven repo、私有 PyPI mirror、私有 container registry 都要在 <code>dependabot.yml</code> 配置 <code>registries</code> 區、credential 走 Dependabot secrets。Dependabot 從私有 registry 抓 package metadata 跟 release info、否則只能看 public registry、會誤判 internal lib 沒新版。Org-level Dependabot secrets 適合共用 credential、repo-level 適合特殊 credential 隔離。</p>
<p><strong>Self-hosted runner 隔離</strong>：Dependabot PR 觸發的 Actions 預設跑在 GitHub-hosted runner、跟 Dependabot 本身的 sandbox 不同。如果 CI 跑在 self-hosted runner（內網資源 / 大 build cache）、Dependabot PR 也會跑在 self-hosted runner — 要確認 runner 不會被 PR 注入的惡意 manifest 攻擊（npm install 跑 postinstall script 是經典攻擊路徑）。Mitigation：Dependabot PR 用 ephemeral runner（每次新 VM）、隔離 build cache、不掛 sensitive volume。</p>
<p><strong>Auto-merge 風險</strong>：auto-merge 加速合併、但也放寬 <em>攻擊者升級 dep 攻擊我</em> 的窗口。<a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a> 的攻擊路徑就是攻擊者花兩年取得 upstream maintainer 信任、發 release 帶 backdoor — 如果下游 auto-merge 升級、攻擊就直達 production。Mitigation：major version 永不 auto-merge、critical infra dep（auth / crypto / network 函式庫）pin commit hash + 手動 review、auto-merge 範圍縮到 patch + minor + low-criticality dep。</p>
<p><strong>GitHub Actions 跟 Dependabot 互動</strong>：Dependabot PR 觸發的 workflow 預設 <code>GITHUB_TOKEN</code> 是 <em>read-only</em>、<code>secrets.*</code> 是 <em>empty</em>（Dependabot context）— 防止 PR 注入腳本竊取 secret。需要在 Dependabot PR 跑帶 secret 的 job、用 <code>pull_request_target</code> event（workflow 從 base branch 取、有完整 secret）— 但這會 <em>讀 PR 的 code 跑 workflow</em>、必須先 <code>checkout</code> base 然後最小化 PR code 的執行（不跑 PR 的 install script、只跑既有 lint）。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>PR noise 淹沒緊急 PR</strong>：Version Update 全開 + 沒 Grouped Updates、一週 30+ PR — 啟用 <code>groups</code> 按 pattern 分組（<code>@types/*</code> / <code>eslint*</code> / <code>dev-dependencies</code>）、<code>open-pull-requests-limit</code> 設 5、archived repo 關 Version Update</li>
<li><strong>Security Update 沒發 PR</strong>：CVE 公告了但 Dependabot 沒動 — 確認 manifest 真的指到 vulnerable 範圍、<code>dependabot.yml</code> 沒 <code>ignore</code> 該 dependency、Security Updates 在 repo settings 是啟用、Dependency graph 有抓到該 manifest</li>
<li><strong>私有 registry 抓不到</strong>：Dependabot 在私有 npm / Maven repo 失敗 — <code>dependabot.yml</code> 配 <code>registries</code> 區、credential 進 Dependabot secrets（不是 Actions secrets）、URL 跟 token 範圍對齊</li>
<li><strong>Auto-merge 不觸發</strong>：PR 開了 CI 也綠了但沒合 — 確認 branch protection required check 跟 CI workflow 名稱對齊、<code>gh pr merge --auto</code> 在 PR comment / workflow 有觸發、reviewer count 達標</li>
<li><strong>Dependabot PR 跑 Actions 失敗</strong>：PR 的 workflow 報 permission denied — <code>GITHUB_TOKEN</code> 在 Dependabot context read-only、改用 <code>pull_request_target</code> 或拆 job（push secret 的部分跑在 merge 後 main branch event）</li>
<li><strong>Major version 被 auto-merge</strong>：規則沒寫對、major 也自動合進 production — <code>dependabot.yml</code> 的 <code>ignore</code> 加 <code>update-types: [&quot;version-update:semver-major&quot;]</code> 或 auto-merge 條件改 <code>${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }}</code></li>
<li><strong>Monorepo 漏掃</strong>：<code>/services/api/package.json</code> 沒掃 — <code>dependabot.yml</code> 每個 sub-package 寫一個 entry、<code>directory</code> 指到正確路徑、不是只在 root 一個 entry</li>
<li><strong>GitHub Actions ecosystem 升級拿掉 commit hash pin</strong>：原本 <code>uses: actions/checkout@a12b3c4</code> 被升成 <code>uses: actions/checkout@v5</code> — Dependabot 會 follow 既有 reference 風格、想要 hash pin 設 <code>dependabot.yml</code> 的 ecosystem-level config 但目前限制較多、實務常另用 <a href="https://github.com/suzuki-shunsuke/pinact">pinact</a> 或 Renovate 處理 Actions hash pinning</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>跨 SCM（GitLab / Bitbucket）</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> / <a href="https://docs.renovatebot.com/">Renovate</a></td>
      </tr>
      <tr>
          <td>容器 / IaC scan</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> / <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a></td>
      </tr>
      <tr>
          <td>Helm / ArgoCD / 自訂 ecosystem</td>
          <td><a href="https://docs.renovatebot.com/">Renovate</a></td>
      </tr>
      <tr>
          <td>PR-time block 引入新漏洞</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Dependency Review</a></td>
      </tr>
      <tr>
          <td>SAST / Code scanning</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Code Scanning</a> / <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk Code</a></td>
      </tr>
      <tr>
          <td>SBOM 生成 / 簽章</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft / Grype</a>（含 Sigstore cosign 整合段落）</td>
      </tr>
      <tr>
          <td>Secret scanning</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> / GitGuardian</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li><code>dependabot.yml</code> 完整欄位 reference（看 <a href="https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file">GitHub 官方文件</a>）</li>
<li>GitHub Advisory Database 詳細運作（CVE 來源、curation 流程）</li>
<li>GHAS 其他模組（Code Scanning / Secret Scanning / Dependency Review）細節 — 看 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS 頁</a></li>
<li>Renovate / Snyk 完整配置 — 看各自 vendor 頁</li>
<li>Container base image 升級的 multi-stage Dockerfile 處理</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>Dependabot 沒有自身 vendor-level case、但在 supply chain case 中是 <em>標準 mitigation</em> 或 <em>風險面</em>：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Dependabot 的關係</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/log4shell-cve-2021-44228-component-chain/" data-link-title="7.R7.2.7 Log4Shell 2021：共用元件風險與修補鏈" data-link-desc="共用元件漏洞如何同步影響多服務，並迫使團隊建立依賴治理 workflow">Log4Shell CVE-2021-44228</a></td>
          <td>對照啟示 — Dependabot Security Update 在 Log4Shell 期間自動發 log4j-core 升級 PR、auto-merge 必須有 functional + security 雙重 CI verify、不能單看 build pass</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a></td>
          <td>對照啟示 — Dependabot 自己用 GitHub token、需確認 Dependabot PR 不能讀 production secrets（GitHub 設計上已 read-only / empty secrets）</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a></td>
          <td>對照啟示 — CI 出事時 Dependabot secrets（私有 registry credential）也要 rotate、不是只 rotate Actions secrets</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a></td>
          <td>對照啟示 — Dependabot auto-merge 隱含 maintainer trust、攻擊者控制 upstream 後升級 = 自動進 production；major 不 auto-merge + 重要 dep pin commit hash</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a>、<a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a></li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（容器 scan）、<a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft / Grype</a>（SBOM）</li>
<li>跨類：artifact 簽章（Sigstore cosign）見 <a href="/blog/backend/07-security-data-protection/vendors/syft-grype/" data-link-title="Syft &#43; Grype" data-link-desc="Anchore 開源姐妹工具：Syft 產 SBOM (CycloneDX / SPDX) &#43; Grype scan 漏洞、Unix philosophy、cosign attestation 整合">Syft / Grype 頁的 SBOM attestation 段</a></li>
<li>跨模組：<a href="/blog/backend/06-reliability/" data-link-title="模組六：可靠性驗證流程" data-link-desc="用 SRE 領域詞彙建問題節點、以服務級案例庫累積驗證脈絡，先建概念與案例庫再進實作交接">6 可靠性驗證流程</a>（Dependabot PR 進 release flow 的 gate 設計）、<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a></li>
<li>官方：<a href="https://docs.github.com/en/code-security/dependabot">Dependabot Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>模組六：本地 LLM 的安全與權限</title><link>https://tarrragon.github.io/blog/llm/06-security/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/llm/06-security/</guid><description>&lt;p>本模組的核心目標是把「個人 dev 在自己機器上跑本地 LLM 寫 code」這條工作流上會碰到的安全議題拆成可操作的判讀。跟 &lt;a href="https://tarrragon.github.io/blog/llm/01-local-llm-services/" data-link-title="模組一：本地 LLM 服務的安裝與應用" data-link-desc="Ollama、LM Studio、llama.cpp 的安裝與差異、VS Code &amp;#43; Continue.dev 整合、模型選型與期望管理">模組一&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/llm/05-discrete-gpu/" data-link-title="模組五：Windows / Linux &amp;#43; 獨立 GPU" data-link-desc="消費級 PC（Windows / Linux &amp;#43; NVIDIA / AMD 獨立 GPU）跑本地 LLM 的硬體判讀、MoE CPU 卸載、KV cache 量化與 llama.cpp 調參">模組五&lt;/a> 是同一條讀者旅程的延伸：模組一/五處理「怎麼跑得起來」、本模組處理「跑起來後該注意什麼」。&lt;/p>
&lt;p>本模組的 framing 是&lt;strong>個人 dev 視角&lt;/strong>、不是 enterprise 資安管理視角。production LLM 服務化的特殊資安議題（多租戶 isolation、deployment 供應鏈、agent 場景 prompt injection 後果、log/PII 治理、偵測訊號）見 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/" data-link-title="模組七：資安與資料保護" data-link-desc="以問題驅動方式擴充資安知識網：先定義服務環節問題，再以案例作為觸發式參考">Backend 模組七 資安與資料保護&lt;/a> 的 LLM 相關章節。&lt;/p>
&lt;h2 id="本模組的責任範圍">本模組的責任範圍&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>處理&lt;/th>
 &lt;th>不處理&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>個人 dev 用本地 LLM 時的模型來源信任、推論伺服器綁定、tool use 副作用權限、IDE 場景 prompt injection、跨雲端 / 本地資料邊界&lt;/td>
 &lt;td>enterprise IAM、production audit log、合規認證、incident response 流程&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>從個人 dev 跨進 team / production 場景的 routing 中樞&lt;/td>
 &lt;td>production 多租戶推論服務 isolation、agent 場景的 prompt injection 後果（見 backend/07）&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/" data-link-title="模組七：資安與資料保護" data-link-desc="以問題驅動方式擴充資安知識網：先定義服務環節問題，再以案例作為觸發式參考">Backend 模組七 資安與資料保護&lt;/a> 的分工：本模組的 6.1 ~ 6.4 是「個人 dev 場景下的安全議題」、用到的通用資安詞彙（identity / boundary / supply chain / transport trust 等）cross-link 回 backend/07 的既有卡片、不在本模組重新定義。&lt;/p>
&lt;h2 id="章節列表">章節列表&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>章節&lt;/th>
 &lt;th>主題&lt;/th>
 &lt;th>關鍵收穫&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">6.0&lt;/a>&lt;/td>
 &lt;td>模型供應鏈與信任邊界&lt;/td>
 &lt;td>GGUF / Hugging Face / Ollama registry 信任、量化版本污染、權重完整性&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/inference-server-binding/" data-link-title="6.1 推論伺服器的綁定與暴露範圍" data-link-desc="個人 dev 場景下 llama-server / Ollama / LM Studio 的 bind address 判讀：127.0.0.1 vs LAN vs 反代、預設安全、誤開放給內網的後果">6.1&lt;/a>&lt;/td>
 &lt;td>推論伺服器的綁定與暴露範圍&lt;/td>
 &lt;td>127.0.0.1 vs 0.0.0.0 vs 反代、預設安全、誤開放給內網的後果&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/tool-use-permission-model/" data-link-title="6.2 tool use 與 MCP server 的權限模型" data-link-desc="個人 dev 場景下 tool use / MCP server 的副作用權限：檔案系統 / shell / 網路存取邊界、第三方 MCP 信任、副作用的可逆性">6.2&lt;/a>&lt;/td>
 &lt;td>tool use 與 MCP server 的權限模型&lt;/td>
 &lt;td>檔案系統 / shell / 網路存取邊界、第三方 MCP 信任、副作用的可逆性&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/prompt-injection-in-ide/" data-link-title="6.3 IDE 場景的 prompt injection" data-link-desc="個人 dev 場景下 IDE 寫 code 工作流的 prompt injection：codebase 內容、外部文件、剪貼簿作為攻擊面、跟雲端 LLM 場景的差異">6.3&lt;/a>&lt;/td>
 &lt;td>IDE 場景的 prompt injection&lt;/td>
 &lt;td>codebase 內容、外部文件、剪貼簿作為攻擊面、跟雲端 LLM 場景的差異&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/cross-cloud-local-data-boundary/" data-link-title="6.4 跨雲端 / 本地的資料邊界" data-link-desc="個人 dev 場景下混用雲端 LLM 跟本地 LLM 時的 prompt 洩漏點：Continue.dev 多 provider 設定、隱私資料流、按敏感度分流的判讀">6.4&lt;/a>&lt;/td>
 &lt;td>跨雲端 / 本地的資料邊界&lt;/td>
 &lt;td>Continue.dev 多 provider 設定、prompt 洩漏點、本地優先的判讀&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/routing-to-production-security/" data-link-title="6.5 跨進 production 的 routing 中樞" data-link-desc="個人 dev → 團隊 → production LLM 服務的三層演化、跟 backend/07 對應卡片的 routing 清單">6.5&lt;/a>&lt;/td>
 &lt;td>跨進 production 的 routing 中樞&lt;/td>
 &lt;td>個人 → 團隊 → production 三層演化、列舉 backend/07 對應卡片&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://tarrragon.github.io/blog/llm/06-security/owasp-llm-top10-mapping/" data-link-title="6.6 OWASP LLM Top 10 對照圖" data-link-desc="把模組六的本地 dev 視角安全章節對照到 OWASP LLM Top 10 2025、補出個人 dev 場景跟企業合規溝通的共同詞彙">6.6&lt;/a>&lt;/td>
 &lt;td>OWASP LLM Top 10 對照圖&lt;/td>
 &lt;td>把 6.0-6.5 對應到 OWASP LLM01-LLM10、跟企業安全溝通的共同詞彙&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="跟其他模組的關係">跟其他模組的關係&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>模組&lt;/th>
 &lt;th>關係&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>模組零&lt;/td>
 &lt;td>本模組沿用模組零的&lt;a href="https://tarrragon.github.io/blog/llm/00-foundations/privacy-data-flow/" data-link-title="0.7 隱私 / 資安的資料流原理" data-link-desc="從「位置」到「資料流」的思考升級：信任邊界、合約模型、零信任原則套用到 LLM 工作流">隱私資料流&lt;/a>框架&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>模組一 / 五&lt;/td>
 &lt;td>本模組是模組一 / 五的安全延伸；模組一/五教怎麼跑、本模組教跑起來該注意什麼&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>模組四&lt;/td>
 &lt;td>本模組 6.2 / 6.3 / 6.5 跟模組四的 &lt;a href="https://tarrragon.github.io/blog/llm/04-applications/tool-use-principles/" data-link-title="4.3 Tool use 原理：LLM 跟外部世界互動" data-link-desc="Structured output 是 LLM 跨入工程系統的橋、function calling 取捨、為什麼本地小模型 tool use 表現崩潰">tool use&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/llm/04-applications/agent-architecture/" data-link-title="4.4 Agent 架構原理" data-link-desc="Agent loop 結構、失敗模式、什麼任務適合 vs 不適合、跟人類審查的協作模型">agent&lt;/a> 章節呼應&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Backend 模組七&lt;/td>
 &lt;td>本模組引用其通用資安卡片；production 場景的 LLM-specific 議題在 backend/07 補充&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="為什麼這個順序">為什麼這個順序&lt;/h2>
&lt;p>本模組章節順序的設計脈絡：&lt;/p></description><content:encoded><![CDATA[<p>本模組的核心目標是把「個人 dev 在自己機器上跑本地 LLM 寫 code」這條工作流上會碰到的安全議題拆成可操作的判讀。跟 <a href="/blog/llm/01-local-llm-services/" data-link-title="模組一：本地 LLM 服務的安裝與應用" data-link-desc="Ollama、LM Studio、llama.cpp 的安裝與差異、VS Code &#43; Continue.dev 整合、模型選型與期望管理">模組一</a> / <a href="/blog/llm/05-discrete-gpu/" data-link-title="模組五：Windows / Linux &#43; 獨立 GPU" data-link-desc="消費級 PC（Windows / Linux &#43; NVIDIA / AMD 獨立 GPU）跑本地 LLM 的硬體判讀、MoE CPU 卸載、KV cache 量化與 llama.cpp 調參">模組五</a> 是同一條讀者旅程的延伸：模組一/五處理「怎麼跑得起來」、本模組處理「跑起來後該注意什麼」。</p>
<p>本模組的 framing 是<strong>個人 dev 視角</strong>、不是 enterprise 資安管理視角。production LLM 服務化的特殊資安議題（多租戶 isolation、deployment 供應鏈、agent 場景 prompt injection 後果、log/PII 治理、偵測訊號）見 <a href="/blog/backend/07-security-data-protection/" data-link-title="模組七：資安與資料保護" data-link-desc="以問題驅動方式擴充資安知識網：先定義服務環節問題，再以案例作為觸發式參考">Backend 模組七 資安與資料保護</a> 的 LLM 相關章節。</p>
<h2 id="本模組的責任範圍">本模組的責任範圍</h2>
<table>
  <thead>
      <tr>
          <th>處理</th>
          <th>不處理</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>個人 dev 用本地 LLM 時的模型來源信任、推論伺服器綁定、tool use 副作用權限、IDE 場景 prompt injection、跨雲端 / 本地資料邊界</td>
          <td>enterprise IAM、production audit log、合規認證、incident response 流程</td>
      </tr>
      <tr>
          <td>從個人 dev 跨進 team / production 場景的 routing 中樞</td>
          <td>production 多租戶推論服務 isolation、agent 場景的 prompt injection 後果（見 backend/07）</td>
      </tr>
  </tbody>
</table>
<p>跟 <a href="/blog/backend/07-security-data-protection/" data-link-title="模組七：資安與資料保護" data-link-desc="以問題驅動方式擴充資安知識網：先定義服務環節問題，再以案例作為觸發式參考">Backend 模組七 資安與資料保護</a> 的分工：本模組的 6.1 ~ 6.4 是「個人 dev 場景下的安全議題」、用到的通用資安詞彙（identity / boundary / supply chain / transport trust 等）cross-link 回 backend/07 的既有卡片、不在本模組重新定義。</p>
<h2 id="章節列表">章節列表</h2>
<table>
  <thead>
      <tr>
          <th>章節</th>
          <th>主題</th>
          <th>關鍵收穫</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">6.0</a></td>
          <td>模型供應鏈與信任邊界</td>
          <td>GGUF / Hugging Face / Ollama registry 信任、量化版本污染、權重完整性</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/inference-server-binding/" data-link-title="6.1 推論伺服器的綁定與暴露範圍" data-link-desc="個人 dev 場景下 llama-server / Ollama / LM Studio 的 bind address 判讀：127.0.0.1 vs LAN vs 反代、預設安全、誤開放給內網的後果">6.1</a></td>
          <td>推論伺服器的綁定與暴露範圍</td>
          <td>127.0.0.1 vs 0.0.0.0 vs 反代、預設安全、誤開放給內網的後果</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/tool-use-permission-model/" data-link-title="6.2 tool use 與 MCP server 的權限模型" data-link-desc="個人 dev 場景下 tool use / MCP server 的副作用權限：檔案系統 / shell / 網路存取邊界、第三方 MCP 信任、副作用的可逆性">6.2</a></td>
          <td>tool use 與 MCP server 的權限模型</td>
          <td>檔案系統 / shell / 網路存取邊界、第三方 MCP 信任、副作用的可逆性</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/prompt-injection-in-ide/" data-link-title="6.3 IDE 場景的 prompt injection" data-link-desc="個人 dev 場景下 IDE 寫 code 工作流的 prompt injection：codebase 內容、外部文件、剪貼簿作為攻擊面、跟雲端 LLM 場景的差異">6.3</a></td>
          <td>IDE 場景的 prompt injection</td>
          <td>codebase 內容、外部文件、剪貼簿作為攻擊面、跟雲端 LLM 場景的差異</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/cross-cloud-local-data-boundary/" data-link-title="6.4 跨雲端 / 本地的資料邊界" data-link-desc="個人 dev 場景下混用雲端 LLM 跟本地 LLM 時的 prompt 洩漏點：Continue.dev 多 provider 設定、隱私資料流、按敏感度分流的判讀">6.4</a></td>
          <td>跨雲端 / 本地的資料邊界</td>
          <td>Continue.dev 多 provider 設定、prompt 洩漏點、本地優先的判讀</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/routing-to-production-security/" data-link-title="6.5 跨進 production 的 routing 中樞" data-link-desc="個人 dev → 團隊 → production LLM 服務的三層演化、跟 backend/07 對應卡片的 routing 清單">6.5</a></td>
          <td>跨進 production 的 routing 中樞</td>
          <td>個人 → 團隊 → production 三層演化、列舉 backend/07 對應卡片</td>
      </tr>
      <tr>
          <td><a href="/blog/llm/06-security/owasp-llm-top10-mapping/" data-link-title="6.6 OWASP LLM Top 10 對照圖" data-link-desc="把模組六的本地 dev 視角安全章節對照到 OWASP LLM Top 10 2025、補出個人 dev 場景跟企業合規溝通的共同詞彙">6.6</a></td>
          <td>OWASP LLM Top 10 對照圖</td>
          <td>把 6.0-6.5 對應到 OWASP LLM01-LLM10、跟企業安全溝通的共同詞彙</td>
      </tr>
  </tbody>
</table>
<h2 id="跟其他模組的關係">跟其他模組的關係</h2>
<table>
  <thead>
      <tr>
          <th>模組</th>
          <th>關係</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>模組零</td>
          <td>本模組沿用模組零的<a href="/blog/llm/00-foundations/privacy-data-flow/" data-link-title="0.7 隱私 / 資安的資料流原理" data-link-desc="從「位置」到「資料流」的思考升級：信任邊界、合約模型、零信任原則套用到 LLM 工作流">隱私資料流</a>框架</td>
      </tr>
      <tr>
          <td>模組一 / 五</td>
          <td>本模組是模組一 / 五的安全延伸；模組一/五教怎麼跑、本模組教跑起來該注意什麼</td>
      </tr>
      <tr>
          <td>模組四</td>
          <td>本模組 6.2 / 6.3 / 6.5 跟模組四的 <a href="/blog/llm/04-applications/tool-use-principles/" data-link-title="4.3 Tool use 原理：LLM 跟外部世界互動" data-link-desc="Structured output 是 LLM 跨入工程系統的橋、function calling 取捨、為什麼本地小模型 tool use 表現崩潰">tool use</a> / <a href="/blog/llm/04-applications/agent-architecture/" data-link-title="4.4 Agent 架構原理" data-link-desc="Agent loop 結構、失敗模式、什麼任務適合 vs 不適合、跟人類審查的協作模型">agent</a> 章節呼應</td>
      </tr>
      <tr>
          <td>Backend 模組七</td>
          <td>本模組引用其通用資安卡片；production 場景的 LLM-specific 議題在 backend/07 補充</td>
      </tr>
  </tbody>
</table>
<h2 id="為什麼這個順序">為什麼這個順序</h2>
<p>本模組章節順序的設計脈絡：</p>
<ol>
<li><strong>先 6.0 模型供應鏈</strong>：模型權重是本地 LLM 的最上游、信任邊界從這裡開始；裝錯模型其他防護都沒意義。</li>
<li><strong>再 6.1 推論伺服器綁定</strong>：模型載入後、伺服器是第一個對外的接觸面；綁定錯誤是個人 dev 場景最常見的暴露點。</li>
<li><strong>接 6.2 tool use 權限</strong>：伺服器跑起來後、最大的副作用來自 tool use / MCP 對本機資源的存取。</li>
<li><strong>再 6.3 prompt injection</strong>：tool use 跟 RAG 把外部內容引入 prompt、prompt injection 才有著力點。</li>
<li><strong>然後 6.4 跨雲端 / 本地邊界</strong>：寫 code 場景常混用雲端 LLM、prompt 的洩漏軌跡要說清楚。</li>
<li><strong>最後 6.5 跨進 production</strong>：個人 dev 工作流穩了之後、若要分享給團隊或部署成服務、需要的 routing。</li>
</ol>
<h2 id="個人-dev-視角的-threat-model-預設">個人 dev 視角的 threat model 預設</h2>
<p>本模組假設的 threat model：</p>
<ol>
<li><strong>攻擊者預期</strong>：「不小心被執行的 malicious payload」（誤裝有問題的 GGUF、誤裝有問題的 MCP server、誤點到帶 prompt injection 的網頁 / 文件 / pull request），而非 nation-state APT。</li>
<li><strong>保護的 asset</strong>：本機檔案、開發中的 codebase（含未公開）、雲端 API key（OpenAI、Anthropic 等）、SSH key 與其他憑證。</li>
<li><strong>trust boundary</strong>：本機 user account 邊界、prompt 邊界、tool 副作用邊界。</li>
<li><strong>可接受風險</strong>：個人 dev 不需要 enterprise-grade audit log、IDS / IPS、SOC、紅藍隊演練；用基本權限隔離 + 預設安全配置 + 場景判讀為主。</li>
</ol>
<p>production / 多人協作場景的 threat model 完全不同、見 <a href="/blog/backend/07-security-data-protection/" data-link-title="模組七：資安與資料保護" data-link-desc="以問題驅動方式擴充資安知識網：先定義服務環節問題，再以案例作為觸發式參考">Backend 模組七</a>。</p>
<h2 id="不在本模組內的主題">不在本模組內的主題</h2>
<p>本模組不討論：</p>
<ol>
<li><strong>enterprise IAM、SSO、SAML / OIDC</strong>：個人 dev 場景用不到、屬 backend/07 <a href="/blog/backend/07-security-data-protection/identity-access-boundary/" data-link-title="7.2 身分與授權邊界" data-link-desc="以問題驅動方式整理身分、授權、會話與供應商身分鏈">identity-access-boundary</a>。</li>
<li><strong>合規認證（SOC 2、ISO 27001、HIPAA、GDPR 流程）</strong>：個人 dev 場景的隱私判讀見 6.4、企業合規流程屬 backend/07。</li>
<li><strong>detection / SIEM / SOAR</strong>：個人 dev 場景靠 OS 既有 log 跟手動觀察、企業偵測屬 backend/07 <a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">detection-coverage-and-signal-governance</a>。</li>
<li><strong>incident response 標準流程</strong>：個人 dev 場景靠快速止血 + 重置、企業 IR 流程屬 backend/07 <a href="/blog/backend/07-security-data-protection/incident-case-to-control-workflow/" data-link-title="7.16 從公開事故到工程 Workflow：案例如何回寫控制面" data-link-desc="建立公開事故如何轉成控制面失效樣式與 workflow 回寫的大綱">incident-case-to-control-workflow</a>。</li>
<li><strong>模型本身的對抗性訓練 / 後門</strong>：屬研究範疇、本模組假設用主流模型作者發布的權重作為可信起點。</li>
</ol>
]]></content:encoded></item><item><title>Syft + Grype</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/syft-grype/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/syft-grype/</guid><description>&lt;p>Syft 跟 Grype 是 Anchore 開源的 &lt;em>姐妹工具&lt;/em>（Apache 2.0、免費）、各做一件事、用 pipe 串接成 &lt;em>SBOM-first&lt;/em> 的 supply chain scan 鏈：&lt;strong>Syft&lt;/strong> 掃 container image / 檔案系統 / 目錄、產出標準 SBOM（CycloneDX 1.5+ / SPDX 2.3 / SyftJSON）；&lt;strong>Grype&lt;/strong> 吃 SBOM 或直接 scan target、比對 Grype-DB 回報 CVE。設計哲學是 Unix philosophy — &lt;code>syft image:tag -o cyclonedx-json | grype&lt;/code> 等價於 &lt;code>grype image:tag&lt;/code>、但中間的 SBOM 是 &lt;em>正式 artifact&lt;/em>、可以單獨簽章、單獨保存、單獨給下游消費。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &amp;#43; Secret &amp;#43; License &amp;#43; SBOM、Apache 2.0、CI 友善">Trivy&lt;/a> 全包式設計不同、跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &amp;#43; Code (SAST) &amp;#43; Container &amp;#43; IaC &amp;#43; Cloud (CSPM)、Reachability analysis">Snyk&lt;/a> 商業 SaaS 路線也不同。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Syft + Grype 的核心定位是 &lt;em>SBOM-first 的 OSS supply chain scan tool chain&lt;/em>。SBOM 不是中間產物、是 &lt;em>正式可簽章 artifact&lt;/em>：Syft 產 SBOM 後通常用 &lt;a href="https://docs.sigstore.dev/">Sigstore cosign&lt;/a> &lt;code>attest --predicate sbom.cdx.json&lt;/code> 把 SBOM 簽進 image OCI metadata、跟 image 一起發布；下游團隊 / 客戶 / scan pipeline 拿 &lt;em>trusted SBOM&lt;/em> 跑 Grype、不需要重新 scan image。對 &lt;em>air-gapped 環境&lt;/em>、&lt;em>multi-team handoff&lt;/em>、&lt;em>合規場景&lt;/em>（EO 14028 / FedRAMP 要求交付 CycloneDX 或 SPDX）特別合適。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &amp;#43; Secret &amp;#43; License &amp;#43; SBOM、Apache 2.0、CI 友善">Trivy&lt;/a> 的差異是 &lt;em>分工 vs 全包&lt;/em>：Trivy 一個 binary 把 SBOM 生成 + vuln scan + IaC + secret + license 都做了；Syft + Grype 拆兩個工具、SBOM 互通流程適合、團隊偏好 Unix philosophy 選這條。功能覆蓋面 Trivy 略廣（含 IaC / secret scan）、Syft 的 SBOM 格式互通性是 OSS reference implementation。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &amp;#43; Code (SAST) &amp;#43; Container &amp;#43; IaC &amp;#43; Cloud (CSPM)、Reachability analysis">Snyk&lt;/a> 的差異更直接：Snyk 商業 SaaS、覆蓋廣（SAST / IaC / CSPM / Reachability）、有 dashboard 跟 fix PR；Syft + Grype 純 CLI、OSS 免費、聚焦 SBOM + vuln 兩件事、沒 server / 沒 dashboard、要 dashboard 走商業 Anchore Enterprise 或自接 JSON 到 Elasticsearch / Grafana。&lt;/p></description><content:encoded><![CDATA[<p>Syft 跟 Grype 是 Anchore 開源的 <em>姐妹工具</em>（Apache 2.0、免費）、各做一件事、用 pipe 串接成 <em>SBOM-first</em> 的 supply chain scan 鏈：<strong>Syft</strong> 掃 container image / 檔案系統 / 目錄、產出標準 SBOM（CycloneDX 1.5+ / SPDX 2.3 / SyftJSON）；<strong>Grype</strong> 吃 SBOM 或直接 scan target、比對 Grype-DB 回報 CVE。設計哲學是 Unix philosophy — <code>syft image:tag -o cyclonedx-json | grype</code> 等價於 <code>grype image:tag</code>、但中間的 SBOM 是 <em>正式 artifact</em>、可以單獨簽章、單獨保存、單獨給下游消費。跟 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 全包式設計不同、跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> 商業 SaaS 路線也不同。</p>
<h2 id="服務定位">服務定位</h2>
<p>Syft + Grype 的核心定位是 <em>SBOM-first 的 OSS supply chain scan tool chain</em>。SBOM 不是中間產物、是 <em>正式可簽章 artifact</em>：Syft 產 SBOM 後通常用 <a href="https://docs.sigstore.dev/">Sigstore cosign</a> <code>attest --predicate sbom.cdx.json</code> 把 SBOM 簽進 image OCI metadata、跟 image 一起發布；下游團隊 / 客戶 / scan pipeline 拿 <em>trusted SBOM</em> 跑 Grype、不需要重新 scan image。對 <em>air-gapped 環境</em>、<em>multi-team handoff</em>、<em>合規場景</em>（EO 14028 / FedRAMP 要求交付 CycloneDX 或 SPDX）特別合適。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 的差異是 <em>分工 vs 全包</em>：Trivy 一個 binary 把 SBOM 生成 + vuln scan + IaC + secret + license 都做了；Syft + Grype 拆兩個工具、SBOM 互通流程適合、團隊偏好 Unix philosophy 選這條。功能覆蓋面 Trivy 略廣（含 IaC / secret scan）、Syft 的 SBOM 格式互通性是 OSS reference implementation。跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> 的差異更直接：Snyk 商業 SaaS、覆蓋廣（SAST / IaC / CSPM / Reachability）、有 dashboard 跟 fix PR；Syft + Grype 純 CLI、OSS 免費、聚焦 SBOM + vuln 兩件事、沒 server / 沒 dashboard、要 dashboard 走商業 Anchore Enterprise 或自接 JSON 到 Elasticsearch / Grafana。</p>
<p>關鍵 first-class concept：<strong>Source</strong>（OCI image / OCI archive / Docker daemon / dir / file / 既有 SBOM）、<strong>Catalog</strong>（Syft 內部 package inventory 結構）、<strong>Package</strong>、<strong>Vulnerability</strong>、<strong>Match</strong>（Grype 的 package ↔ CVE 配對）、<strong>Match Configuration</strong>（<code>grype.yaml</code> 設 severity gate / 比對策略）、<strong>Vulnerability DB</strong>（Grype-DB、Anchore 聚合 NVD + GHSA + 各 distro secdb）、<strong>Ignore Rule</strong>（CVE 例外、強制帶 expiration）。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>Syft 跟 Grype 各自的責任邊界、為什麼拆兩個工具比合一個工具好（SBOM 互通、attestation、air-gapped）</li>
<li>SBOM 格式（CycloneDX / SPDX / SyftJSON）的選擇、跟合規要求對應</li>
<li>Grype Match Configuration 跟 Ignore Rule 怎麼設、CI fail 條件怎麼定</li>
<li>何時改走 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 全包式、何時走 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> 商業 SaaS</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 Syft + Grype 配置是否健康、最少看四件事：</p>
<ul>
<li><strong>SBOM 格式跟保存</strong>：產出格式是否符合合規（多數 EO 14028 / FedRAMP 場景要 CycloneDX 或 SPDX、不是 SyftJSON）、SBOM 是否簽章（cosign attest）、是否集中保存（OCI registry 旁邊 / artifact store）、是否有 <em>baseline diff</em>（image 升級前後依賴變化）</li>
<li><strong>Grype DB 更新</strong>：DB 是否每日同步、air-gapped 場景是否 mirror 到內部 registry（Grype DB 是 OCI artifact、可 <code>oras pull</code> 鏡像）、DB version 是否進 SBOM scan record（重現性）</li>
<li><strong>Match Configuration</strong>：<code>grype.yaml</code> 的 severity gate（CI fail 條件、通常 high / critical fail）、<code>only-fixed: true</code> 是否開（只報有 patch 的 CVE）、<code>add-cpes-if-none: true</code> 對 binary-only package 行為</li>
<li><strong>Ignore Rule 治理</strong>：例外清單是否帶 <em>expiration</em>、<code>reason</code> 欄位是否填 ticket / decision 連結、quarterly review 機制、過期自動回到 fail 狀態</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">Supply Chain Integrity</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Syft 用法跟 Source 種類</strong>：<code>syft &lt;source&gt; -o &lt;format&gt;</code> 是核心 — source 可以是 OCI image（<code>registry/image:tag</code>）、OCI archive（<code>oci-archive:image.tar</code>）、Docker daemon（<code>docker:image:tag</code>）、目錄（<code>dir:./</code>）、單一檔案、甚至既有 SBOM（<code>sbom:./prev.cdx.json</code>、用來 <em>轉格式</em>）。format 包括 <code>cyclonedx-json</code> / <code>cyclonedx-xml</code> / <code>spdx-json</code> / <code>spdx-tag-value</code> / <code>syft-json</code> / <code>table</code>。production 通常產 <em>cyclonedx-json</em>（合規要求最常見）+ 保留 <em>syft-json</em>（Syft 自家最完整、未來 round-trip 用）。</p>
<p><strong>Package detector 廣度</strong>：Syft 自動偵測 OS package（apk / dpkg / rpm）+ 語言 dependency（npm / pip / gem / go module / cargo / maven / gradle / nuget / composer / hex / conan / swift / dart 等）+ binary analysis（Go binary 內 embedded module、Rust binary metadata、Java jar / war / ear nested）。對 <em>static binary</em> / <em>FAT image</em> 的支援是 Syft 的強項、比多數 SBOM tool 廣。但 <em>runtime-only dependency</em>（dlopen / dynamic load）SBOM 看不到、要靠 runtime workload protection（Falco / Cilium Tetragon 類工具、見 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">7 後續候選 vendor 清單</a>）補。</p>
<p><strong>Grype 用法</strong>：<code>grype &lt;source&gt;</code> 或 <code>grype sbom:./image.cdx.json</code>。輸出 <code>table</code> / <code>json</code> / <code>cyclonedx-json</code>（CycloneDX VEX 格式）/ <code>sarif</code>（GitHub code scanning）/ <code>template</code>（Go template 自訂）。production CI 通常 <code>--output sarif</code> 上傳 GitHub code scanning + <code>--output json</code> 進內部 SIEM。<code>grype sbom:./prev.cdx.json</code> 模式是 <em>SBOM-only scan</em>、不碰 image — 適合 <em>下游團隊拿 SBOM 持續 monitor</em>、原始 image 已經 frozen 或不可達。</p>
<p><strong>Match Configuration（<code>grype.yaml</code>）</strong>：核心欄位包括 <code>fail-on-severity: high</code>（CI gate）、<code>only-fixed: true</code>（只回報有 fix 可用的 CVE、避免 noise）、<code>ignore</code> list（個別 CVE 例外）、<code>match</code> strategy（如何把 package CPE / PURL 對應到 CVE、預設策略對 90% 場景夠用、特殊 binary 場景才調）。所有設定走版控、<code>grype.yaml</code> 跟程式碼一起 review、避免 console 改。</p>
<p><strong>Ignore Rule 治理</strong>：<code>grype.yaml</code> 的 <code>ignore</code> entry 結構：<code>vulnerability</code> + <code>reason</code> + <code>expiration</code>（YYYY-MM-DD）+ optional <code>package.name</code> / <code>fix-state</code>。Anchore 設計 <em>沒有「永久 ignore」</em>、必須帶 expiration — 強制 quarterly review、避免「五年前 ignore 的 CVE 早被 fix 了還在清單裡」。reason 欄位填 ticket 編號或 ADR link、給未來的人 context。</p>
<p><strong>Cosign attest SBOM</strong>：<code>syft image:tag -o cyclonedx-json &gt; sbom.cdx.json &amp;&amp; cosign attest --predicate sbom.cdx.json --type cyclonedx --key cosign.key image:tag</code> — SBOM 被簽進 image 的 OCI signature manifest、下游 <code>cosign verify-attestation --type cyclonedx ...</code> 拿到 <em>cryptographically signed SBOM</em>。這把 SBOM 從「可被竄改的 JSON 檔」升級到 <em>trusted artifact</em>、是 <a href="https://slsa.dev/">SLSA L3+</a> provenance 的基礎。</p>
<p><strong>SLSA / SPDX 流程整合</strong>：Syft SBOM 是 build 階段產物、跟 SLSA provenance（誰 build 的、用什麼 builder、source commit 是什麼）併存、不互斥 — SBOM 答「裡面有什麼」、provenance 答「怎麼 build 的」。完整 supply chain trust 需要兩者 + cosign signature。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Syft + Grype</th>
          <th>Trivy</th>
          <th>Snyk</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>工具拆分</td>
          <td>兩個（Unix philosophy）</td>
          <td>一個（all-in-one binary）</td>
          <td>SaaS + CLI（多模組）</td>
      </tr>
      <tr>
          <td>授權</td>
          <td>OSS Apache 2.0</td>
          <td>OSS Apache 2.0</td>
          <td>商業（freemium、付費才解鎖完整）</td>
      </tr>
      <tr>
          <td>部署模型</td>
          <td>CLI、無 server</td>
          <td>CLI、無 server</td>
          <td>SaaS dashboard + CLI</td>
      </tr>
      <tr>
          <td>SBOM 格式</td>
          <td>CycloneDX 1.5+ / SPDX 2.3 / SyftJSON（reference 實作）</td>
          <td>CycloneDX / SPDX</td>
          <td>CycloneDX / SPDX（次要、scan 為主）</td>
      </tr>
      <tr>
          <td>Vuln 資料源</td>
          <td>Grype-DB（NVD + GHSA + 各 distro secdb 聚合）</td>
          <td>Trivy-DB（類似來源 + Aqua 加值）</td>
          <td>Snyk Intel（自家 research、含 reachability）</td>
      </tr>
      <tr>
          <td>額外掃描</td>
          <td>無（聚焦 SBOM + vuln）</td>
          <td>IaC / secret / license / k8s misconfig</td>
          <td>SAST / IaC / container / IaC / Open Source / Code</td>
      </tr>
      <tr>
          <td>Dashboard</td>
          <td>無（Anchore Enterprise 商業才有）</td>
          <td>無（Aqua 商業才有）</td>
          <td>內建 SaaS dashboard</td>
      </tr>
      <tr>
          <td>Air-gapped</td>
          <td>強 — Grype DB 是 OCI artifact、可 mirror</td>
          <td>強 — Trivy DB OCI artifact</td>
          <td>弱 — SaaS-only 為主（自管 server 是 Enterprise）</td>
      </tr>
      <tr>
          <td>Reachability</td>
          <td>無</td>
          <td>無</td>
          <td>有（Java / JS）</td>
      </tr>
      <tr>
          <td>Fix PR 自動化</td>
          <td>無</td>
          <td>無</td>
          <td>有（auto PR、Renovate-like）</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>OSS 偏好、SBOM 互通流程、air-gapped、Unix tool chain</td>
          <td>OSS 偏好、單一工具想包多事、k8s misconfig 也要</td>
          <td>商業 SaaS、需 dashboard / fix workflow / reachability</td>
      </tr>
  </tbody>
</table>
<p>選 Syft + Grype 的核心訴求：<em>要正式 SBOM 作為交付 artifact</em>（合規 / 多 team handoff）+ <em>偏好 OSS Unix philosophy</em>（兩個工具各做一件事、容易整合自家 pipeline）+ 不需要 SaaS dashboard（自家 SIEM / Grafana 已經有）。需要 IaC scan 一起做、看一下 Trivy 是不是更省整合成本；需要 fix workflow 跟 reachability、商業預算足、走 Snyk。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>SBOM attestation 完整鏈</strong>：build pipeline 順序通常是 — build image → <code>syft image -o cyclonedx-json &gt; sbom.cdx.json</code> → <code>cosign sign image</code> → <code>cosign attest --predicate sbom.cdx.json --type cyclonedx image</code> → push。下游 admission controller（Kyverno / Gatekeeper / Sigstore policy-controller）<code>verify-attestation</code> 拿 trusted SBOM、再 Grype scan、policy 決定是否允許 deploy。這條鏈把 SBOM 從 <em>文件</em> 升級成 <em>deploy gate</em>。</p>
<p><strong>Grype DB air-gapped sync</strong>：Grype DB 是 OCI artifact（<code>ghcr.io/anchore/grype/listing.json</code> + <code>db.tar.gz</code>）、<code>oras pull</code> 或 <code>grype db update</code> 取得。air-gapped 場景：DMZ 跑 <code>grype db update --skip-listing-content-check</code>、把 <code>~/.cache/grype/db/</code> 整個 sync 到內部 mirror registry、內部 grype 透過 <code>GRYPE_DB_UPDATE_URL</code> 指到內部 listing。DB 版本進 scan record、確保 <em>相同 SBOM + 相同 DB = 相同結果</em>（可重現）。</p>
<p><strong>Custom matcher / Ignore Rule 細部</strong>：Grype 預設 matcher 對 90% 場景夠、但 <em>Go binary</em>、<em>static-linked binary</em>、<em>custom C++ build</em> 可能需要 <code>add-cpes-if-none: true</code> 強制配對 CPE。Ignore Rule 支援 <code>vex-status</code> 欄位（accepted / under-investigation / fixed / not-affected）對齊 CycloneDX VEX 標準、輸出 VEX-enriched SBOM 給下游 / 客戶。</p>
<p><strong>Anchore Enterprise 商業整合</strong>：OSS Syft + Grype 不夠時、Anchore Enterprise 加：policy engine（GraphQL 寫複雜 policy）、dashboard、RBAC、SLA-backed support、跟 Kubernetes admission integration、跟 Jira / ServiceNow ticket 自動建單。OSS 是 90% 場景的起點、Enterprise 解的是 <em>policy + workflow</em> 而非 <em>scan ability</em>。</p>
<p><strong>SBOM diff（baseline 比對）</strong>：<code>syft</code> 自己沒內建 diff、但 <code>cyclonedx-cli diff</code> 或自家 script 可以比對 <em>image v1 SBOM</em> vs <em>image v2 SBOM</em>、找出新增 / 移除 / 升級的 package。用途：<a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ backdoor</a> 之類「相同 version 但被植入後門」事件、單靠 SBOM 看不出來、但 <em>baseline + behavior anomaly</em> 雙軌可以提早警示。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>Syft scan 找不到 package</strong>：image 是 <code>FROM scratch</code> 或 distroless、Syft 偵測不到 OS package metadata — 改 scan source 為 build 階段的 <code>dir:./</code> 或保留 builder image 的 SBOM</li>
<li><strong>Grype 報一堆 unfixed CVE</strong>：base image 老、有 CVE 但 upstream 還沒 patch — 設 <code>only-fixed: true</code> 過濾 noise、focus 在 actionable item；同時排程 base image 升級</li>
<li><strong>CI 突然 fail 變多</strong>：Grype DB 更新後新 CVE 揭露 — 看 DB version diff、評估是 <em>真新風險</em> 還是 <em>舊 package 被重新分類</em>、必要時用 Ignore Rule + expiration 過渡</li>
<li><strong>SBOM 格式下游不認</strong>：合規要求 SPDX、產的是 SyftJSON — 用 <code>syft convert syft-json:./sbom.json -o spdx-json</code> 轉格式（Syft 本身就是 SBOM 互轉工具）</li>
<li><strong>Air-gapped 環境 Grype 跑不動</strong>：DB 沒同步、scan 直接報 0 vulnerability（假陰性）— <code>grype db status</code> 看 DB age、mirror sync 機制檢查、加 staleness alarm</li>
<li><strong>Ignore Rule 過期回到 fail</strong>：CI 突然 fail、查 expiration 已過 — 預期行為、強制 quarterly review；補 rotation 機制（cronjob 提前一週 alert owner）</li>
<li><strong>Binary 偵測不到 module</strong>：Go binary stripped、<code>-trimpath</code> 後 module path 沒了 — build 改加 <code>-buildvcs=true</code> 保留 VCS info、或 build 階段 SBOM scan source code、不是 binary</li>
<li><strong>cosign verify-attestation 失敗</strong>：image 被 re-tag / re-push 後 attestation manifest 不對 — 用 image digest（<code>@sha256:...</code>）而非 tag 做 attest、tag 不可信</li>
<li><strong>Grype 不抓某個 ecosystem</strong>：例如新冒出的 package manager — Syft 沒實作 detector、Grype 也看不到；submit issue 或自己寫 catalogger 貢獻</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>一個工具想包 IaC / secret / k8s misconfig</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a></td>
      </tr>
      <tr>
          <td>需要 SAST / Reachability / Fix PR workflow</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a></td>
      </tr>
      <tr>
          <td>綁 GitHub 的 SAST + Dependabot</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a></td>
      </tr>
      <tr>
          <td>Container runtime detection</td>
          <td>Falco / Cilium Tetragon（見 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">7 後續候選 vendor 清單</a>）</td>
      </tr>
      <tr>
          <td>Image signing / attestation</td>
          <td><a href="https://docs.sigstore.dev/">Sigstore cosign</a></td>
      </tr>
      <tr>
          <td>Policy at admission</td>
          <td>Kyverno / OPA Gatekeeper（見 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">7 後續候選 vendor 清單</a>）</td>
      </tr>
      <tr>
          <td>SBOM dashboard / enterprise policy / RBAC</td>
          <td>Anchore Enterprise（商業）</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>CycloneDX / SPDX 完整 schema 規格逐欄位解讀</li>
<li>Sigstore cosign / Rekor / Fulcio 完整架構（attest 鏈的 OIDC / transparency log）</li>
<li>SLSA framework 各 level 對應的 builder 要求</li>
<li>Anchore Enterprise policy DSL 完整語法</li>
<li>VEX（Vulnerability Exploitability eXchange）跟 CSAF 標準對照細節</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>07 案例庫沒有直接 Syft / Grype-level 事件、但供應鏈案例都是 SBOM-first 思維的對照：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Syft + Grype 的關係</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/log4shell-cve-2021-44228-component-chain/" data-link-title="7.R7.2.7 Log4Shell 2021：共用元件風險與修補鏈" data-link-desc="共用元件漏洞如何同步影響多服務，並迫使團隊建立依賴治理 workflow">Log4Shell CVE-2021-44228</a></td>
          <td>對照啟示 — 預先用 Syft 產 SBOM 集中保存後、Log4Shell 公開時拿歷史 SBOM 跑 Grype 在分鐘級回答「我們哪些服務有用、含 transitive」</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020 Sunburst</a></td>
          <td>對照啟示 — Syft 看 package layer、看不到 build-time backdoor 注入；需配 cosign attest + SLSA provenance 才完整</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a></td>
          <td>對照啟示 — 相同 version 被植入後 SBOM 一樣、純比對 SBOM 看不出來；mitigation 是 SBOM diff 對 baseline + release tarball verify</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/kaseya-vsa-2021-msp-ransomware-chain/" data-link-title="7.R7.2.9 Kaseya VSA 2021：MSP 供應鏈擴散路徑" data-link-desc="管理平台事件透過 MSP 模型向多客戶擴散時，workflow 應如何分層應對">Kaseya VSA 2021</a></td>
          <td>對照啟示 — 多服務 SBOM 集中 inventory（哪 service 用哪 component）、緊急時可 <em>affected-services-by-package</em> 反查、不是逐 image scan</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></td>
          <td>Syft 是 SBOM reference implementation、章節原則對應 SBOM + signing + provenance 的 trust chain</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（一站式替代）、<a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a>（商業 SaaS）、<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GitHub Advanced Security</a>（GitHub 內建）</li>
<li>下游：<a href="https://docs.sigstore.dev/">Sigstore cosign</a>（SBOM attestation）、admission policy（Kyverno / OPA Gatekeeper、見 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">7 後續候選 vendor 清單</a>）</li>
<li>跨類：runtime workload protection（Falco / Cilium Tetragon、見 <a href="/blog/backend/07-security-data-protection/vendors/" data-link-title="資安與資料保護 Vendor 清單" data-link-desc="規劃身份、秘密、金鑰、入口防護、供應鏈與偵測工具的服務頁撰寫順序與教學大綱">7 後續候選 vendor 清單</a>）、<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a>（cosign signing key 保存）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（新 CVE 揭露時的 SBOM-based fan-out 查詢）</li>
<li>官方：<a href="https://github.com/anchore/syft">Syft Documentation</a> / <a href="https://github.com/anchore/grype">Grype Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>Cloudflare Page Shield：用 CSP + SRI + script monitoring 防 client-side supply chain</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/cloudflare-waf/page-shield-csp-sri/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/cloudflare-waf/page-shield-csp-sri/</guid><description>&lt;blockquote>
&lt;p>本文是 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/cloudflare-waf/" data-link-title="Cloudflare WAF" data-link-desc="Edge WAF &amp;#43; DDoS &amp;#43; Bot management 整合套件、global anycast 網路、控制面信任邊界跟客戶側補強的對照">Cloudflare WAF&lt;/a> overview 的 implementation-layer deep article。Overview 已說明 Cloudflare WAF 在入口治理譜系的定位、本文聚焦 &lt;em>Page Shield&lt;/em> 這個 client-side（browser）supply chain attack 防禦工具 — 跟 WAF 攔 server-side request 是不同層。&lt;/p>&lt;/blockquote>
&lt;h2 id="attack-pattern--defense-mechanism-對照">Attack pattern × Defense mechanism 對照&lt;/h2>
&lt;p>Client-side supply chain attack 不會被 WAF 看到 — 攻擊發生在 browser 渲染 page 時、不在 origin server 跟 client 之間的網路層。Page Shield 是 &lt;em>browser-side script execution&lt;/em> 的監測 + 防禦層、跟 WAF 處理 &lt;em>server-side request inspection&lt;/em> 互補不重疊。&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Attack pattern&lt;/th>
 &lt;th>表現&lt;/th>
 &lt;th>Page Shield 對應防禦&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Magecart 信用卡 skimmer&lt;/td>
 &lt;td>第三方 JS 被注入惡意 form listener、信用卡資訊送外部 endpoint&lt;/td>
 &lt;td>CSP &lt;code>connect-src&lt;/code> + script alert&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>第三方 SDK 被 compromise&lt;/td>
 &lt;td>廠商 CDN 被攻擊、SDK 改版內含 malicious payload&lt;/td>
 &lt;td>SRI hash mismatch + script alert&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Formjacking&lt;/td>
 &lt;td>結帳頁 form action 被改、submit 送外部 server&lt;/td>
 &lt;td>CSP &lt;code>form-action&lt;/code> directive&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Inline script injection&lt;/td>
 &lt;td>XSS / DOM-based injection 插入 &lt;code>&amp;lt;script&amp;gt;&lt;/code> 跑外部 source&lt;/td>
 &lt;td>CSP &lt;code>script-src&lt;/code> + nonce&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Storage abuse&lt;/td>
 &lt;td>malicious JS 讀 localStorage / cookies 送外部&lt;/td>
 &lt;td>CSP &lt;code>connect-src&lt;/code> + CSP report&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>三層防禦對應不同 attack 階段：&lt;/p>
&lt;ol>
&lt;li>&lt;strong>CSP（Content Security Policy）&lt;/strong>：browser-enforced policy、preventive、阻止違反 policy 的 script load / network request&lt;/li>
&lt;li>&lt;strong>SRI（Subresource Integrity）&lt;/strong>：load 階段 hash 驗證、detective + preventive、廠商 CDN 上 script 被改就 browser 拒載&lt;/li>
&lt;li>&lt;strong>Script monitoring&lt;/strong>：runtime 觀測、detective only、記錄頁面 load 哪些 third-party script、變動時 alert&lt;/li>
&lt;/ol>
&lt;p>三層各有 ceiling — &lt;em>CSP 擋 inline / unauthorized source 但擋不到 allowed source 被 compromise&lt;/em>；&lt;em>SRI 擋已知 vendor 改 hash 但擋不到動態 loader&lt;/em>；&lt;em>monitoring 看得到但攔不到&lt;/em>。Production 三層疊用、不要單一 layer。&lt;/p></description><content:encoded><![CDATA[<blockquote>
<p>本文是 <a href="/blog/backend/07-security-data-protection/vendors/cloudflare-waf/" data-link-title="Cloudflare WAF" data-link-desc="Edge WAF &#43; DDoS &#43; Bot management 整合套件、global anycast 網路、控制面信任邊界跟客戶側補強的對照">Cloudflare WAF</a> overview 的 implementation-layer deep article。Overview 已說明 Cloudflare WAF 在入口治理譜系的定位、本文聚焦 <em>Page Shield</em> 這個 client-side（browser）supply chain attack 防禦工具 — 跟 WAF 攔 server-side request 是不同層。</p></blockquote>
<h2 id="attack-pattern--defense-mechanism-對照">Attack pattern × Defense mechanism 對照</h2>
<p>Client-side supply chain attack 不會被 WAF 看到 — 攻擊發生在 browser 渲染 page 時、不在 origin server 跟 client 之間的網路層。Page Shield 是 <em>browser-side script execution</em> 的監測 + 防禦層、跟 WAF 處理 <em>server-side request inspection</em> 互補不重疊。</p>
<table>
  <thead>
      <tr>
          <th>Attack pattern</th>
          <th>表現</th>
          <th>Page Shield 對應防禦</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Magecart 信用卡 skimmer</td>
          <td>第三方 JS 被注入惡意 form listener、信用卡資訊送外部 endpoint</td>
          <td>CSP <code>connect-src</code> + script alert</td>
      </tr>
      <tr>
          <td>第三方 SDK 被 compromise</td>
          <td>廠商 CDN 被攻擊、SDK 改版內含 malicious payload</td>
          <td>SRI hash mismatch + script alert</td>
      </tr>
      <tr>
          <td>Formjacking</td>
          <td>結帳頁 form action 被改、submit 送外部 server</td>
          <td>CSP <code>form-action</code> directive</td>
      </tr>
      <tr>
          <td>Inline script injection</td>
          <td>XSS / DOM-based injection 插入 <code>&lt;script&gt;</code> 跑外部 source</td>
          <td>CSP <code>script-src</code> + nonce</td>
      </tr>
      <tr>
          <td>Storage abuse</td>
          <td>malicious JS 讀 localStorage / cookies 送外部</td>
          <td>CSP <code>connect-src</code> + CSP report</td>
      </tr>
  </tbody>
</table>
<p>三層防禦對應不同 attack 階段：</p>
<ol>
<li><strong>CSP（Content Security Policy）</strong>：browser-enforced policy、preventive、阻止違反 policy 的 script load / network request</li>
<li><strong>SRI（Subresource Integrity）</strong>：load 階段 hash 驗證、detective + preventive、廠商 CDN 上 script 被改就 browser 拒載</li>
<li><strong>Script monitoring</strong>：runtime 觀測、detective only、記錄頁面 load 哪些 third-party script、變動時 alert</li>
</ol>
<p>三層各有 ceiling — <em>CSP 擋 inline / unauthorized source 但擋不到 allowed source 被 compromise</em>；<em>SRI 擋已知 vendor 改 hash 但擋不到動態 loader</em>；<em>monitoring 看得到但攔不到</em>。Production 三層疊用、不要單一 layer。</p>
<h2 id="csp-配置-step-by-step">CSP 配置 step-by-step</h2>
<h3 id="從-cloudflare-dashboard-啟用--寫-policy">從 Cloudflare dashboard 啟用 + 寫 policy</h3>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln"> 1</span><span class="cl"># Dashboard: Security → Page Shield → CSP
</span></span><span class="line"><span class="ln"> 2</span><span class="cl"># 模式: Report-only（第一週）→ Enforced（驗證後）
</span></span><span class="line"><span class="ln"> 3</span><span class="cl">
</span></span><span class="line"><span class="ln"> 4</span><span class="cl"># 範例 policy
</span></span><span class="line"><span class="ln"> 5</span><span class="cl">default-src &#39;self&#39;;
</span></span><span class="line"><span class="ln"> 6</span><span class="cl">script-src &#39;self&#39; &#39;nonce-{NONCE}&#39; https://cdn.trusted.com https://www.googletagmanager.com;
</span></span><span class="line"><span class="ln"> 7</span><span class="cl">style-src &#39;self&#39; &#39;unsafe-inline&#39; https://fonts.googleapis.com;
</span></span><span class="line"><span class="ln"> 8</span><span class="cl">img-src &#39;self&#39; data: https:;
</span></span><span class="line"><span class="ln"> 9</span><span class="cl">connect-src &#39;self&#39; https://api.myapp.com https://*.sentry.io;
</span></span><span class="line"><span class="ln">10</span><span class="cl">form-action &#39;self&#39;;
</span></span><span class="line"><span class="ln">11</span><span class="cl">frame-ancestors &#39;none&#39;;
</span></span><span class="line"><span class="ln">12</span><span class="cl">report-uri https://csp-report.cloudflare.com/cdn-cgi/script_monitor/report;
</span></span><span class="line"><span class="ln">13</span><span class="cl">report-to default;</span></span></code></pre></div><p>關鍵直覺：</p>
<ul>
<li><strong><code>'nonce-{NONCE}'</code></strong>：origin server 每 request 生成 random nonce、注入 <code>&lt;script nonce=&quot;...&quot;&gt;</code> 跟 CSP header；script tag 沒對應 nonce 就被 browser 拒跑、擋 XSS</li>
<li><strong><code>connect-src</code> 精準寫</strong>：第三方 API endpoint 全列出；不寫 <code>*</code> 或 <code>https:</code> 是擋 exfiltration 的關鍵（Magecart 把信用卡送外部 endpoint 就是用 <code>connect-src</code> 攔）</li>
<li><strong><code>form-action</code></strong>：擋 form 被改 action attribute 送外部、formjacking 第一道防線</li>
<li><strong><code>report-uri</code> + <code>report-to</code></strong>：违反 policy 的 event 送 Cloudflare、Page Shield dashboard 看 violation report</li>
</ul>
<h3 id="report-only-mode-第一週">Report-only mode 第一週</h3>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln">1</span><span class="cl">Content-Security-Policy-Report-Only: &lt;policy&gt;
</span></span><span class="line"><span class="ln">2</span><span class="cl">Content-Security-Policy:             default-src &#39;self&#39;;   # 鬆 policy 仍 enforce</span></span></code></pre></div><p>Report-only 期間 browser <em>report 違反但不擋</em>、production traffic 不受影響；SOC 看 report 找：</p>
<ul>
<li>漏列的 legitimate third-party（marketing / analytics SDK 沒寫進 policy）</li>
<li>意外 inline script（dev 留下的 debug snippet）</li>
<li>跨 domain 的合法 connect（CRM / chat widget）</li>
</ul>
<p>第一週後 dashboard 看 violation 數量趨穩 + 主要違規都已 whitelist、切 Enforced。</p>
<h3 id="enforced-mode-切換--canary">Enforced mode 切換 + canary</h3>
<p>不要直接全站 enforced — 用 Cloudflare Page Rule 對 10% traffic enforced、90% report-only：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="ln">1</span><span class="cl">URL pattern: example.com/*
</span></span><span class="line"><span class="ln">2</span><span class="cl">Page Rule: Add CSP header (enforced)
</span></span><span class="line"><span class="ln">3</span><span class="cl">Bypass: 90% by Cookie / IP hash</span></span></code></pre></div><p>10% traffic 跑 24-48h、確認 zero legitimate violation、再擴大到 50% → 100%。canary 期間 monitor <code>error-rate</code> metric、不只是 violation report。</p>
<h2 id="sri-配置">SRI 配置</h2>
<p>Subresource Integrity 用 hash 驗證 CDN-hosted script 沒被改：</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="ln">1</span><span class="cl"><span class="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&#34;https://cdn.example.com/widget.v1.2.3.js&#34;</span>
</span></span><span class="line"><span class="ln">2</span><span class="cl">        <span class="na">integrity</span><span class="o">=</span><span class="s">&#34;sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC&#34;</span>
</span></span><span class="line"><span class="ln">3</span><span class="cl">        <span class="na">crossorigin</span><span class="o">=</span><span class="s">&#34;anonymous&#34;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span></span></span></code></pre></div><p>Browser load 時算 hash、跟 <code>integrity</code> 不符就拒跑。關鍵：</p>
<ul>
<li><strong>Hash 一定要 version-pinned</strong>：用 <code>widget.v1.2.3.js</code>、不能用 <code>widget.latest.js</code>；廠商更新 latest 時 hash 變 → SRI 拒載 → 服務中斷</li>
<li><strong>多 hash</strong>：寫 <code>integrity=&quot;sha384-... sha512-...&quot;</code> 至少一個 match 就過、可在 vendor rotate hash 時平滑遷移</li>
<li><strong><code>crossorigin=&quot;anonymous&quot;</code></strong> 必加：跨 origin script 預設 browser 不暴露 hash 失敗細節、<code>anonymous</code> 才允許 CORS-based hash check</li>
</ul>
<h3 id="page-shield-自動產-sri-提示">Page Shield 自動產 SRI 提示</h3>
<p>Dashboard → Page Shield → Scripts 列出所有偵測到的 script、含 <em>建議 SRI hash</em>；可以 export 整合進 build pipeline、自動把所有 vendor script 加 SRI。</p>
<h2 id="故障演練">故障演練</h2>
<h3 id="case-1csp-report-floodsoc-noise">Case 1：CSP report flood，SOC noise</h3>
<p><strong>徵兆</strong>：切 Enforced 後、CSP violation report 從每天 ~500 漲到每分鐘 ~50K、Page Shield dashboard 變紅、SOC 收 alert 收到 silent。</p>
<p><strong>根因</strong>：browser extension（廣告攔截 / spell checker / password manager）注入 inline script 跟 connect、被 CSP block 同時觸發 report；不是真實 attack、是 user 端 extension 行為。</p>
<p><strong>修法</strong>：</p>
<ol>
<li>CSP <code>report-sample</code> directive 限 sampling（只 report 10%）— spec 部分支援、不是所有 browser 都認</li>
<li>Page Shield 規則：filter out extension protocol（<code>chrome-extension://</code>、<code>moz-extension://</code>、<code>safari-extension://</code>）後再 alert</li>
<li>Report endpoint 自管 + aggregation：不直接接 SIEM、先 batch + dedupe、再送 SIEM</li>
<li>接受 report flood 是 normal、focus 監測 <em>unique violation pattern</em> 不是 <em>total volume</em></li>
</ol>
<h3 id="case-2inline-script-漏舊頁面突然壞">Case 2：Inline script 漏，舊頁面突然壞</h3>
<p><strong>徵兆</strong>：切 Enforced 後 X 個舊頁面壞、user feedback 提交 form 失敗、debugger 看到 console <code>Refused to execute inline script because it violates...</code>。</p>
<p><strong>根因</strong>：legacy page 有 inline <code>&lt;script&gt;</code> 沒 nonce、CSP enforced 後 browser 拒跑；報表/管理後台/舊 admin page 常見。</p>
<p><strong>修法</strong>：</p>
<ol>
<li>Audit 所有 inline <code>&lt;script&gt;</code>、加 nonce attribute（server-side render 時注入）</li>
<li>短期：對舊頁面用 <code>unsafe-inline</code> 寫進 CSP（接受降級）、page-specific CSP override</li>
<li>長期：legacy page 改 build-time bundle、消除 inline script</li>
</ol>
<h3 id="case-3dynamic-script-loader-繞過-sri">Case 3：Dynamic script loader 繞過 SRI</h3>
<p><strong>徵兆</strong>：vendor script load 成功、但 Page Shield monitoring 看到該 vendor script <em>load 後又動態 load 多個額外 script</em>；額外 script 沒 SRI 保護、廠商側 compromise 直接過。</p>
<p><strong>根因</strong>：第三方 SDK 用 <code>document.createElement('script')</code> + <code>script.src = '...'</code> runtime 動態 load；CSP <code>script-src</code> 可能允許這個來源、但 SRI 沒法在 runtime 注入。</p>
<p><strong>修法</strong>：</p>
<ol>
<li>CSP <code>script-src</code> 精準到 <em>只允許特定 path</em>、不是整個 domain（例：<code>https://cdn.vendor.com/sdk/v3/</code> 而不是 <code>https://cdn.vendor.com</code>）</li>
<li>評估 vendor 是否有 <em>static-only</em> 替代（多數 marketing / analytics SDK 不需要 dynamic loader、是 legacy 設計）</li>
<li>不能消除 dynamic loader 時、Page Shield monitoring 設 <em>new script alert</em>、廠商加 sub-script 即刻通知</li>
</ol>
<h3 id="case-4sri-hash-mismatchvendor-偷偷更新">Case 4：SRI hash mismatch，vendor 偷偷更新</h3>
<p><strong>徵兆</strong>：第三方 widget 突然不顯示、Page Shield 顯示 SRI mismatch、廠商 status page 沒事故公告。</p>
<p><strong>根因</strong>：廠商在 same URL（不是 versioned）下偷偷 push minor patch、hash 變了 → SRI 拒載；不是 attack、是 vendor 不遵守 immutable URL 慣例。</p>
<p><strong>修法</strong>：</p>
<ol>
<li>強制要求廠商提供 versioned URL（<code>widget.v1.2.3.js</code>）、不收 <code>widget.latest.js</code></li>
<li>廠商不配合時、build pipeline 加 <em>daily hash check</em>、廠商偷改 SRI hash 自動更新 + Slack alert</li>
<li>評估換 vendor — 不遵守 immutable URL 的廠商 supply chain integrity 信用低</li>
</ol>
<h2 id="容量--cost">容量 + cost</h2>
<p>Page Shield 是 <em>Enterprise plan + Page Shield add-on</em>、cost 維度：</p>
<table>
  <thead>
      <tr>
          <th>維度</th>
          <th>影響</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CSP report 量</td>
          <td>Cloudflare 端聚合、不另外計費；report endpoint 自管要 sizing</td>
      </tr>
      <tr>
          <td>Script monitoring</td>
          <td>不影響 page load latency（async detection）</td>
      </tr>
      <tr>
          <td>Per-zone pricing</td>
          <td>跨子域 + apex domain 多 zone 各算一份</td>
      </tr>
      <tr>
          <td>SOC operation</td>
          <td>第一週 report 量大、需要 1-2 analyst FTE 跑 tuning；穩定後低人力</td>
      </tr>
  </tbody>
</table>
<p>Page load 影響：</p>
<ul>
<li>CSP header ~1-2KB（policy 寫越精準越長、不是越短越好）</li>
<li>SRI 比對 ~5-10ms / script、現代 browser cache decoded hash、不重複算</li>
<li>Script monitoring beacon ~100 byte / script load、async 不阻塞 page render</li>
</ul>
<p>實務 default：</p>
<ul>
<li>Critical e-commerce / fintech：CSP enforced + SRI 全 vendor + monitoring all、SOC review weekly</li>
<li>一般 SaaS：CSP report-only ongoing + SRI critical vendor only + monitoring 主域</li>
<li>Marketing / blog：CSP <code>default-src 'self'</code> minimum + monitoring only</li>
</ul>
<h2 id="整合--下一步">整合 / 下一步</h2>
<h3 id="跟-dev-workflow-整合">跟 dev workflow 整合</h3>
<p>CSP 寫進 <em>deploy pipeline</em>、不是 dashboard 手動配：</p>
<ol>
<li>Repo 內 <code>csp-policy.yml</code>、跟 code 同 lifecycle</li>
<li>CI 跑 <em>CSP linter</em>（如 <code>csp-evaluator</code>）、檢查 policy 弱點</li>
<li>Deploy 時 push 到 Cloudflare API、自動 versioning + rollback</li>
</ol>
<h3 id="跟-waf-互補">跟 WAF 互補</h3>
<p>Page Shield 跟 <a href="/blog/backend/07-security-data-protection/vendors/cloudflare-waf/" data-link-title="Cloudflare WAF" data-link-desc="Edge WAF &#43; DDoS &#43; Bot management 整合套件、global anycast 網路、控制面信任邊界跟客戶側補強的對照">Cloudflare WAF</a> 不重疊但互補：</p>
<ul>
<li>WAF 攔 <em>server-side</em> request injection（SQL / command / path traversal）</li>
<li>Page Shield 攔 <em>client-side</em> script execution（XSS / supply chain）</li>
<li>共同 dashboard + alert routing、不要分開 SOC team 看</li>
</ul>
<h3 id="跟-supply-chain-sbom">跟 supply chain SBOM</h3>
<p>Page Shield 偵測的 <em>client-side dependency</em> 可進 SBOM、跟 <a href="/blog/backend/07-security-data-protection/vendors/snyk/" data-link-title="Snyk" data-link-desc="跨 SCM 多模組 application security platform：Open Source (SCA) &#43; Code (SAST) &#43; Container &#43; IaC &#43; Cloud (CSPM)、Reachability analysis">Snyk</a> / <a href="/blog/backend/07-security-data-protection/vendors/dependabot/" data-link-title="Dependabot" data-link-desc="GitHub 原生依賴更新自動化、Version Update &#43; Security Update &#43; Alerts、Grouped Updates 減 PR noise、Auto-merge 配 branch protection">Dependabot</a> 的 server-side SBOM 合併、得到完整 dependency graph。</p>
<h3 id="下一步議題">下一步議題</h3>
<ul>
<li><strong>Trusted Types</strong>：browser-side template injection 的下一代防禦、Chrome 已支援、Firefox / Safari 進度不一</li>
<li><strong>CSP Level 3 + strict-dynamic</strong>：減少 maintenance burden、用 nonce 動態信任 nested script</li>
<li><strong>Reporting API v1</strong>：standard report endpoint + <code>Reporting-Endpoints</code> header 取代 <code>report-uri</code></li>
</ul>
<h2 id="相關連結">相關連結</h2>
<ul>
<li>上游 vendor 頁：<a href="/blog/backend/07-security-data-protection/vendors/cloudflare-waf/" data-link-title="Cloudflare WAF" data-link-desc="Edge WAF &#43; DDoS &#43; Bot management 整合套件、global anycast 網路、控制面信任邊界跟客戶側補強的對照">Cloudflare WAF</a></li>
<li>上游 chapter：<a href="/blog/backend/07-security-data-protection/entrypoint-and-server-protection/" data-link-title="7.3 入口治理與伺服器防護" data-link-desc="以問題驅動方式整理對外入口、管理平面與伺服器邊界">7.3 入口治理與伺服器防護</a>、<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性</a></li>
<li>對照案例：British Airways 2018 Magecart / Macy&rsquo;s 2019 skimmer（公開 supply chain 案例）</li>
<li>平行 vendor：<a href="/blog/backend/07-security-data-protection/vendors/aws-waf/" data-link-title="AWS WAF" data-link-desc="AWS-internal WAF、跟 ALB / CloudFront / API Gateway 直接整合、Web ACL &#43; Managed Rule Group &#43; Rate-based Rule、Shield Standard 內含">AWS WAF</a> / <a href="/blog/backend/07-security-data-protection/vendors/fastly-ngwaf/" data-link-title="Fastly Next-Gen WAF" data-link-desc="Behavioral / 語意分析 WAF（前 Signal Sciences）、低 false positive、Edge / Agent / Cloud 三種部署模型、API &#43; ATO &#43; Bot 一體">Fastly Next-Gen WAF</a></li>
<li>平行 deep article：<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/dynamic-credential/" data-link-title="HashiCorp Vault Dynamic Credential：lease 治理跟 application 整合的實作層" data-link-desc="Vault database secrets engine 怎麼配、application 怎麼 renew lease、production 五大踩雷（lease 過期 race、DB max_connections 撞牆、Vault sealed、token expire、scope 過寬）、容量規劃跟 vault-agent injector 整合">Vault Dynamic Credential</a> / <a href="/blog/backend/07-security-data-protection/vendors/splunk/risk-based-alerting/" data-link-title="Splunk Risk-Based Alerting：從 alert per rule 到 score-aggregated notable" data-link-desc="Splunk Enterprise Security 的 RBA 方法論：risk score / modifier / notable 三層 model、ES 配置 step-by-step、tuning playbook（false positive / score inflation / threshold drift / decay）、capacity 成本、跟 SOAR &#43; case management 整合">Splunk RBA</a></li>
<li>Methodology：<a href="/blog/posts/vendor-%E6%B7%B1%E5%BA%A6%E6%8A%80%E8%A1%93%E6%96%87%E7%AB%A0%E6%96%B9%E6%B3%95%E8%AB%96%E7%9A%84%E6%BC%94%E5%8C%96%E7%B4%80%E9%8C%84%E5%90%8C-vendor-%E7%B3%BB%E5%88%97%E7%9A%84%E9%96%8B%E5%A0%B4%E8%BC%AA%E6%9B%BF%E9%A9%97%E8%AD%89/" data-link-title="Vendor 深度技術文章方法論的演化紀錄：同 vendor 系列的開場輪替驗證" data-link-desc="vendor overview 飽和後要寫單一功能深度文章、需要選題與結構依據時回來。這套方法論的驗證來源與 cadence variant 在高風險場景（同 vendor sub-tool 系列）的實證。">Vendor 深度技術文章的寫作方法論</a></li>
</ul>
]]></content:encoded></item><item><title>SBOM</title><link>https://tarrragon.github.io/blog/ci/knowledge-cards/sbom/</link><pubDate>Thu, 21 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/ci/knowledge-cards/sbom/</guid><description>&lt;p>SBOM 的核心概念是「列出 artifact 內含軟體元件」。它把 &lt;a href="https://tarrragon.github.io/blog/ci/knowledge-cards/artifact/" data-link-title="Artifact" data-link-desc="說明 CI/CD 中可被驗證、保存與發布的交付產物">Artifact&lt;/a> 的依賴組成顯性化，並支援 image scan、license review 與 vulnerability exception。&lt;/p>
&lt;h2 id="概念位置">概念位置&lt;/h2>
&lt;p>SBOM 位在 build、scan、release 與 compliance review 之間，常見格式包含 SPDX、CycloneDX 或工具自訂輸出。&lt;/p>
&lt;h2 id="可觀察訊號">可觀察訊號&lt;/h2>
&lt;ul>
&lt;li>團隊需要知道 image 或 package 包含哪些 dependency。&lt;/li>
&lt;li>漏洞公告需要快速判斷受影響 artifact。&lt;/li>
&lt;li>高治理環境要求 release 產物附帶供應鏈證據。&lt;/li>
&lt;/ul>
&lt;h2 id="接近真實服務的例子">接近真實服務的例子&lt;/h2>
&lt;p>Container image 發布時同時產生 SBOM，scan gate 依 SBOM 對照 CVE 與 license policy。若 base image 發現 critical vulnerability，團隊可查哪些 release digest 受影響。&lt;/p>
&lt;h2 id="設計責任">設計責任&lt;/h2>
&lt;p>SBOM 要定義產出時機、格式、保存位置、artifact 對應關係與例外審核流程，讓供應鏈風險可以被查詢與治理。&lt;/p></description><content:encoded><![CDATA[<p>SBOM 的核心概念是「列出 artifact 內含軟體元件」。它把 <a href="/blog/ci/knowledge-cards/artifact/" data-link-title="Artifact" data-link-desc="說明 CI/CD 中可被驗證、保存與發布的交付產物">Artifact</a> 的依賴組成顯性化，並支援 image scan、license review 與 vulnerability exception。</p>
<h2 id="概念位置">概念位置</h2>
<p>SBOM 位在 build、scan、release 與 compliance review 之間，常見格式包含 SPDX、CycloneDX 或工具自訂輸出。</p>
<h2 id="可觀察訊號">可觀察訊號</h2>
<ul>
<li>團隊需要知道 image 或 package 包含哪些 dependency。</li>
<li>漏洞公告需要快速判斷受影響 artifact。</li>
<li>高治理環境要求 release 產物附帶供應鏈證據。</li>
</ul>
<h2 id="接近真實服務的例子">接近真實服務的例子</h2>
<p>Container image 發布時同時產生 SBOM，scan gate 依 SBOM 對照 CVE 與 license policy。若 base image 發現 critical vulnerability，團隊可查哪些 release digest 受影響。</p>
<h2 id="設計責任">設計責任</h2>
<p>SBOM 要定義產出時機、格式、保存位置、artifact 對應關係與例外審核流程，讓供應鏈風險可以被查詢與治理。</p>
]]></content:encoded></item><item><title>GitGuardian</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/</guid><description>&lt;p>GitGuardian 是 &lt;em>secret scanning + remediation&lt;/em> SaaS、起家於 GitHub public repo scan、現延伸到 internal SCM、CI 系統與 collaboration / chat 工具。它跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 的根本差異不在「能不能抓到 secret」、而在 &lt;em>偵測邊界跟 remediation workflow 的 shape&lt;/em> — GHAS 是 GitHub-only、partner pattern 強但 push protection 鎖在 GitHub repo；GitGuardian 把 detection 邊界擴到跨 SCM 跟 SaaS workspace、然後用 &lt;em>Incident&lt;/em> 物件管整個生命週期。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>GitGuardian 的核心定位是 &lt;em>跨工具的 secret leak detection + incident workflow&lt;/em>、不只是「pre-commit grep」。底層是一組 &lt;em>Detector&lt;/em>（350+ specific detector、覆蓋 AWS / GCP / Stripe / Slack / 自家 token 等）+ &lt;em>Validation endpoint&lt;/em>（call 該 service 確認 secret live 中），上層是 &lt;em>Incident&lt;/em> 物件（assign / resolve / ignore / share with developer）跟 &lt;em>Source&lt;/em> 抽象（GitHub / GitLab / Bitbucket / Azure DevOps / Slack / Jira / Confluence / Notion）。本機側用 &lt;em>ggshield&lt;/em> CLI 做 pre-commit hook 跟 CI scan。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 比、GitGuardian 走 &lt;em>cross-tool detection + remediation workflow&lt;/em>、GHAS 走 &lt;em>deep integration in GitHub&lt;/em>：GHAS 的 push protection 在 GitHub server-side 直接攔 push、partner pattern（AWS / Stripe / Slack）廣度高；但只要組織有 GitLab self-hosted、Bitbucket、或 developer 習慣把 token 貼 Slack / Confluence，GHAS 看不到的就是 GitGuardian 的場域。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &amp;#43; regex &amp;#43; entropy、SARIF output、跨 SCM、pre-commit &amp;#43; CI 友善">Gitleaks&lt;/a> / TruffleHog OSS 比、GitGuardian 走 &lt;em>managed SaaS + validation + workflow&lt;/em>、OSS 走 &lt;em>self-hosted + 你自己接 incident pipeline&lt;/em>；OSS 適合預算敏感 + 已有 SOC / IR tooling、GitGuardian 適合直接買 incident workflow 不想自建。&lt;/p></description><content:encoded><![CDATA[<p>GitGuardian 是 <em>secret scanning + remediation</em> SaaS、起家於 GitHub public repo scan、現延伸到 internal SCM、CI 系統與 collaboration / chat 工具。它跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 的根本差異不在「能不能抓到 secret」、而在 <em>偵測邊界跟 remediation workflow 的 shape</em> — GHAS 是 GitHub-only、partner pattern 強但 push protection 鎖在 GitHub repo；GitGuardian 把 detection 邊界擴到跨 SCM 跟 SaaS workspace、然後用 <em>Incident</em> 物件管整個生命週期。</p>
<h2 id="服務定位">服務定位</h2>
<p>GitGuardian 的核心定位是 <em>跨工具的 secret leak detection + incident workflow</em>、不只是「pre-commit grep」。底層是一組 <em>Detector</em>（350+ specific detector、覆蓋 AWS / GCP / Stripe / Slack / 自家 token 等）+ <em>Validation endpoint</em>（call 該 service 確認 secret live 中），上層是 <em>Incident</em> 物件（assign / resolve / ignore / share with developer）跟 <em>Source</em> 抽象（GitHub / GitLab / Bitbucket / Azure DevOps / Slack / Jira / Confluence / Notion）。本機側用 <em>ggshield</em> CLI 做 pre-commit hook 跟 CI scan。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 比、GitGuardian 走 <em>cross-tool detection + remediation workflow</em>、GHAS 走 <em>deep integration in GitHub</em>：GHAS 的 push protection 在 GitHub server-side 直接攔 push、partner pattern（AWS / Stripe / Slack）廣度高；但只要組織有 GitLab self-hosted、Bitbucket、或 developer 習慣把 token 貼 Slack / Confluence，GHAS 看不到的就是 GitGuardian 的場域。跟 <a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> / TruffleHog OSS 比、GitGuardian 走 <em>managed SaaS + validation + workflow</em>、OSS 走 <em>self-hosted + 你自己接 incident pipeline</em>；OSS 適合預算敏感 + 已有 SOC / IR tooling、GitGuardian 適合直接買 incident workflow 不想自建。</p>
<p>關鍵張力：<em>validation endpoint 是 FP 降噪核心</em>、但也是 <em>vendor 風險點</em>。Detector 抓到字串後 GitGuardian <em>call 該 service API live verify</em>（AWS access key 試 <code>sts:GetCallerIdentity</code>、Stripe key 試 retrieve event）、活躍 secret 才升 Incident。意義是 noise 從 OSS gitleaks 的 70-80% FP 降到 個位數 FP；風險是 GitGuardian <em>本身會 call 你的 cloud account</em> — vendor trust 跟 <a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a> 的 scope map 需要在 onboarding 就釐清。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>GitGuardian 在 secret scanning stack 中承擔哪一段（pre-commit / SCM scan / SaaS scan / honeytoken）、哪些要外接（<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 管 rotation、IR tool 接 incident）</li>
<li>Detector / Validation / Incident / Source 的 ownership 設計（誰 assign、誰 resolve、developer 怎麼參與）</li>
<li>跨 SCM + SaaS coverage 該開哪些 source、historical scan 多久跑一次</li>
<li>何時用 GitGuardian、何時走 GHAS / Gitleaks / TruffleHog 的取捨</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 GitGuardian deployment 是否健康、最少看四件事：</p>
<ul>
<li><strong>Source coverage 廣度</strong>：除 GitHub / GitLab 外、Slack / Jira / Confluence / Notion 是否也納入掃 — developer 把 token 貼 Slack DM 是常見 leak vector</li>
<li><strong>Validation endpoint 是否開</strong>：FP 降噪靠 live verify、未開等於回到 OSS gitleaks 的 noise 水位</li>
<li><strong>Incident remediation SLA</strong>：valid incident 從偵測到 rotation 完成的時間、是否串 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 自動 rotation、是否進 PagerDuty / Slack alert</li>
<li><strong>ggshield 在 CI 跟 pre-commit 的覆蓋率</strong>：是否所有 repo 走 pre-commit hook、CI step 是否阻擋 commit-with-secret merge</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">Secrets Management at Scale</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Detector library</strong>：350+ specific detector（AWS Access Key / Stripe Live Key / Slack Bot Token / GitHub PAT / 自家 API key pattern 等）+ generic high-entropy detector。Specific detector 走 vendor-specific pattern + validation endpoint、FP 個位數；generic detector 抓 unknown pattern、FP 較高、通常 routing 到 manual triage queue。Production tenant 應該全開 specific、generic 視 noise budget 開。</p>
<p><strong>Validation endpoint</strong>：detector 抓到字串後、GitGuardian backend <em>call 該 service API live verify</em>。AWS key 試 <code>sts:GetCallerIdentity</code>、Stripe key 試 retrieve test event、GitHub PAT 試 <code>GET /user</code>。verify 結果 <em>Valid</em> / <em>Invalid</em> / <em>Unknown</em> 三態、決定 incident severity。意義是 <em>只有 active secret 升 incident</em>、已 revoke 的舊 commit history 不再 noise。</p>
<p><strong>Incident workflow</strong>：偵測命中後會建 <em>Incident</em> 物件（而非直接 alert）、含 source location / detector / validation status / suggested remediation。Incident 可 <em>assign 給 developer</em>（developer 在 GitGuardian dashboard 自助 acknowledge / rotate / mark FP）、SecOps 只 review escalated case。對應 <a href="/blog/backend/07-security-data-protection/security-as-risk-routing-system/" data-link-title="7.15 資安作為風險路由系統" data-link-desc="建立資安作為風險路由系統的導讀大綱，串接問題節點、控制面與跨模組交接">Security Workflow as Code</a> 的 shift-left 模式 — developer 是 first responder、不是 SecOps 全包。</p>
<p><strong>Source coverage</strong>：GitGuardian 預設掃 SCM（GitHub / GitLab / Bitbucket / Azure DevOps / 自管 Git），但 <em>差異化價值在 SaaS scan</em> — Slack workspace（message / DM / file upload）、Jira issue / comment、Confluence page、Notion workspace、Microsoft Teams 都可接 source connector。Developer 在 Slack 貼 prod DB password 是真實常見 case、SCM-only 工具看不到。</p>
<p><strong>ggshield CLI</strong>：本地 / CI 端的 detection engine。<em>pre-commit hook</em> 攔住 push 前 leak（developer 機器、可被 bypass 但成本提高）、<em>CI step</em> 在 PR 跑 historical scan（不可 bypass、阻擋 merge）。跟 GHAS Push Protection 同類、但跨 SCM、且 detector pool 來自同一個 GitGuardian backend、跟 dashboard incident 走同一條 lineage。</p>
<p><strong>Historical scan</strong>：onboarding 第一次跑 <em>full git history scan</em>、回填過去所有 commit 的 leak。意義是 <em>已 leaked 多年的 secret 被找出來、強制 rotation</em>。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a> 的場景：CI 環境 compromise 後、historical scan 在數小時內找出 CI 環境曾接觸過的所有 secret、配合 secret store API 自動 rotation。</p>
<p><strong>Honeytokens</strong>：散佈假 AWS / Stripe / GitHub token 到 repo 角落 / Confluence page / internal doc、attacker 拿到後試用會觸發 alert。是 <em>早期偵測 unauthorized access</em> 的工程化做法、不依賴 detection model 抓 attacker behavior、而是讓 attacker 自己 trigger 自己。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a> — attacker 拿到 OAuth token 後試 GitHub API、honeytoken 在 attacker map 環境時就 trigger。</p>
<p><strong>Rotation 整合</strong>：detect 完不是工作結束、要 <em>rotate the secret</em>。GitGuardian 自身不存 secret，rotation 走 webhook / API 拉 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> / AWS Secrets Manager / Azure Key Vault 觸發 rotation workflow。意義是 <em>偵測跟 remediation 解耦</em>、但需要組織側先把 secret store 接好、否則 incident 只能 manual rotation。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>GitGuardian</th>
          <th>GHAS Secret Scanning</th>
          <th>Gitleaks (OSS)</th>
          <th>TruffleHog</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>部署模型</td>
          <td>SaaS（self-hosted 有 enterprise tier）</td>
          <td>GitHub-only（SaaS / GHES）</td>
          <td>Self-hosted CLI / CI</td>
          <td>Self-hosted CLI / CI / SaaS tier</td>
      </tr>
      <tr>
          <td>Source 範圍</td>
          <td>GitHub / GitLab / Bitbucket / ADO / SaaS</td>
          <td>GitHub repo only</td>
          <td>Git repo（任何 host）</td>
          <td>Git / S3 / Docker / 多 source</td>
      </tr>
      <tr>
          <td>Validation</td>
          <td>內建、350+ detector live verify</td>
          <td>Partner pattern validation（部分）</td>
          <td>無（regex match only）</td>
          <td>有（verified mode）</td>
      </tr>
      <tr>
          <td>Push 攔截</td>
          <td>ggshield pre-commit + CI</td>
          <td>Push Protection（server-side、強制）</td>
          <td>pre-commit hook</td>
          <td>pre-commit hook</td>
      </tr>
      <tr>
          <td>Incident workflow</td>
          <td>內建 Incident + assign + dashboard</td>
          <td>GitHub Alert + Dependabot-like UI</td>
          <td>無（自接 SIEM）</td>
          <td>SaaS tier 有、OSS 無</td>
      </tr>
      <tr>
          <td>Honeytokens</td>
          <td>內建</td>
          <td>無</td>
          <td>無</td>
          <td>無</td>
      </tr>
      <tr>
          <td>計費</td>
          <td>Per developer / contributor（年訂）</td>
          <td>Per active committer（GitHub Enterprise）</td>
          <td>免費</td>
          <td>OSS 免費、SaaS 按 contributor</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>跨 SCM + SaaS、要 workflow + honeytoken</td>
          <td>GitHub-only + 已買 GHAS</td>
          <td>預算敏感 + 自建 IR pipeline</td>
          <td>多 source（含 S3 / Docker）、OSS-friendly</td>
      </tr>
      <tr>
          <td>退場成本</td>
          <td>中 — Incident 歷史在 vendor、detector 通用</td>
          <td>中 — 綁 GitHub UI、export 有限</td>
          <td>低 — 規則自有</td>
          <td>低 — 規則自有</td>
      </tr>
  </tbody>
</table>
<p>選 GitGuardian 的核心訴求：<em>跨 SCM + SaaS coverage + 內建 incident workflow + honeytoken</em>、且能投入 per-developer 訂閱（大型公司 contributor 數會放大成本）+ 有 SecOps 跟 developer 分工承接 incident。GitHub-only 環境且已買 GHAS、重疊不必要、直接用 GHAS；預算敏感且自家有 IR pipeline、走 <a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> 或 TruffleHog OSS。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Honeytokens 散佈策略</strong>：honeytoken 的效果取決於 <em>放在哪裡 + 看起來多真</em>。放 repo README、Confluence runbook、Slack <code>#engineering</code> 過期附件、舊 backup script — attacker reconnaissance 會優先看的地方。token 的命名要跟組織 naming convention 一致（<code>prod-db-readonly-2024</code>）、避免一看就是假的。每個 honeytoken 配 unique ID、trigger 時能定位 <em>attacker 從哪個位置拿到</em>、反推 leak surface。</p>
<p><strong>Validation endpoint 的 trade-off</strong>：validation 是 FP 降噪核心、但代價是 <em>GitGuardian 會 call 你的 cloud account</em>。AWS key 命中時 GitGuardian 從自家 IP call <code>sts:GetCallerIdentity</code>、log 留在你的 CloudTrail。Onboarding 要 <em>把 GitGuardian IP range allowlist 進 SIEM whitelist</em>、避免被自家 detection 誤判為 unauthorized access；同時要評估 vendor trust — 2020 年 GitGuardian 自家 source code 透過第三方 SaaS leak、提醒 vendor 不是 detection-only 的零信任邊界。</p>
<p><strong>IR workflow 整合</strong>：Incident 不應該停在 GitGuardian dashboard、要 routing 到組織既有 IR tooling — PagerDuty for on-call、Slack channel for SecOps、Jira ticket for tracking。Webhook 是標準做法、payload 含 incident metadata + validation status、由組織側決定升級邏輯（valid + prod scope → PagerDuty page；invalid + dev scope → Slack info）。</p>
<p><strong>Historical scan + scope map</strong>：偵測到 leaked secret 後、要回答 <em>這個 secret 還在哪裡用</em>。GitGuardian 的 historical scan 找出 <em>所有 commit 提到該 pattern 的位置</em>、配合組織側 secret store 的 <em>who uses this secret</em> metadata、形成 scope map。對應 <a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a> — rotation 不能只換一個地方、要全 scope 一起換、否則舊 secret 還在某個 service 用、rotation 沒生效。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>Incident volume 爆炸 / developer 看不完</strong>：generic high-entropy detector 全開 + 沒 assign 到 developer — 縮 generic detector scope、incident 走 assign-to-author、SecOps 只 review escalated</li>
<li><strong>Valid incident rotation 慢 / SLA 跑掉</strong>：沒接 secret store rotation API、停在 manual rotation — 接 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> / Secrets Manager webhook、自動觸發 rotation workflow</li>
<li><strong>Slack / Confluence 沒掃進來</strong>：以為 SCM-only 就夠 — 接 SaaS source connector、developer 貼 token 在 Slack DM 是常見 leak vector</li>
<li><strong>ggshield 被 bypass</strong>：pre-commit 在 developer 機器、可 <code>--no-verify</code> — 同步在 CI step 跑 ggshield、CI 不可 bypass、阻擋 merge</li>
<li><strong>Validation FP 不降</strong>：validation endpoint 沒開、或被 firewall 擋 — 確認 GitGuardian IP range 在 cloud account allowlist、validation status 是 <em>Valid</em> 不是 <em>Unknown</em></li>
<li><strong>Honeytoken 沒 trigger / 假警報</strong>：token 放錯位置（attacker 不會看的 deep nested folder）或命名一看就假 — 散佈到 reconnaissance hot spot、命名跟組織 convention 一致</li>
<li><strong>Per-developer 計費暴衝</strong>：contractor / bot account 也算 developer — review billing report、排除 service account / read-only viewer、跟 vendor 談 contributor 定義</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GitHub-only + 已買 GHAS</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a></td>
      </tr>
      <tr>
          <td>預算敏感 + 自建 IR pipeline</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> OSS / TruffleHog OSS</td>
      </tr>
      <tr>
          <td>多 source（S3 / Docker image）</td>
          <td>TruffleHog（覆蓋更多 non-Git source）</td>
      </tr>
      <tr>
          <td>Secret store / rotation</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a> / AWS Secrets Manager / Azure Key Vault</td>
      </tr>
      <tr>
          <td>SIEM correlation / cross-source</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a> / <a href="/blog/backend/07-security-data-protection/vendors/elastic-security/" data-link-title="Elastic Security" data-link-desc="Elastic Stack 上的 SIEM &#43; EDR &#43; Cloud Security 套件、OSS 起源、KQL/EQL/Lucene/ES|QL 多查詢語言、resource-based pricing">Elastic Security</a></td>
      </tr>
      <tr>
          <td>Supply chain build provenance</td>
          <td><a href="https://docs.sigstore.dev/">Sigstore / SLSA vendor 群</a>（同 vendor 章）</td>
      </tr>
      <tr>
          <td>Incident routing</td>
          <td><a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a></td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>ggshield 完整 CLI flag reference 跟 custom detector YAML schema</li>
<li>GitGuardian Internal Monitoring (self-hosted enterprise) 的部署架構細節</li>
<li>Honeytoken 在 active deception / canary token 廣義生態的位置（屬 deception engineering、不在本頁）</li>
<li>Detector pattern 的 regex / entropy 細節（屬 detection engineering）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>GitGuardian 在 07 案例庫沒有直接 vendor-level 事件、但所有 secret leak / supply chain case 都是它的偵測對照：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 GitGuardian 的關係（對照啟示）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a></td>
          <td>Historical scan 在 CI compromise 後數小時內找出 CI 環境曾接觸過的所有 secret、配合 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 自動 rotation、不是 console manual rotation</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a></td>
          <td>Honeytokens 散佈在 repo 跟 Confluence、attacker 拿到 OAuth token 後試 GitHub API 時 trigger、不靠 detection model 抓 attacker behavior</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a></td>
          <td>GitGuardian historical scan 找出 leaked secret 的 <em>scope map</em>（哪些 service 共用同一個 secret）、配合 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 分域 rotation 才完整</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020 Sunburst</a></td>
          <td>secret scanning 抓不到 build pipeline 內 malicious code 注入、要靠 <a href="https://docs.sigstore.dev/">Sigstore / SLSA</a> provenance；secret scanning 是覆蓋一段、不是全部</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">7.x Secrets Management at Scale</a>、<a href="/blog/backend/07-security-data-protection/security-as-risk-routing-system/" data-link-title="7.15 資安作為風險路由系統" data-link-desc="建立資安作為風險路由系統的導讀大綱，串接問題節點、控制面與跨模組交接">Security Workflow as Code</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a>、<a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a>、TruffleHog</li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a>（rotation 接點）、<a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a> / <a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a></li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a>（Incident webhook → SIEM）、<a href="https://docs.sigstore.dev/">Sigstore</a>（build provenance 覆蓋 secret scanning 抓不到的段）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（Incident → IR routing）</li>
<li>官方：<a href="https://docs.gitguardian.com/">GitGuardian Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>LLM Deployment 供應鏈完整性</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/llm-deployment-supply-chain/</link><pubDate>Tue, 12 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/llm-deployment-supply-chain/</guid><description>&lt;p>本章的責任是把 LLM 服務的模型權重、推論伺服器、第三方 plugin / &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/mcp/" data-link-title="MCP（Model Context Protocol）" data-link-desc="LLM application ↔ 外部 tool server 之間的標準化協議、複用 OpenAI 相容 API 的成功模式">MCP&lt;/a> server 三條供應鏈、納入 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.4 供應鏈與產物信任&lt;/a> 的既有框架。模型來源信任的判讀依據見 &lt;a href="https://tarrragon.github.io/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card&lt;/a> 卡；通用 artifact 信任機制見 &lt;a href="https://tarrragon.github.io/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact-provenance&lt;/a> 卡。LLM 場景的特殊性在於模型權重既是「資料」又是「程式邏輯」、第三方 MCP 是可執行程式碼、跟一般 software artifact 的信任模型有部分差異、但 build provenance / signature / dependency isolation 等控制原則沿用同一套。&lt;/p>
&lt;h2 id="本章寫作邊界">本章寫作邊界&lt;/h2>
&lt;p>本章聚焦 production LLM 服務的供應鏈完整性問題節點。個人 dev 視角的模型來源信任見 &lt;a href="https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">llm/6.0 模型供應鏈與信任邊界&lt;/a>；本章不重複個人 dev 場景的判讀、聚焦 production 場景下的特殊議題（規模化下載、跨 region 鏡像、retry 策略、模型 release 流程）。&lt;/p>
&lt;h2 id="本章-threat-scope">本章 threat scope&lt;/h2>
&lt;p>&lt;strong>In-scope&lt;/strong>：模型權重 build provenance（HF organization / 量化者 / Ollama registry）、GGUF / safetensors artifact 完整性、production 下載與鏡像策略、第三方 MCP / plugin 的 deployment 供應鏈、模型版本回退機制。&lt;/p>
&lt;p>&lt;strong>Out-of-scope&lt;/strong>（路由到他章）：&lt;/p>
&lt;ul>
&lt;li>一般 software artifact 信任 → &lt;a href="../supply-chain-integrity-and-artifact-trust/">7.4 supply-chain-integrity-and-artifact-trust&lt;/a>&lt;/li>
&lt;li>機器憑證 → &lt;a href="../secrets-and-machine-credential-governance/">7.6 secrets-and-machine-credential-governance&lt;/a>&lt;/li>
&lt;li>入口治理 → &lt;a href="../entrypoint-and-server-protection/">7.3 entrypoint-and-server-protection&lt;/a>&lt;/li>
&lt;li>個人 dev 模型來源信任 → &lt;a href="https://tarrragon.github.io/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">llm/6.0 model-supply-chain-trust&lt;/a>&lt;/li>
&lt;li>部署平台 → &lt;code>05-deployment-platform&lt;/code>、可靠性 → &lt;code>06-reliability&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="從本章到實作">從本章到實作&lt;/h2>
&lt;p>本章是 routing layer、沿兩條 chain 進入 implementation：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Mechanism&lt;/strong>：問題節點表的 control link 進 knowledge-card、看具體機制與 LLM 場景的差異。&lt;/li>
&lt;li>&lt;strong>Delivery&lt;/strong>：「交接路由」欄位指向 &lt;code>05-deployment-platform / 06-reliability / 08-incident-response&lt;/code>、接配置 / 驗證 / 處置交付。&lt;/li>
&lt;/ul>
&lt;h2 id="llm-供應鏈的三條-chain">LLM 供應鏈的三條 chain&lt;/h2>
&lt;p>LLM 服務的供應鏈跟一般 software 服務的差異在「同時管三條 chain」：&lt;/p>
&lt;ol>
&lt;li>&lt;strong>模型權重 chain&lt;/strong>：原始作者 → 官方 release → 量化者 → registry → production 鏡像&lt;/li>
&lt;li>&lt;strong>推論伺服器 chain&lt;/strong>：llama.cpp / vLLM / Ollama 等 server software 的一般 software artifact chain&lt;/li>
&lt;li>&lt;strong>第三方 plugin / MCP chain&lt;/strong>：MCP server / Continue.dev 等的程式碼供應鏈&lt;/li>
&lt;/ol>
&lt;p>三條 chain 在 production 階段都需要 build provenance、簽署驗證、依賴隔離跟回退機制。差異主要在模型權重 chain 的特殊性：權重是大型 binary（GB 級）、難以靜態 audit、且權重本身會影響推論行為。&lt;/p></description><content:encoded><![CDATA[<p>本章的責任是把 LLM 服務的模型權重、推論伺服器、第三方 plugin / <a href="/blog/llm/knowledge-cards/mcp/" data-link-title="MCP（Model Context Protocol）" data-link-desc="LLM application ↔ 外部 tool server 之間的標準化協議、複用 OpenAI 相容 API 的成功模式">MCP</a> server 三條供應鏈、納入 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.4 供應鏈與產物信任</a> 的既有框架。模型來源信任的判讀依據見 <a href="/blog/llm/knowledge-cards/model-card/" data-link-title="Model Card" data-link-desc="Hugging Face 等平台上模型的 metadata 文件、列出模型來源、訓練資料、能力、限制、授權">model card</a> 卡；通用 artifact 信任機制見 <a href="/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact-provenance</a> 卡。LLM 場景的特殊性在於模型權重既是「資料」又是「程式邏輯」、第三方 MCP 是可執行程式碼、跟一般 software artifact 的信任模型有部分差異、但 build provenance / signature / dependency isolation 等控制原則沿用同一套。</p>
<h2 id="本章寫作邊界">本章寫作邊界</h2>
<p>本章聚焦 production LLM 服務的供應鏈完整性問題節點。個人 dev 視角的模型來源信任見 <a href="/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">llm/6.0 模型供應鏈與信任邊界</a>；本章不重複個人 dev 場景的判讀、聚焦 production 場景下的特殊議題（規模化下載、跨 region 鏡像、retry 策略、模型 release 流程）。</p>
<h2 id="本章-threat-scope">本章 threat scope</h2>
<p><strong>In-scope</strong>：模型權重 build provenance（HF organization / 量化者 / Ollama registry）、GGUF / safetensors artifact 完整性、production 下載與鏡像策略、第三方 MCP / plugin 的 deployment 供應鏈、模型版本回退機制。</p>
<p><strong>Out-of-scope</strong>（路由到他章）：</p>
<ul>
<li>一般 software artifact 信任 → <a href="../supply-chain-integrity-and-artifact-trust/">7.4 supply-chain-integrity-and-artifact-trust</a></li>
<li>機器憑證 → <a href="../secrets-and-machine-credential-governance/">7.6 secrets-and-machine-credential-governance</a></li>
<li>入口治理 → <a href="../entrypoint-and-server-protection/">7.3 entrypoint-and-server-protection</a></li>
<li>個人 dev 模型來源信任 → <a href="/blog/llm/06-security/model-supply-chain-trust/" data-link-title="6.0 模型供應鏈與信任邊界" data-link-desc="個人 dev 用本地 LLM 時的模型權重來源信任：GGUF 完整性、Hugging Face / Ollama registry 信任、量化版本污染、檔案完整性檢查">llm/6.0 model-supply-chain-trust</a></li>
<li>部署平台 → <code>05-deployment-platform</code>、可靠性 → <code>06-reliability</code></li>
</ul>
<h2 id="從本章到實作">從本章到實作</h2>
<p>本章是 routing layer、沿兩條 chain 進入 implementation：</p>
<ul>
<li><strong>Mechanism</strong>：問題節點表的 control link 進 knowledge-card、看具體機制與 LLM 場景的差異。</li>
<li><strong>Delivery</strong>：「交接路由」欄位指向 <code>05-deployment-platform / 06-reliability / 08-incident-response</code>、接配置 / 驗證 / 處置交付。</li>
</ul>
<h2 id="llm-供應鏈的三條-chain">LLM 供應鏈的三條 chain</h2>
<p>LLM 服務的供應鏈跟一般 software 服務的差異在「同時管三條 chain」：</p>
<ol>
<li><strong>模型權重 chain</strong>：原始作者 → 官方 release → 量化者 → registry → production 鏡像</li>
<li><strong>推論伺服器 chain</strong>：llama.cpp / vLLM / Ollama 等 server software 的一般 software artifact chain</li>
<li><strong>第三方 plugin / MCP chain</strong>：MCP server / Continue.dev 等的程式碼供應鏈</li>
</ol>
<p>三條 chain 在 production 階段都需要 build provenance、簽署驗證、依賴隔離跟回退機制。差異主要在模型權重 chain 的特殊性：權重是大型 binary（GB 級）、難以靜態 audit、且權重本身會影響推論行為。</p>
<h2 id="分析模型">分析模型</h2>
<p>production LLM 供應鏈的分析依五個層次拆解、跟 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.4</a> 的層次模型保持一致：</p>
<ol>
<li><strong>來源層</strong>：模型 build provenance 是否可回溯（哪個 base model、用哪個 dataset、由誰量化）。</li>
<li><strong>產物層</strong>：GGUF / safetensors 在傳遞過程的完整性（hash / 簽署）。</li>
<li><strong>依賴層</strong>：MCP server / inference framework / model 各自獨立信任、影響面隔離。</li>
<li><strong>節奏層</strong>：模型版本切換、回退、freeze 流程。</li>
<li><strong>收斂層</strong>：供應鏈事件能否路由到 IR 流程。</li>
</ol>
<h2 id="判讀流程">判讀流程</h2>
<p>判讀流程的責任是把「可部署的 LLM 服務」轉成「可信的 LLM 服務」。</p>
<ol>
<li>先確認模型來源 organization、量化版本、build provenance 可關聯。</li>
<li>再確認 GGUF / safetensors 的完整性證據（hash、size、metadata）。</li>
<li>接著確認模型 + server + plugin 三條 chain 的依賴隔離。</li>
<li>最後交接到可靠性與 incident 流程、追蹤回退能力。</li>
</ol>
<h2 id="問題節點案例觸發式">問題節點（案例觸發式）</h2>
<table>
  <thead>
      <tr>
          <th>問題節點</th>
          <th>判讀訊號</th>
          <th>風險後果</th>
          <th>前置控制面</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>模型來源不可追溯</td>
          <td>HF organization 不明、量化者沒公開 build script</td>
          <td>模型可信度下降、無法 audit、合規問題</td>
          <td><a href="/blog/backend/knowledge-cards/ci-pipeline/" data-link-title="CI Pipeline" data-link-desc="說明持續整合流程如何在合併前驗證品質與相容性">ci-pipeline</a></td>
      </tr>
      <tr>
          <td>GGUF artifact 完整性斷點</td>
          <td>缺 hash 比對、CDN 鏡像未驗證、未簽署</td>
          <td>模型權重被替換、影響推論行為</td>
          <td><a href="/blog/backend/knowledge-cards/deployment-contract/" data-link-title="Deployment Contract" data-link-desc="說明服務與部署平台之間的生命週期約定">deployment-contract</a></td>
      </tr>
      <tr>
          <td>第三方 MCP / plugin 風險放大</td>
          <td>多服務共用同一 MCP server、依賴版本固定</td>
          <td>單一 MCP server 漏洞波及多 service</td>
          <td><a href="/blog/backend/knowledge-cards/dependency-isolation/" data-link-title="Dependency Isolation" data-link-desc="說明如何隔離下游依賴，避免單一依賴耗盡共享資源">dependency-isolation</a></td>
      </tr>
      <tr>
          <td>模型版本切換節奏混亂</td>
          <td>版本切換條件不一致、回退測試缺失</td>
          <td>切換時行為差異未測、production incident</td>
          <td><a href="/blog/backend/knowledge-cards/release-gate/" data-link-title="Release Gate" data-link-desc="說明變更在正式釋出前如何通過或阻擋">release-gate</a></td>
      </tr>
      <tr>
          <td>量化版本污染</td>
          <td>信任未知量化者、未做 behavior regression</td>
          <td>量化過程引入後門或非預期行為</td>
          <td><a href="/blog/backend/knowledge-cards/contract/" data-link-title="Boundary Contract" data-link-desc="說明跨邊界約定如何維持相容與可驗證">contract-test</a></td>
      </tr>
      <tr>
          <td>跨 region 鏡像不一致</td>
          <td>不同 region 跑不同版本權重、cache 政策衝突</td>
          <td>一致性議題、debug 困難</td>
          <td><a href="/blog/backend/knowledge-cards/deployment-contract/" data-link-title="Deployment Contract" data-link-desc="說明服務與部署平台之間的生命週期約定">deployment-contract</a></td>
      </tr>
  </tbody>
</table>
<h2 id="常見風險邊界">常見風險邊界</h2>
<p>風險邊界的責任是界定何時 LLM 供應鏈風險已進入高壓狀態。</p>
<ul>
<li>模型來源（base + dataset + 量化者）長期無法回溯時、代表 provenance 模型失效。</li>
<li>模型 artifact 在 CDN / 鏡像層沒有簽署驗證時、代表完整性邊界不足。</li>
<li>MCP server / plugin 跟 inference framework 共用單一信任域時、代表依賴隔離不足。</li>
<li>模型版本切換沒有 behavior regression test 時、代表 release 流程不收斂。</li>
</ul>
<h2 id="llm-場景的特殊判讀">LLM 場景的特殊判讀</h2>
<p>LLM 供應鏈相對一般 software 供應鏈有幾個特殊點：</p>
<ol>
<li><strong>權重是大型 binary、難以靜態 audit</strong>：跟 source code 不同、權重檔案無法用 grep / diff / linter 找後門；只能用 behavior testing 跟 hash 比對。</li>
<li><strong>量化過程可能改變推論行為</strong>：同一 base model 不同量化版本、回答品質有差；量化者的可信度影響整體可信度、需 case-by-case 信任。</li>
<li><strong>模型 supply chain 跟 production deployment 解耦</strong>：模型釋出方（如 Meta、Qwen 團隊）跟 production 部署方通常不同單位、責任邊界要明確。</li>
<li><strong>「license」議題</strong>：模型權重的 license（如 Llama Community License）跟一般 software license 不同、production 使用需 legal review、不只是技術議題。</li>
<li><strong>MCP server 多為 Node / Python 程式</strong>：跟一般 dependency 一樣有 supply chain 風險、但 LLM 場景下、MCP 對主機資源的副作用面比一般 dependency 大、需更嚴格的 isolation。</li>
</ol>
<h2 id="案例觸發參考">案例觸發參考</h2>
<p>LLM 場景的供應鏈事件案例尚在累積中、本章先沿用 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.4</a> 的通用案例。LLM-specific 案例累積後會補入 <code>red-team/cases/llm-supply-chain/</code>：</p>
<ul>
<li>開源組件滲透與下游衝擊：<a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a>（同類威脅在 MCP server / inference framework 也適用）</li>
<li>平台級供應鏈事件：<a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020</a>（模型釋出方平台級事件適用）</li>
</ul>
<blockquote>
<p><strong>事實查核註</strong>：LLM 供應鏈的公開事件案例累積還在早期、本章列舉的通用案例提供 mechanism 對照、不代表 LLM 場景已有等同規模的事件記錄。建議引用前以最新的 <a href="https://owasp.org/www-project-top-10-for-large-language-model-applications/">OWASP LLM Top 10</a> 跟社群 incident 報告為準。</p></blockquote>
<h2 id="引用標準">引用標準</h2>
<p>LLM 場景的供應鏈標準在發展中、本章沿用 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.4 供應鏈與產物信任</a> 的標準作為 mechanism 層 anchor、補上 LLM-specific 參考：</p>
<table>
  <thead>
      <tr>
          <th>標準</th>
          <th>版本 / 年份</th>
          <th>適用場景</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>SLSA</td>
          <td>v1.0 (2023)</td>
          <td>套用於 inference server + MCP build provenance</td>
      </tr>
      <tr>
          <td>Sigstore（cosign / Rekor / Fulcio）</td>
          <td>continuous</td>
          <td>模型 artifact 簽署實驗階段</td>
      </tr>
      <tr>
          <td>OWASP LLM Top 10</td>
          <td>2025</td>
          <td>LLM application security 通用 reference</td>
      </tr>
      <tr>
          <td>Hugging Face Model Card spec</td>
          <td>continuous</td>
          <td>模型來源 metadata</td>
      </tr>
  </tbody>
</table>
<p>引用版本與 cadence 規則見 <a href="/blog/report/security-citation-currency-and-precision/" data-link-title="Security 標準引用的時效性與精確度" data-link-desc="資安 citation 跟一般技術引用不同——best practice 時效短（MD5 / SHA-1 / bcrypt 100k / TLS 1.0 都曾是 best practice）、原文常被引用扭曲（conditional → unconditional drift）、版本不標 reader 會套用過時 spec。citation 同時涵蓋外部標準（OWASP / RFC / NIST / CIS）跟內部 citation（knowledge-cards / 跨章引用作為 control-of-record）；後者因無版本號 anchor 反而更易 silent drift / broken。每條 citation 必須附：版本 / 年份、引用句意可回溯、deprecated / superseded 標記、強度參數對應 actor 能力的 review trigger（外部）/ last-checked &#43; sync owner（內部）。">security-citation-currency-and-precision</a>。Last reviewed: 2026-05-12。</p>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>交付平台與部署治理：<code>05-deployment-platform</code></li>
<li>發佈驗證與回退演練：<code>06-reliability</code></li>
<li>多租戶 LLM 推論隔離：<a href="/blog/backend/07-security-data-protection/llm-multi-tenant-isolation/" data-link-title="LLM 多租戶推論隔離" data-link-desc="production LLM 服務的多租戶隔離：KV cache 不共享、log / model artifact 隔離、跨用戶 prompt 洩漏面">llm-multi-tenant-isolation</a></li>
<li>偵測訊號設計：<a href="/blog/backend/07-security-data-protection/llm-as-service-detection-coverage/" data-link-title="LLM Service 偵測訊號覆蓋" data-link-desc="production LLM 服務的 detection 訊號設計：tool call 異常模式、prompt injection 觸發徵兆、abuse 跟濫用模式、跟既有 detection-coverage 框架的接合">llm-as-service-detection-coverage</a></li>
<li>分級與跨部門收斂：<code>08-incident-response</code></li>
</ul>
]]></content:encoded></item><item><title>3CX 2023：供應鏈 Artifact 壓力</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/field-cases/3cx-2023-supply-chain-artifact-pressure/</link><pubDate>Thu, 30 Apr 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/field-cases/3cx-2023-supply-chain-artifact-pressure/</guid><description>&lt;p>本案例的責任是提供供應鏈 artifact 壓力素材。3CX 2023 事件顯示，第三方軟體、員工端點、build 系統與客戶下載 artifact 可以形成連鎖供應鏈壓力。&lt;/p>
&lt;h2 id="來源">來源&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>來源&lt;/th>
 &lt;th>可引用範圍&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;a href="https://cloud.google.com/blog/topics/threat-intelligence/3cx-software-supply-chain-compromise">Mandiant：3CX software supply chain compromise&lt;/a>&lt;/td>
 &lt;td>供應鏈連鎖、initial compromise、trojanized desktop app、UNC4736&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://www.3cx.com/blog/news/mandiant-security-update2/">3CX：Initial intrusion vector found&lt;/a>&lt;/td>
 &lt;td>X_TRADER 初始入侵、VEILEDSIGNAL、IOC 與 vendor update&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://www.cisa.gov/news-events/alerts/2023/03/30/supply-chain-attack-against-3cxdesktopapp">CISA：Supply Chain Attack Against 3CXDesktopApp&lt;/a>&lt;/td>
 &lt;td>user guidance、IOC hunting、vendor communications&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="defender-pressure">Defender Pressure&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>壓力&lt;/th>
 &lt;th>服務判讀&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Artifact trust pressure&lt;/td>
 &lt;td>客戶下載的 legitimate app 需要可驗證 provenance&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Build environment pressure&lt;/td>
 &lt;td>build 系統需要和 endpoint compromise 風險分離&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Customer response pressure&lt;/td>
 &lt;td>供應鏈事件需要快速提供 uninstall、hunt 與 update 路由&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Release gate pressure&lt;/td>
 &lt;td>release process 需要能驗證來源、簽章與 build evidence&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="control-gap">Control Gap&lt;/h2>
&lt;p>控制缺口的核心是 artifact trust 需要跨越端點、CI、簽章與發佈流程。當 initial compromise 來自上游軟體時，單一 release gate 需要補足來源信任、build isolation 與 customer communication。&lt;/p>
&lt;h2 id="detection-route">Detection Route&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>訊號&lt;/th>
 &lt;th>判讀用途&lt;/th>
 &lt;th>下一步&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>artifact hash 與預期不一致&lt;/td>
 &lt;td>判斷 release integrity&lt;/td>
 &lt;td>啟動 release freeze 與 rollback&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>build 來源或簽章證據缺口&lt;/td>
 &lt;td>判斷 provenance gap&lt;/td>
 &lt;td>啟動 &lt;a href="https://tarrragon.github.io/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance&lt;/a> review&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>客戶端 IOC 命中&lt;/td>
 &lt;td>判斷 downstream impact&lt;/td>
 &lt;td>啟動 customer advisory route&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="exercise-hook">Exercise Hook&lt;/h2>
&lt;p>本案例可支撐 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/" data-link-title="Supply Chain Artifact Drill" data-link-desc="以 artifact provenance 偏移設計供應鏈 release gate 與 rollback 演練">Supply chain artifact drill&lt;/a>。演練重點是確認 artifact provenance、release freeze、rollback 與 customer communication 是否能在同一事件中協作。&lt;/p>
&lt;h2 id="write-back-target">Write-back Target&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/exercise-write-back-pattern/" data-link-title="Exercise Write-back Pattern" data-link-desc="定義 tabletop 與 game day 如何把 finding 回寫成控制更新、runbook 更新與 [tripwire](/backend/knowledge-cards/tripwire/)">Exercise write-back pattern&lt;/a>&lt;/li>
&lt;/ul></description><content:encoded><![CDATA[<p>本案例的責任是提供供應鏈 artifact 壓力素材。3CX 2023 事件顯示，第三方軟體、員工端點、build 系統與客戶下載 artifact 可以形成連鎖供應鏈壓力。</p>
<h2 id="來源">來源</h2>
<table>
  <thead>
      <tr>
          <th>來源</th>
          <th>可引用範圍</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://cloud.google.com/blog/topics/threat-intelligence/3cx-software-supply-chain-compromise">Mandiant：3CX software supply chain compromise</a></td>
          <td>供應鏈連鎖、initial compromise、trojanized desktop app、UNC4736</td>
      </tr>
      <tr>
          <td><a href="https://www.3cx.com/blog/news/mandiant-security-update2/">3CX：Initial intrusion vector found</a></td>
          <td>X_TRADER 初始入侵、VEILEDSIGNAL、IOC 與 vendor update</td>
      </tr>
      <tr>
          <td><a href="https://www.cisa.gov/news-events/alerts/2023/03/30/supply-chain-attack-against-3cxdesktopapp">CISA：Supply Chain Attack Against 3CXDesktopApp</a></td>
          <td>user guidance、IOC hunting、vendor communications</td>
      </tr>
  </tbody>
</table>
<h2 id="defender-pressure">Defender Pressure</h2>
<table>
  <thead>
      <tr>
          <th>壓力</th>
          <th>服務判讀</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Artifact trust pressure</td>
          <td>客戶下載的 legitimate app 需要可驗證 provenance</td>
      </tr>
      <tr>
          <td>Build environment pressure</td>
          <td>build 系統需要和 endpoint compromise 風險分離</td>
      </tr>
      <tr>
          <td>Customer response pressure</td>
          <td>供應鏈事件需要快速提供 uninstall、hunt 與 update 路由</td>
      </tr>
      <tr>
          <td>Release gate pressure</td>
          <td>release process 需要能驗證來源、簽章與 build evidence</td>
      </tr>
  </tbody>
</table>
<h2 id="control-gap">Control Gap</h2>
<p>控制缺口的核心是 artifact trust 需要跨越端點、CI、簽章與發佈流程。當 initial compromise 來自上游軟體時，單一 release gate 需要補足來源信任、build isolation 與 customer communication。</p>
<h2 id="detection-route">Detection Route</h2>
<table>
  <thead>
      <tr>
          <th>訊號</th>
          <th>判讀用途</th>
          <th>下一步</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>artifact hash 與預期不一致</td>
          <td>判斷 release integrity</td>
          <td>啟動 release freeze 與 rollback</td>
      </tr>
      <tr>
          <td>build 來源或簽章證據缺口</td>
          <td>判斷 provenance gap</td>
          <td>啟動 <a href="/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance</a> review</td>
      </tr>
      <tr>
          <td>客戶端 IOC 命中</td>
          <td>判斷 downstream impact</td>
          <td>啟動 customer advisory route</td>
      </tr>
  </tbody>
</table>
<h2 id="exercise-hook">Exercise Hook</h2>
<p>本案例可支撐 <a href="/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/" data-link-title="Supply Chain Artifact Drill" data-link-desc="以 artifact provenance 偏移設計供應鏈 release gate 與 rollback 演練">Supply chain artifact drill</a>。演練重點是確認 artifact provenance、release freeze、rollback 與 customer communication 是否能在同一事件中協作。</p>
<h2 id="write-back-target">Write-back Target</h2>
<ul>
<li><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li><a href="/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/exercise-write-back-pattern/" data-link-title="Exercise Write-back Pattern" data-link-desc="定義 tabletop 與 game day 如何把 finding 回寫成控制更新、runbook 更新與 [tripwire](/backend/knowledge-cards/tripwire/)">Exercise write-back pattern</a></li>
</ul>
]]></content:encoded></item><item><title>XZ Utils 2024:開源維護者信任壓力</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/field-cases/xz-utils-2024-open-source-maintainer-pressure/</link><pubDate>Thu, 30 Apr 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/field-cases/xz-utils-2024-open-source-maintainer-pressure/</guid><description>&lt;p>本案例的責任是提供開源維護者信任壓力素材。XZ Utils 事件顯示,當攻擊者用兩年時間累積維護者信任、再把 backdoor 植入特定 release artifact 時,只有上游建置時序、發行前測試與快速 distro 回應能在量產前攔截下來。&lt;/p>
&lt;h2 id="來源">來源&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>來源&lt;/th>
 &lt;th>可引用範圍&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;a href="https://www.cisa.gov/news-events/alerts/2024/03/29/reported-supply-chain-compromise-affecting-xz-utils-data-compression-library-cve-2024-3094">CISA alert:XZ Utils CVE-2024-3094&lt;/a>&lt;/td>
 &lt;td>影響版本、降版建議、hunting 指引&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://securitylabs.datadoghq.com/articles/xz-backdoor-cve-2024-3094/">Datadog Security Labs:XZ backdoor 分析&lt;/a>&lt;/td>
 &lt;td>maintainer 接管時間線、artifact 注入機制&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://www.akamai.com/blog/security-research/critical-linux-backdoor-xz-utils-discovered-what-to-know">Akamai:XZ Utils backdoor 摘要&lt;/a>&lt;/td>
 &lt;td>sshd 行為改變、影響面、distro 回應&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://nvd.nist.gov/vuln/detail/cve-2024-3094">NVD:CVE-2024-3094&lt;/a>&lt;/td>
 &lt;td>官方紀錄、影響版本範圍&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="defender-pressure">Defender Pressure&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>壓力&lt;/th>
 &lt;th>服務判讀&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Maintainer trust pressure&lt;/td>
 &lt;td>開源元件治理需要納入維護者社群動態&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Pre-release detection pressure&lt;/td>
 &lt;td>量產前需要有 build artifact 與 sshd 行為驗證&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Distro response pressure&lt;/td>
 &lt;td>受影響 distro 需要快速降版與通報&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Composition awareness pressure&lt;/td>
 &lt;td>服務需要知道自己的 image / package 是否含受影響版本&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="control-gap">Control Gap&lt;/h2>
&lt;p>控制缺口的核心是開源元件信任只看版本與簽章,缺少對維護者活動與 build artifact 行為的監控。XZ Utils 的 backdoor 只在特定 release 路徑啟用,單純依賴上游版本號與 license 檢查會漏掉這類風險。&lt;/p>
&lt;h2 id="detection-route">Detection Route&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>訊號&lt;/th>
 &lt;th>判讀用途&lt;/th>
 &lt;th>下一步&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>受影響版本出現在 image 或 package 清單&lt;/td>
 &lt;td>判斷曝險範圍&lt;/td>
 &lt;td>啟動降版與重建&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>sshd 行為與基線出現偏移&lt;/td>
 &lt;td>判斷 backdoor 啟用可能&lt;/td>
 &lt;td>啟動 forensic preserve&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>上游 maintainer 出現異常活動&lt;/td>
 &lt;td>判斷信任邊界&lt;/td>
 &lt;td>啟動 &lt;a href="https://tarrragon.github.io/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance&lt;/a> review&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="exercise-hook">Exercise Hook&lt;/h2>
&lt;p>本案例可支撐 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/" data-link-title="Supply Chain Artifact Drill" data-link-desc="以 artifact provenance 偏移設計供應鏈 release gate 與 rollback 演練">Supply chain artifact drill&lt;/a> 的開源變體。演練重點是確認團隊能在上游 advisory 出現時,快速比對 SBOM、降版受影響元件並驗證 sshd 行為。&lt;/p>
&lt;h2 id="write-back-target">Write-back Target&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/vulnerability-response-pattern/" data-link-title="Vulnerability Response Pattern" data-link-desc="定義漏洞回應如何從 observed 推進到 assessed、mitigated、patched、validated 與 closed">Vulnerability response pattern&lt;/a>&lt;/li>
&lt;/ul></description><content:encoded><![CDATA[<p>本案例的責任是提供開源維護者信任壓力素材。XZ Utils 事件顯示,當攻擊者用兩年時間累積維護者信任、再把 backdoor 植入特定 release artifact 時,只有上游建置時序、發行前測試與快速 distro 回應能在量產前攔截下來。</p>
<h2 id="來源">來源</h2>
<table>
  <thead>
      <tr>
          <th>來源</th>
          <th>可引用範圍</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="https://www.cisa.gov/news-events/alerts/2024/03/29/reported-supply-chain-compromise-affecting-xz-utils-data-compression-library-cve-2024-3094">CISA alert:XZ Utils CVE-2024-3094</a></td>
          <td>影響版本、降版建議、hunting 指引</td>
      </tr>
      <tr>
          <td><a href="https://securitylabs.datadoghq.com/articles/xz-backdoor-cve-2024-3094/">Datadog Security Labs:XZ backdoor 分析</a></td>
          <td>maintainer 接管時間線、artifact 注入機制</td>
      </tr>
      <tr>
          <td><a href="https://www.akamai.com/blog/security-research/critical-linux-backdoor-xz-utils-discovered-what-to-know">Akamai:XZ Utils backdoor 摘要</a></td>
          <td>sshd 行為改變、影響面、distro 回應</td>
      </tr>
      <tr>
          <td><a href="https://nvd.nist.gov/vuln/detail/cve-2024-3094">NVD:CVE-2024-3094</a></td>
          <td>官方紀錄、影響版本範圍</td>
      </tr>
  </tbody>
</table>
<h2 id="defender-pressure">Defender Pressure</h2>
<table>
  <thead>
      <tr>
          <th>壓力</th>
          <th>服務判讀</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Maintainer trust pressure</td>
          <td>開源元件治理需要納入維護者社群動態</td>
      </tr>
      <tr>
          <td>Pre-release detection pressure</td>
          <td>量產前需要有 build artifact 與 sshd 行為驗證</td>
      </tr>
      <tr>
          <td>Distro response pressure</td>
          <td>受影響 distro 需要快速降版與通報</td>
      </tr>
      <tr>
          <td>Composition awareness pressure</td>
          <td>服務需要知道自己的 image / package 是否含受影響版本</td>
      </tr>
  </tbody>
</table>
<h2 id="control-gap">Control Gap</h2>
<p>控制缺口的核心是開源元件信任只看版本與簽章,缺少對維護者活動與 build artifact 行為的監控。XZ Utils 的 backdoor 只在特定 release 路徑啟用,單純依賴上游版本號與 license 檢查會漏掉這類風險。</p>
<h2 id="detection-route">Detection Route</h2>
<table>
  <thead>
      <tr>
          <th>訊號</th>
          <th>判讀用途</th>
          <th>下一步</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>受影響版本出現在 image 或 package 清單</td>
          <td>判斷曝險範圍</td>
          <td>啟動降版與重建</td>
      </tr>
      <tr>
          <td>sshd 行為與基線出現偏移</td>
          <td>判斷 backdoor 啟用可能</td>
          <td>啟動 forensic preserve</td>
      </tr>
      <tr>
          <td>上游 maintainer 出現異常活動</td>
          <td>判斷信任邊界</td>
          <td>啟動 <a href="/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance</a> review</td>
      </tr>
  </tbody>
</table>
<h2 id="exercise-hook">Exercise Hook</h2>
<p>本案例可支撐 <a href="/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/" data-link-title="Supply Chain Artifact Drill" data-link-desc="以 artifact provenance 偏移設計供應鏈 release gate 與 rollback 演練">Supply chain artifact drill</a> 的開源變體。演練重點是確認團隊能在上游 advisory 出現時,快速比對 SBOM、降版受影響元件並驗證 sshd 行為。</p>
<h2 id="write-back-target">Write-back Target</h2>
<ul>
<li><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li><a href="/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/vulnerability-response-pattern/" data-link-title="Vulnerability Response Pattern" data-link-desc="定義漏洞回應如何從 observed 推進到 assessed、mitigated、patched、validated 與 closed">Vulnerability response pattern</a></li>
</ul>
]]></content:encoded></item><item><title>Supply Chain Artifact Drill</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/</link><pubDate>Thu, 30 Apr 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/scenarios/supply-chain-artifact-drill/</guid><description>&lt;p>本情境的責任是演練 artifact provenance 與 release gate。它以 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/field-cases/3cx-2023-supply-chain-artifact-pressure/" data-link-title="3CX 2023：供應鏈 Artifact 壓力" data-link-desc="把 3CX supply chain compromise 轉成 build、artifact、來源信任與 release gate 的藍隊案例素材">3CX 2023 supply chain case&lt;/a> 為來源，轉成通用軟體供應鏈 artifact drill。&lt;/p>
&lt;h2 id="scenario-trigger">Scenario Trigger&lt;/h2>
&lt;p>客戶回報桌面客戶端或 agent 版本觸發 EDR alert。內部比對發現公開下載 artifact、build record 與簽章證據之間存在偏移。&lt;/p>
&lt;h2 id="initial-hypothesis">Initial Hypothesis&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>假設&lt;/th>
 &lt;th>驗證資料&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>artifact 在 build 後被替換&lt;/td>
 &lt;td>checksum、registry log、publish log&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>build environment 受影響&lt;/td>
 &lt;td>CI log、runner image、credential use&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>upstream dependency 或工具引入污染&lt;/td>
 &lt;td>dependency provenance、developer endpoint evidence&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="control-surface">Control Surface&lt;/h2>
&lt;p>控制面包含 &lt;a href="https://tarrragon.github.io/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance&lt;/a>、CI pipeline、release gate、release freeze、rollback 與 customer advisory。&lt;/p>
&lt;h2 id="response-route">Response Route&lt;/h2>
&lt;ol>
&lt;li>Freeze：暫停 affected artifact 發佈與自動更新。&lt;/li>
&lt;li>Scope：比對 artifact hash、download log、customer version distribution。&lt;/li>
&lt;li>Validate：重建 clean build、驗證簽章與 provenance。&lt;/li>
&lt;li>Rollback：提供 clean artifact、uninstall 或 rollback route。&lt;/li>
&lt;li>Write-back：更新 release gate、build isolation 與 artifact evidence policy。&lt;/li>
&lt;/ol>
&lt;h2 id="evidence-target">Evidence Target&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>證據&lt;/th>
 &lt;th>用途&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>build provenance record&lt;/td>
 &lt;td>判斷 artifact 是否可追溯&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>signing log&lt;/td>
 &lt;td>判斷簽章流程是否被濫用&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>customer download log&lt;/td>
 &lt;td>判斷 downstream impact&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>release freeze record&lt;/td>
 &lt;td>證明風險放行被暫停&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="write-back-target">Write-back Target&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/exercise-write-back-pattern/" data-link-title="Exercise Write-back Pattern" data-link-desc="定義 tabletop 與 game day 如何把 finding 回寫成控制更新、runbook 更新與 [tripwire](/backend/knowledge-cards/tripwire/)">Exercise write-back pattern&lt;/a>&lt;/li>
&lt;/ul></description><content:encoded><![CDATA[<p>本情境的責任是演練 artifact provenance 與 release gate。它以 <a href="/blog/backend/07-security-data-protection/blue-team/materials/field-cases/3cx-2023-supply-chain-artifact-pressure/" data-link-title="3CX 2023：供應鏈 Artifact 壓力" data-link-desc="把 3CX supply chain compromise 轉成 build、artifact、來源信任與 release gate 的藍隊案例素材">3CX 2023 supply chain case</a> 為來源，轉成通用軟體供應鏈 artifact drill。</p>
<h2 id="scenario-trigger">Scenario Trigger</h2>
<p>客戶回報桌面客戶端或 agent 版本觸發 EDR alert。內部比對發現公開下載 artifact、build record 與簽章證據之間存在偏移。</p>
<h2 id="initial-hypothesis">Initial Hypothesis</h2>
<table>
  <thead>
      <tr>
          <th>假設</th>
          <th>驗證資料</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>artifact 在 build 後被替換</td>
          <td>checksum、registry log、publish log</td>
      </tr>
      <tr>
          <td>build environment 受影響</td>
          <td>CI log、runner image、credential use</td>
      </tr>
      <tr>
          <td>upstream dependency 或工具引入污染</td>
          <td>dependency provenance、developer endpoint evidence</td>
      </tr>
  </tbody>
</table>
<h2 id="control-surface">Control Surface</h2>
<p>控制面包含 <a href="/blog/backend/knowledge-cards/artifact-provenance/" data-link-title="Artifact Provenance" data-link-desc="說明交付物的來源、完整性與簽章關聯如何建立信任">artifact provenance</a>、CI pipeline、release gate、release freeze、rollback 與 customer advisory。</p>
<h2 id="response-route">Response Route</h2>
<ol>
<li>Freeze：暫停 affected artifact 發佈與自動更新。</li>
<li>Scope：比對 artifact hash、download log、customer version distribution。</li>
<li>Validate：重建 clean build、驗證簽章與 provenance。</li>
<li>Rollback：提供 clean artifact、uninstall 或 rollback route。</li>
<li>Write-back：更新 release gate、build isolation 與 artifact evidence policy。</li>
</ol>
<h2 id="evidence-target">Evidence Target</h2>
<table>
  <thead>
      <tr>
          <th>證據</th>
          <th>用途</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>build provenance record</td>
          <td>判斷 artifact 是否可追溯</td>
      </tr>
      <tr>
          <td>signing log</td>
          <td>判斷簽章流程是否被濫用</td>
      </tr>
      <tr>
          <td>customer download log</td>
          <td>判斷 downstream impact</td>
      </tr>
      <tr>
          <td>release freeze record</td>
          <td>證明風險放行被暫停</td>
      </tr>
  </tbody>
</table>
<h2 id="write-back-target">Write-back Target</h2>
<ul>
<li><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact 信任</a></li>
<li><a href="/blog/backend/07-security-data-protection/security-risk-in-release-gate/" data-link-title="7.22 資安風險如何進入 Release Gate" data-link-desc="把資安風險、例外與驗證證據納入 release gate，建立可稽核的放行判準">7.22 資安風險如何進入 Release Gate</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/detection-lifecycle-pattern/" data-link-title="Detection Lifecycle Pattern" data-link-desc="定義偵測規則如何管理來源、邏輯、測試事件、誤報與退場">Detection lifecycle pattern</a></li>
<li><a href="/blog/backend/07-security-data-protection/blue-team/materials/control-patterns/exercise-write-back-pattern/" data-link-title="Exercise Write-back Pattern" data-link-desc="定義 tabletop 與 game day 如何把 finding 回寫成控制更新、runbook 更新與 [tripwire](/backend/knowledge-cards/tripwire/)">Exercise write-back pattern</a></li>
</ul>
]]></content:encoded></item></channel></rss>