﻿---
title: "陌生仓库先 git clone，不要直接打开带 .git 的压缩包"
summary: "代理常在沙箱外跑 git status。仓库自己的 .git/config 里若写了 core.fsmonitor 一类键，可能在批准前提权执行。"
category: security
level: advanced
surfaces: [cli, ide, app]
tags: ["Git", "供应链", "沙箱"]
canonical: /tips/untrusted-git-config/
---

# 陌生仓库先 git clone，不要直接打开带 .git 的压缩包

代理常在沙箱外跑 git status。仓库自己的 .git/config 里若写了 core.fsmonitor 一类键，可能在批准前提权执行。

2026 年 9 月披露的一类问题：编码代理为了采集仓库上下文会调 Git，Git 会执行仓库配置里点名的命令。这发生在 agent 工具层之外，批准旋钮看不见。

Codex 已被报告并打过补丁。你仍应：

- 外来代码用 `git clone`，不要解压别人给的、带着 `.git/` 的 zip / U 盘目录
- 打开前看 `git config --get core.fsmonitor`，以及 hooksPath、credential.helper、pager、diff 驱动
- 保持 CLI 为当前版本；补丁是进程边界上的，不是再写一条 AGENTS.md 能挡住的

普通 `git clone` 不会把源仓的 local config 带过来。没有 `.git` 的源码包也不走这条路径。

## 来源

- [Manifold · The git you didn't run](https://www.manifold.security/blog/ai-coding-agents-git-hijack)
