<?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>Google-Secret-Manager on Tarragon</title><link>https://tarrragon.github.io/blog/tags/google-secret-manager/</link><description>Recent content in Google-Secret-Manager on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Mon, 18 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/google-secret-manager/index.xml" rel="self" type="application/rss+xml"/><item><title>Google Secret Manager</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-secret-manager/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-secret-manager/</guid><description>&lt;p>Google Secret Manager（GSM）是 GCP 原生的 &lt;em>static secret 集中保管&lt;/em> 服務、設計上刻意保持 &lt;em>簡單&lt;/em>：只負責 secret 儲存、版本管理、IAM 授權、跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &amp;#43; Cloud HSM &amp;#43; External Key Manager">Cloud KMS&lt;/a> 整合的 envelope encryption。rotation orchestration、cross-region replication policy、dynamic credential issuing 都不在 GSM 自己做、留給上層用 Cloud Function / Cloud Run 自組。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &amp;#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager&lt;/a> 最大的差異是 &lt;em>沒有 built-in rotation Lambda&lt;/em> — rotation logic 要自己寫、GSM 只提供 &lt;em>Rotation Schedule + Pub/Sub event&lt;/em> 當觸發點。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>GSM 的定位是 &lt;em>GCP-native 的 secret 集中點&lt;/em>、解決三件事：把 secret 從 environment variable / Cloud Build substitution / GitHub secret 收回單一受控位置；用 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM&lt;/a> 的 &lt;em>role binding on secret resource&lt;/em> 控制誰能讀；走 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Workload Identity Federation&lt;/a> 讓 GKE / Cloud Run / 外部 workload（GitHub Actions / AWS / Azure）安全取用、避免長期 service account key 散落。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/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&lt;/a> 比、GSM 沒有 dynamic credential engine、沒有 transit / PKI engine、沒有跨雲統一介面 — 但運維成本接近於零、跟 GCP IAM / KMS / Cloud Logging 的整合是 first-class。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &amp;#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager&lt;/a> 比、GSM 把 rotation orchestration 推給應用層、自由度高但代價是 &lt;em>rotation 流程要自己設計&lt;/em>；跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &amp;#43; Key &amp;#43; Certificate）、整合 Managed Identity &amp;#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault&lt;/a> 比、兩者 mindset 相近（單雲、IAM-driven、CMEK 整合）、各自綁雲。&lt;/p></description><content:encoded><![CDATA[<p>Google Secret Manager（GSM）是 GCP 原生的 <em>static secret 集中保管</em> 服務、設計上刻意保持 <em>簡單</em>：只負責 secret 儲存、版本管理、IAM 授權、跟 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud KMS</a> 整合的 envelope encryption。rotation orchestration、cross-region replication policy、dynamic credential issuing 都不在 GSM 自己做、留給上層用 Cloud Function / Cloud Run 自組。跟 <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> 最大的差異是 <em>沒有 built-in rotation Lambda</em> — rotation logic 要自己寫、GSM 只提供 <em>Rotation Schedule + Pub/Sub event</em> 當觸發點。</p>
<h2 id="服務定位">服務定位</h2>
<p>GSM 的定位是 <em>GCP-native 的 secret 集中點</em>、解決三件事：把 secret 從 environment variable / Cloud Build substitution / GitHub secret 收回單一受控位置；用 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a> 的 <em>role binding on secret resource</em> 控制誰能讀；走 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Workload Identity Federation</a> 讓 GKE / Cloud Run / 外部 workload（GitHub Actions / AWS / Azure）安全取用、避免長期 service account key 散落。</p>
<p>跟 <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> 比、GSM 沒有 dynamic credential engine、沒有 transit / PKI engine、沒有跨雲統一介面 — 但運維成本接近於零、跟 GCP IAM / KMS / Cloud Logging 的整合是 first-class。跟 <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> 比、GSM 把 rotation orchestration 推給應用層、自由度高但代價是 <em>rotation 流程要自己設計</em>；跟 <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> 比、兩者 mindset 相近（單雲、IAM-driven、CMEK 整合）、各自綁雲。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>哪些 secret 適合 GSM（GCP-only、static、靠 IAM 授權即可）、哪些該走 <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> 或其他雲端 native</li>
<li>GSM 最低安全設定（CMEK、Data Access audit、Workload Identity Federation、IAM Conditions）</li>
<li>自寫 rotation Cloud Function 時必須處理的 <em>版本切換窗口</em> 跟 <em>fallback 邏輯</em></li>
<li>何時 GSM 不夠用、要往 Vault / Berglas / Cloud HSM 走</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判讀一個 GSM deployment 是否健康、最少看四件事：</p>
<ul>
<li><strong>誰能讀 secret</strong>：secret resource 上的 IAM binding 是不是用最小單位授權（per-secret、不是 project-level <code>roles/secretmanager.secretAccessor</code>）、有沒有上 IAM Conditions 限定時間 / IP / resource tag</li>
<li><strong>Key custody 分離</strong>：encryption key 是 Google-managed default key、還是 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud KMS</a> CMEK？CMEK 的 key 持有 admin 跟 secret access admin 是不是分人</li>
<li><strong>取用路徑</strong>：workload 取 secret 是走 <em>service account key</em>（壞模式、長期憑證散落）還是 <em>Workload Identity Federation</em>（GKE WIF / 外部 OIDC token exchange）</li>
<li><strong>證據是否可回查</strong>：Admin Activity audit 預設開、Data Access audit（<code>AccessSecretVersion</code> 誰呼叫）預設 <em>關</em>、production 要手動 enable + 接 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Cloud Logging sink</a> 推到 SIEM</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/knowledge-cards/audit-log/" data-link-title="Audit Log" data-link-desc="說明高風險操作如何留下可追溯、可稽核的紀錄">Audit Log</a> 與 <a href="/blog/backend/knowledge-cards/secret-management/" data-link-title="Secret Management" data-link-desc="說明 token、key、password 與憑證如何保存、輪替與撤銷">Secret Management</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>IAM Conditions 收 scope</strong>：GSM 的 secretAccessor role 預設綁到 secret resource、但組織常見錯配是給整個 project 上 <code>roles/secretmanager.secretAccessor</code> — 等於整個 project 所有 secret 都能讀。應該用 <em>per-secret binding</em>、再加 IAM Conditions（<code>resource.name.endsWith('prod-db-password')</code>、<code>request.time &lt; timestamp('...')</code>）限縮時間窗口。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/identity-access/okta-cloudflare-2023-support-supply-chain/" data-link-title="7.R7.1.2 Okta &#43; Cloudflare 2023：支援流程與身分供應鏈" data-link-desc="支援工單與第三方身份供應商路徑如何變成入侵鏈的一部分">Okta Cloudflare 2023 supply chain</a> 的對照啟示：第三方 token scope 過寬時、上游事件直接傳導下游、IAM Conditions 是收 scope 的工具。</p>
<p><strong>Secret Version + Alias 模型</strong>：每個 secret 有 monotonic version（v1、v2、v3…）、預設 alias <code>latest</code> 指向最新 enabled version。rotation 不是「更新現有 secret」、是 <em>建立新 version + 把舊 version disable</em>。應用端要支援 <em>讀新 version 失敗時 fallback 舊 version</em>、或在 rotation Cloud Function 內實作 <em>雙軌驗證窗口</em>（新版本上線後一段時間舊版還能讀、確認所有 consumer 切過去再 destroy 舊版）。沒這層設計、一次 rotation 就會打掉沒及時更新的 consumer。</p>
<p><strong>CMEK（Customer-Managed Encryption Key）</strong>：GSM 預設用 Google-managed key、production 應該指向 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud KMS</a> CMEK。意義是 <em>把 key 持有跟 secret 取用分離</em> — 即使 secret admin 被攻破、沒有 CMEK 的 <code>decrypt</code> 權限拿不到明文。代價是 CMEK key region 跟 secret replication 要對齊（key 在 <code>us-central1</code> 但 secret 設 automatic replication = key 進不去其他 region、secret access 會失敗）。</p>
<p><strong>Replication 策略</strong>：automatic 是 GCP 自動跨 region replicate（高可用、不需要管 region 一致性、但 data residency 受 GCP 全球策略支配）；user-managed 是手動指定 region list（精細控制資料駐留、適合有 GDPR / 跨境合規需求的場景、但 region 加減要自己管 + CMEK key 要在每個指定 region 都存在）。一個常見錯配：選 user-managed 但只設一個 region — 等於沒有跨 region 冗餘、該 region 出事 secret 完全讀不到。</p>
<p><strong>Rotation 是自管 schedule</strong>：GSM 提供的不是 rotation logic、是 <em>Rotation Schedule</em>（cron 或固定間隔）、到期會發 <em>Pub/Sub message</em> 到指定 topic、由 <em>自己寫的 Cloud Function / Cloud Run</em> 訂閱該 topic 執行實際 rotation（呼叫上游系統 API 生新 credential、寫成新 secret version、disable 舊 version）。對應 <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 Cloud Function 必須自己處理 <em>scope map</em>（哪些 consumer 用了同一把 secret）跟 <em>雙軌驗證窗口</em>（confirm 所有 consumer 切到新版本才 disable 舊版）、不像 AWS Secrets Manager 有 built-in 四階段 flow（<code>createSecret</code> → <code>setSecret</code> → <code>testSecret</code> → <code>finishSecret</code>）。</p>
<p><strong>Workload Identity Federation 取用</strong>：external workload（GitHub Actions / AWS workload / Azure workload / on-prem K8s）用 WIF 拿 GSM secret 是現代預設模式 — workload 用自己的 OIDC token（GitHub OIDC、AWS STS）跟 GCP STS 交換 short-lived access token、再用 token 呼叫 GSM。避開了「長期 service account JSON key 散落 CI / 第三方環境」的問題。GKE 內 workload 走 <em>GKE Workload Identity</em>（pod ServiceAccount → GCP service account 綁定）取 secret、也是同 mindset。</p>
<p><strong>Audit log 治理</strong>：GSM 的 audit 分兩層 — Admin Activity（create / delete / IAM 變更、預設開、免費）、Data Access（<code>AccessSecretVersion</code>、預設 <em>關</em>、開啟有 log 量跟 BigQuery export cost）。production 不開 Data Access = 事故時 <em>連 secret 被誰取過都查不到</em>、必須在 project IAM Audit Config 開、Cloud Logging sink 推到 SIEM 或 BigQuery（見 <a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a>）。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Google Secret Manager</th>
          <th>HashiCorp Vault</th>
          <th>AWS Secrets Manager</th>
          <th>Azure Key Vault</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>部署模型</td>
          <td>GCP managed</td>
          <td>自管 cluster（HA + replication）</td>
          <td>AWS managed</td>
          <td>Azure managed</td>
      </tr>
      <tr>
          <td>跨雲</td>
          <td>弱 — 綁 GCP</td>
          <td>強 — 同一介面跨 AWS / GCP / Azure / on-prem</td>
          <td>弱 — 綁 AWS</td>
          <td>弱 — 綁 Azure</td>
      </tr>
      <tr>
          <td>Rotation 模型</td>
          <td>自寫 Cloud Function（Pub/Sub trigger）</td>
          <td>dynamic engine 自動 lease</td>
          <td>built-in Lambda 四階段 flow</td>
          <td>自寫 Function App（Event Grid trigger）</td>
      </tr>
      <tr>
          <td>Dynamic credential</td>
          <td>無（靠 IAM impersonation 替代）</td>
          <td>DB / cloud / SSH engine 完整</td>
          <td>RDS rotation 有、cloud STS 較弱</td>
          <td>較弱（依靠 Managed Identity）</td>
      </tr>
      <tr>
          <td>Encryption key</td>
          <td>Google-managed default / <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud KMS</a> CMEK</td>
          <td>自管 / KMS auto-unseal</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/aws-kms/" data-link-title="AWS KMS" data-link-desc="AWS 原生 key management service、envelope encryption / digital signing / Multi-Region Key、Key Policy &#43; Grant 雙軌授權">AWS KMS</a> CMK</td>
          <td>Azure Key Vault key</td>
      </tr>
      <tr>
          <td>External workload</td>
          <td>Workload Identity Federation（成熟）</td>
          <td>AppRole / Kubernetes / OIDC auth</td>
          <td>IAM Roles Anywhere（較新）</td>
          <td>Managed Identity / Workload Identity</td>
      </tr>
      <tr>
          <td>運維成本</td>
          <td>低</td>
          <td>高 — HA、upgrade、replication 自己顧</td>
          <td>低</td>
          <td>低</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>GCP-heavy + WIF 已主導 + static secret 為主</td>
          <td>跨雲、dynamic credential、內部 PKI</td>
          <td>AWS-heavy + 需要 built-in rotation 收斂</td>
          <td>Azure-heavy + Managed Identity 已主導</td>
      </tr>
      <tr>
          <td>退場成本</td>
          <td>低</td>
          <td>中 — dynamic engine 接線多</td>
          <td>低</td>
          <td>低</td>
      </tr>
  </tbody>
</table>
<p>選 GSM 的核心訴求：workload 主要跑在 GCP（GKE / Cloud Run / Cloud Build）、已經用 Workload Identity Federation 收 service account key、secret 形態以 static 為主（DB password、third-party API key、private key）、rotation 邏輯願意用 Cloud Function 自寫。要跨雲、要 dynamic credential、要內建 rotation flow、需要 transit encryption — 走 <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>。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>CMEK + Cloud KMS 雙軌權限分離</strong>：production 應該 <em>至少</em> 把 prod secret 的 CMEK key 跟 secret IAM 分到不同 admin group — secret admin 可以建 / 改 secret 但不能 decrypt（沒 KMS <code>cloudkms.cryptoKeyDecrypter</code>），KMS admin 可以管 key 但不能讀 secret 內容。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/identity-access/microsoft-storm-0558-2023-signing-key-chain/" data-link-title="7.R7.1.5 Microsoft Storm-0558 2023：簽章金鑰鏈與郵件存取" data-link-desc="從簽章金鑰保護失效到雲端郵件存取，拆解身分信任鏈的關鍵控制點">Microsoft Storm-0558 signing key chain</a> 的對照啟示：key 不離 KMS 邊界、跟 HSM-bound 同 mindset；CMEK 是把這個原則內建到 secret 路徑。</p>
<p><strong>Berglas（OSS pattern）</strong>：<a href="https://github.com/GoogleCloudPlatform/berglas">Berglas</a> 是 Google 開源的 GSM client library + CLI、在 Cloud Run / Cloud Function / GKE 啟動時把 <code>sm://...</code> 參考自動 resolve 成實際 secret value、注進環境變數或檔案。比起應用端寫 SDK 取 secret 的好處：<em>secret 不進 container image / build manifest</em>、只有 runtime 取得；缺點是多一層 dependency、且 Berglas 自己有 IAM 需求要管。</p>
<p><strong>GKE Workload Identity 取用</strong>：GKE pod 用 ServiceAccount → IAM service account 綁定（透過 <code>iam.gke.io/gcp-service-account</code> annotation）、pod 內呼叫 GSM API 自動帶 GCP service account 身份、metadata server 簽 token。比起把 service account JSON key mount 進 pod、Workload Identity 沒有長期 credential 在 pod 內、credential rotation 由 GCP metadata 自動處理。</p>
<p><strong>Secret rotation Cloud Function 樣板</strong>：訂閱 secret 的 rotation topic（Pub/Sub）、message 帶 secret name 跟 trigger reason；Function 內呼叫上游系統 API（DB / SaaS）生新 credential、用 <code>secretmanager.AddSecretVersion</code> 寫新 version、等一段時間（雙軌驗證窗口）後 <code>DisableSecretVersion</code> 舊 version、最後 <code>DestroySecretVersion</code> 完成 rotation。<strong>雙軌窗口的長度必須大於 consumer 的最長 cache TTL</strong>、否則沒及時 refresh 的 consumer 會在 disable 後失敗。</p>
<p><strong>Pub/Sub event subscription（new in 2023+）</strong>：除了 rotation schedule 自動發 event、GSM 也支援對 secret 任意變更（new version、IAM change）發 Pub/Sub message、可接 SOAR / SIEM 做 <em>secret 異常變更告警</em>（例：非 CI service account 在週末新增 secret version）。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>取 secret 拿到 PERMISSION_DENIED</strong>：通常是 IAM binding 在 project 層但 secret 在某 sub-resource、或 IAM Conditions 把當前 caller 排除 — 用 <code>gcloud secrets get-iam-policy</code> 直接看 binding、確認 condition 表達式</li>
<li><strong>CMEK 設定後突然讀不到 secret</strong>：CMEK key region 跟 secret replication region 不對齊、或 caller 沒有 KMS decrypt 權限 — 確認 key 在所有 replication region 都有版本、secret accessor service account 有 <code>cloudkms.cryptoKeyDecrypter</code></li>
<li><strong>Rotation Cloud Function 跑了但 consumer 認證失敗</strong>：雙軌窗口太短或 consumer 沒實作 <em>latest version 失敗 fallback</em>、舊版 disable 後孤兒 consumer 直接斷 — 把雙軌窗口拉到 cache TTL × 2、補 fallback 邏輯</li>
<li><strong>Data Access audit 沒紀錄</strong>：預設關、要在 project IAM Audit Config 明確開 <code>secretmanager.googleapis.com</code> 的 DATA_READ — 不開等於沒辦法回答「事故當下誰讀了 secret」</li>
<li><strong>External workload 拿不到 secret</strong>：Workload Identity Federation 的 provider attribute mapping 沒對齊（GitHub OIDC token 的 <code>repository</code> claim 沒被 map 到 attribute condition）— 走 <code>gcloud iam workload-identity-pools providers describe</code> 看 mapping、用 token introspection 驗實際 claim</li>
<li><strong>Secret version 累積過多</strong>：rotation 只 disable 不 destroy、版本無限長 — 加 lifecycle policy（手動 / Cloud Function 排程）destroy 超過 N 個版本以前的舊版</li>
<li><strong>GKE pod 用 Workload Identity 但拿不到 secret</strong>：通常是 GKE 沒 enable Workload Identity feature、或 <code>iam.gke.io/gcp-service-account</code> annotation 拼錯、或 GCP service account 沒給 K8s ServiceAccount <code>iam.workloadIdentityUser</code> — 三層都要對才能通</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>跨雲 secret 統一介面</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></td>
      </tr>
      <tr>
          <td>需要 dynamic database / cloud credential</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> dynamic engine</td>
      </tr>
      <tr>
          <td>需要 built-in 四階段 rotation flow</td>
          <td><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>（若可遷 AWS）</td>
      </tr>
      <tr>
          <td>Encryption-as-a-service / 內部 PKI</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> transit / PKI engine</td>
      </tr>
      <tr>
          <td>FIPS 140-2 Level 3 HSM 需求</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud HSM</a>（KMS 後端可改 HSM）</td>
      </tr>
      <tr>
          <td>公開憑證 PKI</td>
          <td>Google Certificate Authority Service / <a href="/blog/backend/07-security-data-protection/vendors/letsencrypt/" data-link-title="Let&#39;s Encrypt" data-link-desc="免費 &#43; 自動化的公共 ACME CA、90 天 TTL 強制自動化、跨雲跨平台 public TLS cert 的事實基礎">Let&rsquo;s Encrypt</a></td>
      </tr>
      <tr>
          <td>K8s workload cert 自動化</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/cert-manager/" data-link-title="cert-manager" data-link-desc="K8s 原生 certificate lifecycle automation、支援 Let&#39;s Encrypt / Vault PKI / Venafi 等多 issuer、auto-renewal &#43; Challenge solver">cert-manager</a></td>
      </tr>
      <tr>
          <td>Secret rotation 證據鏈</td>
          <td><a href="/blog/backend/07-security-data-protection/credential-rotation-scoped-evidence/" data-link-title="7.27 Credential Rotation with Scoped Evidence 實作示範" data-link-desc="以 webhook/API credential 輪替示範 scope map、證據欄位與回退窗口如何一起設計。">7.5 Credential Rotation Scoped Evidence</a></td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>GSM 完整 REST API 跟 <code>gcloud secrets</code> 詳盡子命令</li>
<li>Cloud KMS key lifecycle 跟 rotation 細節（看 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Google Cloud KMS</a> 章）</li>
<li>Workload Identity Federation 完整設定步驟（attribute mapping、condition expression、provider 設定看 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a> 章）</li>
<li>Berglas 完整 CLI 用法</li>
<li>Cloud Function / Cloud Run 部署細節</li>
<li>GCP Organization Policy 跟 secret 跨 project 共享的進階場景</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>GSM 在 07 案例庫沒有直接 vendor-level 事件、以下案例採對照引用：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 GSM 的關係（對照）</th>
      </tr>
  </thead>
  <tbody>
      <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>GSM rotation 是自寫 Cloud Function、scope map 跟雙軌驗證窗口都要自己設計、不像 AWS Secrets Manager 有 built-in 四階段 flow — 設計時就要把 consumer scope 跟 cache TTL 算進 rotation 排程</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/identity-access/microsoft-storm-0558-2023-signing-key-chain/" data-link-title="7.R7.1.5 Microsoft Storm-0558 2023：簽章金鑰鏈與郵件存取" data-link-desc="從簽章金鑰保護失效到雲端郵件存取，拆解身分信任鏈的關鍵控制點">Microsoft Storm-0558 Signing Key Chain (red-team)</a></td>
          <td>對照啟示 — GSM CMEK 把 encryption key 放 <a href="/blog/backend/07-security-data-protection/vendors/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Cloud KMS</a>、key 不離 KMS 邊界、跟 HSM-bound 同 mindset；secret admin 跟 KMS admin 分人是減 blast radius 的關鍵</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/identity-access/okta-cloudflare-2023-support-supply-chain/" data-link-title="7.R7.1.2 Okta &#43; Cloudflare 2023：支援流程與身分供應鏈" data-link-desc="支援工單與第三方身份供應商路徑如何變成入侵鏈的一部分">Okta Cloudflare 2023 Support Supply Chain (red-team)</a></td>
          <td>對照啟示 — GSM 管的第三方 token（GitHub PAT / Slack token / SaaS API key）scope 過寬時、上游事件直接傳導下游、要走 IAM Conditions 收 caller scope 跟過期時間</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.6 秘密管理與機器憑證治理</a>、<a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a></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>、<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/google-cloud-kms/" data-link-title="Google Cloud KMS" data-link-desc="GCP 原生 key management service、KeyRing / CryptoKey Version 設計、CMEK 整合 &#43; Cloud HSM &#43; External Key Manager">Google Cloud KMS</a>（GSM CMEK 後端、key custody 分離）</li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/google-cloud-iam/" data-link-title="Google Cloud IAM" data-link-desc="GCP cloud resource permission engine、Role Binding / Service Account / Workload Identity Federation、resource hierarchy 為核心的權限治理">Google Cloud IAM</a>（secret IAM binding、Workload Identity Federation 設定）</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>（GSM 事件如何 routing 進 IR 流程）</li>
<li>官方：<a href="https://cloud.google.com/secret-manager/docs">Secret Manager Documentation</a></li>
</ul>
]]></content:encoded></item></channel></rss>