Can an AI coding agent be locked out of modifying its own guardrail hooks? (OpenAI Codex CLI)
一位开发者正在询问是否可以阻止AI编码代理,特别是OpenAI Codex CLI,修改其自身的防护钩子。提议的解决方案是使用NTFS ACLs,拒绝代理身份对钩子脚本和hooks.json的写入和删除权限,同时保留读取和执行权限。这种设置将要求任何修改都需要通过提升的用户账户控制(UAC)操作,开发者正在寻求有关此方法的文档或现有技术。
为什么是这条该讨论不同于一般AI安全话题,它具体探讨了如何通过NTFS ACLs阻止AI代理修改其自身的防护钩子。
时间与来源
时间显示为 UTC
显示时区:UTC
本地时区尚不可用,暂时显示 UTC。
发布当时偏移:UTC+02026年9月9日 01:41 UTC
收录当时偏移:UTC+02026年9月9日 17:00 UTC
- 发布
- 2026年9月9日 01:41
- 收录
- 2026年9月9日 17:00
- 来源类型
- 开发者社区
- 档位
- 社区
- 信源状态
- 正常
档位是按信源手工设定的编辑判断,不是逐条打分。
讨论趋势
百分比基于采集到的讨论信号,不代表新增评论数或独立参与人数。曲线仅用于同一话题在不同时段的比较。
Goal
I run AI coding agents locally on Windows and want a "hardstop" I can trigger at any time - a single keystroke that immediately blocks the agent from doing anything further until I clear it. I have this working for one agent as a UserPromptSubmit hook: typing exactly "h" arms a latch file, "c" clears it, and while the latch exists every prompt is blocked before the model sees it.
I now want the same thing for Codex, but hardened.
The problem
The agent runs under my own user account. Anything my user can write, the agent can write - including its own hook script, the hooks.json that registers it, and the latch file itself. So the guardrail is only as strong as the agent's willingness to respect it, which is not a guarantee. I have already had files in this setup modified without my approval.
Instruction-level policy (system prompt / AGENTS.md rules telling it not to touch these files) demonstrably does not hold. I need a mechanical boundary, not a promise.
What I have built or considered
- Wrapper + policy design - an output gate that mechanically checks replies, plus instruction files. Works for what it does, but it cannot protect itself: the agent can edit the policy files.
- Codex managed hooks - the docs describe hooks from requirements.toml as "marked as managed, trusted by policy, and can't be disabled from the user hook browser", with allow_managed_hooks_only = true skipping user/project/session/plugin hooks. This looks like exactly what I want.
- NTFS ACLs - deny write/delete on the hook script and hooks.json to whatever identity the agent runs as, keeping read+execute so the hook still fires. Changes would then require an elevated (UAC) action by me.
Questions
- Does the requirements.toml managed-hooks path work on a personal/individual account, or does it require an enterprise/MDM deployment? The docs frame it as enterprise-managed and I cannot tell whether it is plan-gated.
- Does Codex CLI run hooks as the logged-in user, or under a separate sandbox account? That determines whether an ACL denial actually stops it.
- Codex docs note that multiple hooks for the same event "are launched concurrently, so one hook can't prevent another matching hook from starting". Does a decision: block from one UserPromptSubmit hook still reliably stop the turn?
- Is there a better pattern for this generally - making an agent's own kill switch tamper-proof against the agent, on a single-user machine, without paying for an enterprise tier?
Any pointers to the right docs or prior art appreciated.