AI Learn
OpenAI · Codex Tutorial

Choose a least-privilege Codex permission profile

Control filesystem, command and network access with the smallest permission profile that still lets the repository task succeed.

Reviewed September 19, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site and is not affiliated with OpenAI. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Codex permission profiles are actively evolving. Use either the current permission-profile system or legacy sandbox settings as documented; do not combine incompatible configuration styles.

1. Classify the repository

Decide whether the code is trusted, whether build scripts are understood, whether the task needs network access, and which directories really need writes.

2. Start with the restrictive default

Use read-only or tightly scoped workspace writes for investigation. Expand only when a concrete command or file operation is blocked.

3. Separate network from file access

A task may need package docs without needing arbitrary filesystem writes, or may need local edits without network. Grant these dimensions independently.

4. Review approvals as signals

When Codex asks for permission, read the exact command, path and reason. Repeated legitimate approvals may justify a narrow rule; surprising approvals are a warning to stop.

5. Re-test after changing config

Restart or verify the current session configuration and run a harmless boundary test. Do not assume editing a config file changed an already-running session.

Try this prompt

Use the minimum permissions needed for this task. Before requesting any escalation, show the blocked command or path, explain why it is necessary, and propose the narrowest permission change that would unblock it.

Common mistakes

Mixing legacy sandbox and new permission settings; enabling network for all tasks; approving shell commands without reading arguments; treating a familiar repository as permanently trusted.

Finish check

The task can complete, but unexpected paths, commands and network actions remain blocked or require review.

开始之前

Codex 权限配置仍在持续演进。按照当前文档使用权限配置方案或旧版 sandbox 方式,不要把不兼容的两套配置混在一起。

1. 先给仓库做风险分类

判断代码是否可信、构建脚本是否理解、任务是否需要网络、哪些目录真的需要写入。

2. 从限制较严格的默认配置开始

调查阶段使用只读或严格限定的工作区写入,只有出现具体被阻止的合理动作时才增加权限。

3. 把网络访问和文件权限拆开考虑

有的任务只需要查包文档却不需要任意写文件;有的任务只需要本地编辑却不需要网络。两类权限应独立开放。

4. 把审批弹窗当成风险信号

Codex 请求权限时看清具体命令、路径和原因。重复出现的合理请求可以形成窄规则;意外请求则应该暂停调查。

5. 改配置后重新验证

重启或检查当前会话配置,并做一个无害的边界测试。不要假设编辑配置文件后正在运行的会话一定自动变化。

可以直接套用的提示词

这次任务只使用最小必要权限。任何权限升级前,先展示被阻止的命令或路径,解释为什么确实需要,并提出能够解除阻塞的最窄权限变化。

常见错误

混用旧 sandbox 与新权限配置;所有任务都默认开网络;不看参数就批准 Shell 命令;因为仓库以前可信就永远不再审查。

完成检查

完成后,任务能够顺利执行,但意外路径、命令和网络操作仍然会被阻止或需要人工审查。

開始之前

Codex 權限配置仍在持續演進。按照當前文檔使用權限配置方案或舊版 sandbox 方式,不要把不兼容的兩套配置混在一起。

1. 先給倉庫做風險分類

判斷代碼是否可信、構建腳本是否理解、任務是否需要網絡、哪些目錄真的需要寫入。

2. 從限制較嚴格的預設配置開始

調查階段使用只讀或嚴格限定的工作區寫入,只有出現具體被阻止的合理動作時才增加權限。

3. 把網絡訪問和檔案權限拆開考慮

有的任務只需要查包文檔卻不需要任意寫檔案;有的任務只需要本地編輯卻不需要網絡。兩類權限應獨立開放。

4. 把審批彈窗當成風險信號

Codex 請求權限時看清具體指令、路徑和原因。重復出現的合理請求可以形成窄規則;意外請求則應該暫停調查。

5. 改配置後重新驗證

重啓或檢查當前會話配置,並做一個無害的邊界測試。不要假設編輯配置檔案後正在運行的會話一定自動變化。

可以直接套用的提示詞

這次任務只使用最小必要權限。任何權限升級前,先展示被阻止的指令或路徑,解釋為甚麼確實需要,並提出能夠解除阻塞的最窄權限變化。

常見錯誤

混用舊 sandbox 與新權限配置;所有任務都預設開網絡;不看參數就批准 Shell 指令;因為倉庫以前可信就永遠不再審查。

完成檢查

完成後,任務能夠順利執行,但意外路徑、指令和網絡操作仍然會被阻止或需要人工審查。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →