﻿---
title: "Windows deny-read 不要写无界 glob，写精确目录"
summary: "Windows 会把 glob 展开进沙箱 helper 命令行。Chrome 配置目录那种树能报 os error 206，会话起不来。目录拒绝写精确路径。"
category: sandbox
level: advanced
surfaces: [cli, app]
tags: ["Windows", "permissions", "deny-read"]
canonical: /tips/windows-deny-read-glob/
---

# Windows deny-read 不要写无界 glob，写精确目录

Windows 会把 glob 展开进沙箱 helper 命令行。Chrome 配置目录那种树能报 os error 206，会话起不来。目录拒绝写精确路径。

Windows ACL 表达不了 glob。权限档里的 deny-read 会在启动前扫盘、展开成具体路径，再塞进一条 `CreateProcessW` 命令行（上限 32,767 个 UTF-16 字符）。下面这种树可以扫出上万条路径，会话卡几十秒后报：

```text
~/AppData/Local/Google/Chrome/**
failed to load AGENTS.md instructions … The filename or extension is too long. (os error 206)
```

这不是路径超过 260 字符，也不是 sessions 坏了。空项目、企业托管档同样会中招。

目录级拒绝写精确路径，不要在目录后面再加递归 glob。目录 deny 会覆盖子树，不必先展开：

```toml
default_permissions = "managed_net"

[permissions.managed_net]
extends = ":workspace"

[permissions.managed_net.filesystem]
glob_scan_max_depth = 3
":workspace_roots" = { "." = "write" }
"~/AppData/Local/Google/Chrome" = "deny"
"/absolute/path/to/secrets" = "deny"
```

官方样本里无界 glob（例如匹配任意深度的 env 文件）要配 `glob_scan_max_depth`（至少 `1`）。这只能限制扫描深度，救不了已经膨胀的 argv。工作区里匹配数很少时再用。

临时绕过：`project_doc_max_bytes = 0` 能跳过 AGENTS.md 加载，但沙箱命令仍可能撞上同一条命令行上限。真正该改的是 deny 列表。

## 来源

- [openai/codex#41809](https://github.com/openai/codex/issues/41809)
- [OpenAI · Sample configuration](https://learn.chatgpt.com/docs/config-file/config-sample)
