﻿---
title: "权限档有 deny-read 时，execpolicy allow 仍可能不出沙箱"
summary: "check 报 allow 只说明规则匹配。任意 deny-read 会禁止出沙箱，命令仍走默认沙箱，git fetch 还会弹窗。"
category: hooks
level: advanced
surfaces: [cli, app]
tags: ["execpolicy", "permissions", "沙箱"]
canonical: /tips/execpolicy-allow-denied-read/
---

# 权限档有 deny-read 时，execpolicy allow 仍可能不出沙箱

check 报 allow 只说明规则匹配。任意 deny-read 会禁止出沙箱，命令仍走默认沙箱，git fetch 还会弹窗。

Rules 文档把 `decision = "allow"` 写成可以出沙箱跑受信任命令。权限档里只要有一条 deny-read（哪怕是探测路径），运行时会关掉这次 bypass，命令留在默认沙箱。`codex execpolicy check` 仍然打印 `allow`，没有警告。

核对：

```bash
codex execpolicy check --pretty --rules ~/.codex/rules/default.rules -- git fetch
```

报 allow 之后，在开了 deny-read 的会话里跑同一条，仍可能要批准，或在 Seatbelt / Landlock 里失败。这是为了保住凭证边界，不是规则没加载。

能选的路：

- 要出沙箱的受信任 CLI：不要在同一套权限档写 deny-read
- 要挡 `~/.ssh` / `.env`：接受 `allow` 仍在沙箱里跑，或把这类命令交给钩子 / 人工批准
- 不要为了让 `git fetch` 安静而改成 `:danger-full-access`

`check` 只评规则文件，不模拟当前权限档。改完 deny-read 用真实会话或 `codex sandbox` 再试一次。

## 来源

- [openai/codex#38318](https://github.com/openai/codex/issues/38318)
- [OpenAI · Rules](https://learn.chatgpt.com/docs/agent-configuration/rules)
