資安週報Security Weekly 攻擊手法通報 × 資安工具Advisories × Tooling
密鑰管理Secrets management MIT(核心)/ee 目錄另有企業授權

Infisical

集中管理應用程式密鑰與憑證的平台,目的是讓金鑰從一開始就不要進到程式碼裡。A platform for centralising application secrets and credentials, so keys never enter the codebase in the first place.

這是什麼What it is

金鑰外洩的真正難處不在「發現」,而在它一旦進過版本控制就幾乎洗不掉。把金鑰從程式碼刪除、提交修正,表面上解決了——但那一行仍留在 Git 的歷史紀錄裡,任何能複製儲存庫的人都讀得到。

本期的 GhostAction 攻擊正是利用這一點:新版惡意工作流程會主動翻查提交歷史,專門尋找開發者已經刪掉、卻仍留在過去紀錄中的金鑰。

Infisical 處理的是源頭問題:密鑰集中存放於伺服器,應用程式在執行期取用,程式碼裡只留參照而非值。它提供依環境(開發/測試/正式)與專案區隔的存放、存取控制與稽核紀錄、金鑰輪換,以及與 CI/CD、Kubernetes、各家雲端的整合。

它也內建密鑰掃描,可在提交前攔截——這是補救既有問題的那一半。

The hard part about a leaked key is not finding it but that once it has entered version control it is nearly impossible to remove. Delete the key, commit the fix, and the problem looks solved — yet that line remains in Git history, readable by anyone who can clone the repository.

The GhostAction campaign covered in this issue exploits exactly that: its newer malicious workflows mine commit history specifically for keys developers had deleted but which survive in past commits.

Infisical addresses the source of the problem: secrets live on a server, applications fetch them at runtime, and the code carries a reference rather than a value. It offers storage separated by environment (development, staging, production) and project, access control and audit logging, rotation, and integrations with CI/CD, Kubernetes, and the major clouds.

It also ships secret scanning to catch keys before they are committed — the other half, for cleaning up what you already have.

什麼時候用得上When to use it

- 新專案從一開始就不要有 .env 進版控,這是最省事的時機
- CI/CD 取用憑證:讓建置流程在執行期取得金鑰,而不是存成儲存庫的 secret 變數
- 提交前攔截:掛上 pre-commit 掃描,避免金鑰進入歷史紀錄
- 既有專案的收斂:先掃描歷史紀錄找出已外洩的金鑰並全部輪換——這一步比遷移本身更急迫,因為那些金鑰可能早已被取走

導入順序建議由正式環境的高價值憑證開始,而非一次搬遷全部。

- Keep .env out of version control from day one on new projects — by far the cheapest moment to get this right
- CI/CD credential fetching: have pipelines retrieve secrets at runtime instead of storing them as repository secret variables
- Pre-commit interception: hook in scanning so keys never reach history
- Cleaning up existing projects: first scan history for already-leaked keys and rotate every one of them — more urgent than the migration itself, because those keys may have been taken long ago

Start with high-value production credentials rather than migrating everything at once.

注意事項Caveats

授權採開放核心模式:核心為 MIT Expat,但儲存庫 ee/ 目錄下的內容適用另一份企業授權。自架前請先確認您需要的功能落在哪一邊——這一點在評估階段就該釐清,不要等到部署後才發現關鍵功能需要付費授權。

架構上要意識到:集中管理代表把所有雞蛋放進一個籃子。這台伺服器成為最高價值的目標,其存取控制、備份與可用性都必須比照關鍵系統辦理;服務中斷時應用程式可能無法取得憑證而啟動失敗,導入前要先確認快取與降級行為。

Open-core licensing: the core is MIT Expat, but content under the repository's ee/ directory falls under a separate enterprise licence. Before self-hosting, confirm which side the features you need sit on — settle this during evaluation rather than discovering after deployment that something essential requires a paid licence.

Architecturally, be clear that centralisation puts every egg in one basket. That server becomes your highest-value target, and its access control, backups, and availability must be treated as critical infrastructure. An outage can leave applications unable to fetch credentials and fail to start, so confirm caching and degradation behaviour before rollout.

安裝Install

brew install infisical/get-cli/infisical
# 或 / or
npm install -g @infisical/cli

快速上手Quick start

# 登入並連結專案
infisical login
infisical init

# 以注入環境變數的方式執行,程式碼中不留金鑰
infisical run -- npm start

# 掃描儲存庫歷史紀錄中是否有外洩的金鑰
infisical scan --verbose

出現在Featured in