Command escalation information look to be not available in Codex hooks
What version of Codex CLI is running?
0.139.0
What subscription do you have?
Pro 5x
Which model were you using?
gpt-5.5 medium
What platform is your computer?
Linux 6.12.90+deb13.1-amd64 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
neovim
Codex doctor report
What issue are you seeing?
The escalated command was approved and executed successfully. From the hook side, escalation does not seem available or enforceable enough to distinguish this from other command authorization cases.
What steps can reproduce the bug?
Uploaded thread: 019ec28d-72b9-7d10-8f21-0f4f32c88dba
What is the expected behavior?
Hook payloads should expose escalation state and target command details in a way that allows a hook to make an enforceable decision before the command runs. If a hook returns a block decision, the escalated operation should not execute.
Additional information
I encountered the issue while working on a hook https://github.com/malach-it/boruta-server/pull/163, I am discovering hooks then I may be wrong, sorry if it is the case.
Thank you for your work on Codex
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
A rephrase suggestion from Codex
I think the key distinction here is not only whether hooks can see the shell command, but whether they can make a policy decision on the permission transition.
From a hook author perspective, the useful contract would be something like:
PreToolUseforBashincludes the command as it does today.PermissionRequestincludes a stable reason/category for the requested elevation, e.g. sandbox escape vs network vs write outside workspace.PermissionRequest, the elevated command is not executed even if the normal tool call would otherwise be allowed.That would let policy hooks distinguish “ordinary command inside current permissions” from “same command after an escalation request”. Without that, a hook can block broad command patterns, but cannot express rules such as “allow this command in the sandbox, deny it if it requests filesystem escalation”.
A useful test case would be: configure a hook that allows
Bashgenerally, blocks only permission requests with an escalation marker, then run a command that requires escalation. Expected: command never runs and the user sees the hook block reason.Hi @SylvainWinning,
Thank you for your reply, would you have more information about the category/reason you highlighted. I tested to get the information from
sandbox_permissionsin hook payload and did not get any meaningful results. Maybe is there other keys I am missing?This is exactly the test case I am trying to solve, I have pretty good results with other markers but not with the escalation one.
Thanks for checking. The field I had in mind is on the
PermissionRequesthook payload, notsandbox_permissions.For the current documented payload, the relevant pieces are:
tool_nameshould beBashtool_input.commandhas the command being requestedtool_input.descriptionmay contain the human-readable approval reason, when Codex has oneSo for that test case I would try matching the
PermissionRequestevent forBashand inspectingtool_input.description, then returning a deny decision from that hook.That said, I think your core point is still valid: I don’t see a stable/documented field today that says “this request is specifically a sandbox escalation” or exposes the escalation category as structured data. If
descriptionis empty or too generic for this path, then this is probably not something your hook can enforce robustly yet, and the issue should stay open as a request/bug for a structured escalation marker in thePermissionRequestpayload.The useful boundary here is the permission transition, not just the shell command. A hook can already reason about
Bash; what it needs is a stable way to say "this same command is fine inside the current sandbox, but not after escalation."A minimal
PermissionRequestcontract that would make that enforceable:permission_request_idandtool_call_id, so later allow/deny/audit events can be tied back to the exact requestpermission.kind, e.g.sandbox_escape,network,write_outside_workspace, or whatever categories Codex actually uses internallycurrent_sandboxandrequested_sandbox, not just a human-readable descriptionescalation_reason.codeplus optionalescalation_reason.text; hooks should not have to parse prosetool_name,tool_input.command, andcwdcopied into the request payload so the hook does not need to correlate separate events before decidingOrdering matters too: if a hook denies the
PermissionRequest, the elevated operation should not run, and no successfulPostToolUse/exec-result event should be emitted for that elevated attempt. If Codex emits an audit event, it should carry the samepermission_request_idwithdecision=denied.The regression test I would want is narrow: allow ordinary
Bash, deny onlyPermissionRequestwherepermission.kind == sandbox_escape, run a command that requires escalation, and assert the command never executes.---
_Generated with ax._