{
  "schema": "aidefend-secureflow-metadata-v1",
  "flow_id": "aidefend-research-sf0063-plugin4shell-git-reference-pinning-bypass",
  "title": "Plugin4Shell: Git Reference Shadowing Defeats Reviewed Plugin Pins",
  "subtitle": "Two source-backed checkout variants converge on attacker-controlled plugin execution; update status is separated by product.",
  "summary": "Air Security demonstrated that AI coding clients could install different plugin code from the commit reviewed by a marketplace. An attacker controlling an already trusted plugin repository could shadow a pinned SHA with a default branch of the same name, or shadow FETCH_HEAD in Gemini CLI. Background updates then loaded malicious code without a fresh install decision. The defect is verification of the resolved working-tree commit, not a failure to review the marketplace entry; both repository control and a compatible client/hosting path are material prerequisites.",
  "reviewed": true,
  "import_status": "curated-research",
  "ai_layers": [
    "autonomous-agents"
  ],
  "risk_impact": [
    "system-compromise-rce",
    "data-exfiltration"
  ],
  "affected_components": [
    "Marketplace pinned Git commit",
    "Plugin repository default branch",
    "Client Git checkout",
    "Background plugin updater"
  ],
  "source_research": {
    "provider": "Air Security",
    "primary_url": "https://www.air.security/blog-posts/plugin4shell",
    "published": "2026-09-17",
    "note": "Source-verified AIDEFEND research curation. ATLAS technique annotations are analyst mappings, not an official ATLAS case study."
  },
  "attack_steps": [
    {
      "id": "step-1",
      "title": "Establish an Installed, Reviewed Plugin",
      "zhTitle": "先有已安裝且經審查的外掛",
      "summary": "The user already has a benign marketplace plugin pinned to a reviewed commit. The attacker controls its upstream repository, either as publisher or through a separate takeover. The study does not make this prerequisite disappear.",
      "zhSummary": "使用者已安裝由官方市集固定至特定審查 commit 的正常外掛。攻擊者必須掌控該外掛的上游儲存庫，其身分可能是原發布者或透過帳號接管取得權限；研究並未省略這項關鍵前提。",
      "tactic": "AML.TA0004",
      "technique": "AML.T0010.001",
      "layout": {
        "x": -960,
        "y": 0
      }
    },
    {
      "id": "step-2",
      "title": "Approve a New Benign Pinned Version",
      "zhTitle": "市集核准另一個正常版本的提交",
      "summary": "For the background-update route, a routine marketplace change pins a new still-benign commit. The attacker does not need to compromise the marketplace itself.",
      "zhSummary": "在背景更新路徑中，市集經由例行發布程序固定至另一個同樣正常的全新 commit；攻擊者完全不需要入侵或竄改市集本身。",
      "tactic": "AML.TA0007",
      "technique": "AML.T0109",
      "layout": {
        "x": -480,
        "y": 0
      }
    },
    {
      "id": "step-3",
      "title": "Set a Malicious SHA-Named Default Branch",
      "zhTitle": "把與 SHA 同名的惡意分支設為預設",
      "summary": "For Claude Code, Codex and GitHub Copilot, the repository default branch is named exactly like the pinned 40-hex SHA and points to malicious code. This variant requires a host that permits such names; GitHub rejects them, while the report identifies Bitbucket and self-hosted Git as permitted examples.",
      "zhSummary": "在 Claude Code、Codex 與 GitHub Copilot 攻擊路徑中，攻擊者將上游儲存庫的預設分支名稱，命名為與已固定 40 位十六進位 SHA 完全相同的字串，但該分支指向惡意程式碼。此變體需仰賴允許此類分支命名的託管平台；GitHub 會主動拒絕此命名，而報告指出 Bitbucket 與自架 Git 服務均允許此設定。",
      "tactic": "AML.TA0007",
      "technique": "AML.T0109",
      "layout": {
        "x": 0,
        "y": -600
      }
    },
    {
      "id": "step-4",
      "title": "Set a Malicious FETCH_HEAD Default Branch",
      "zhTitle": "另以 FETCH_HEAD 惡意分支遮蔽特殊參照",
      "summary": "In the Gemini CLI variant, the default branch is named FETCH_HEAD. The client fetches the correct pinned commit, but its subsequent checkout resolves the branch rather than the special fetch record. This is an alternative client path, not a second required stage of the SHA-name exploit.",
      "zhSummary": "在 Gemini CLI 攻擊變體中，攻擊者將預設分支命名為 FETCH_HEAD。客戶端雖能 fetch 到正確的固定 commit 物件，但隨後的 checkout 動作卻優先解析到該同名分支，而非特殊的 FETCH_HEAD 抓取記錄。這是另一條平行的客戶端解析缺陷路徑，並非 SHA 同名攻擊的接續步驟。",
      "tactic": "AML.TA0007",
      "technique": "AML.T0109",
      "layout": {
        "x": 0,
        "y": 600
      }
    },
    {
      "id": "step-5",
      "title": "Check Out the Branch Instead of the Pinned Commit",
      "zhTitle": "checkout 到分支而非固定提交",
      "summary": "A clone brings the malicious default branch into the local repository. Git checkout resolves the ambiguous SHA-shaped name as a ref, and the client does not assert that the resulting HEAD equals the reviewed pin.",
      "zhSummary": "執行 clone 時會將帶有惡意程式碼的預設分支複製至本機儲存庫。Git checkout 在解析具歧義的 SHA 名稱時將其優先視為分支參照（ref），而客戶端並未進一步校驗 checkout 後的 HEAD 是否與市集審查固定的 commit 雜湊值一致。",
      "tactic": "AML.TA0004",
      "technique": "AML.T0010.001",
      "layout": {
        "x": 480,
        "y": -600
      }
    },
    {
      "id": "step-6",
      "title": "Discard the Fetched Pin through Ref Resolution",
      "zhTitle": "特殊參照解析錯誤，未使用已擷取提交",
      "summary": "After fetching the pinned object, Gemini CLI runs checkout FETCH_HEAD. The attacker-named local default branch wins, and the expected commit is not the code placed in the working tree.",
      "zhSummary": "Gemini CLI 在抓取固定物件後執行 checkout FETCH_HEAD；此時同名的本機預設分支在參照解析中勝出，導致釋出至工作目錄的程式碼並非預期且經審查的 commit。",
      "tactic": "AML.TA0004",
      "technique": "AML.T0010.001",
      "layout": {
        "x": 480,
        "y": 600
      }
    },
    {
      "id": "step-7",
      "title": "Activate the Malicious Plugin Code",
      "zhTitle": "啟用惡意外掛程式碼",
      "summary": "The affected client activates the substituted plugin, enabling attacker-controlled code execution under the client's available host authority. Existing-plugin background updates can reach this point without another user click; initial adoption and repository control still remain prerequisites.",
      "zhSummary": "受影響的客戶端啟用了被偷換的惡意外掛，使攻擊者控制的程式碼得以在客戶端現有的主機權限下執行。既有外掛的背景更新流程無須使用者再次點擊確認即可觸發此執行，但初始安裝意願與攻擊者掌控上游儲存庫仍是不可或缺的前提。",
      "tactic": "AML.TA0005",
      "technique": "AML.T0011.000",
      "layout": {
        "x": 1440,
        "y": 0
      }
    }
  ],
  "threat_refs": [
    {
      "id": "AML.T0010.001",
      "name": "AI Supply Chain Compromise: AI Software"
    },
    {
      "id": "AML.T0109",
      "name": "AI Supply Chain Rug Pull"
    },
    {
      "id": "AML.T0053",
      "name": "AI Agent Tool Invocation"
    }
  ]
}
