Repository navigation
🤖 fix: block a Codex PreToolUse call when its hook output is malformed - #7834
Conversation
A Codex PreToolUse hook whose output is malformed or fails its schema check now blocks the tool call instead of being ignored (Cursor plugin RFC, D8, PR 6). The model gets "Tool call blocked by plugin '<plugin>' hook: its output is malformed: <detail>", and the user gets one plugin hook notice that names the hook and how to turn it off. invoke takes a `malformed` option beside `inputTooLarge`; only PreToolUse sets it. A parse throw or an `invalid` output returns that decision. Every other failure keeps failing open: a timeout, an MCP call error, a missing server, an MCP tool error (isError), and malformed PostToolUse, UserPromptSubmit and Stop output. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Comment pass over the previous commit: drop comments that restate the code or an assertion, and name the inputTooLarge block in the runner's failure rule next to blockRewrite. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Verifier findings on 0699b8c: - A PreToolUse guard whose output text was a JSON array (`[]`, a list of findings) or another non-object JSON value still let the call run, with no notice and no warning. Such text is now a malformed output: PreToolUse blocks the call with the notice, and the other events fail open with a warning. Plain text that is not JSON stays ignored. - docs/hooks/plugins.mdx still said malformed PreToolUse output fails open. It now lists what blocks a PreToolUse call (bare `allow`, `ask` and legacy `approve` included, unlike Codex) and what still fails open. The built-in xum-docs skill content is regenerated from it. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Re-verifier findings on 58a832c. Follow Codex's looks_like_json rule exactly: only text that starts with `{` or `[` and is not a JSON object is malformed (a PreToolUse call blocks with the notice). Other text, a bare JSON scalar such as `42`, `"ok"`, `true` or `null` included, is plain text and is ignored on PreToolUse, as before this PR. A hook written to Codex's contract that answers `true` no longer blocks every matching call. docs/hooks/plugins.mdx now says which text is ignored and which is malformed. The built-in xum-docs skill content is regenerated from it. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
Verifier follow-ups on 7c7a4eb: the codexHookOutput.ts header and the docs/hooks/plugins.mdx failure lists now say "starts with `{` or `[` and is not a JSON object", so they no longer read as covering a bare scalar such as `42`. The built-in xum-docs skill content is regenerated from the page. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🟢 e2e stories (Haiku): 14 passed22 agent steps · 7 replayed from cache · 15 model calls · 47.1k tokens (27% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 8s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 7.9k tokens (33% cached) All 3 tests in 3 files
e2e 0.20.0 · 18.9s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 5.8s · 2 targets (web, phone) · run artifacts |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 599c48a682
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…k reason Codex review P1 on 599c48a: a PreToolUse block shows the parser's detail to the model (tool error) and to the user (notice). Two details quoted the hook's own data: an invalid enum value and an unknown field name, where a hook can put a secret. Both messages are now value-free ("invalid permissionDecision value", "returned output with an unknown field"). This also covers the existing deny of a voided rewrite, which quoted the unknown field name. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Main (PR 7, per-hook stop limits) replaced `stopHookActive` in TurnStopHookInput with `turnContinuations` and `hookContinuations`. Two runTurnStopHooks calls that this branch added still passed the old field and failed the merge-group typecheck. They now pass main's shape. No behavior change. --- _Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_ <!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh -->
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
A Codex
PreToolUsehook whose output is malformed or fails its schema check now blocks the tool call instead of being ignored. The user sees one notice that names the plugin and says how to turn the hook off. Every other Codex hook failure keeps failing open: a timeout, an MCP error result, a missing server, and broken output fromPostToolUse,UserPromptSubmitandStop.Background
This is PR 6 of the Cursor plugin RFC, decision D8:
rfc/20261030_cursor-plugin-support.md(RFC PR #7829), section "PR 6", section 5.5 and the section 8 row. It needs no other PR of the program.Before this PR, a trusted
PreToolUseguard with broken output let every matching call through, silently. The owner chose the more secure rule: a guard that cannot be read blocks. Codex itself fails such a hook open, so this is a deliberate Xum difference.Implementation
codexHookRunner.ts:invoketakes amalformedoption besideinputTooLarge. Only thePreToolUsecall sets it. It returns the denyits output is malformed: <detail>and emits oneplugin.hook.notice.applyOutputnow runsparse. A parse error or aninvalidoutput goes throughrejectOutput, which blocks whenmalformedis set and warns and ignores otherwise.invalid <field> value, an unknown fieldreturned <where> with an unknown field.isError: true) still fails open, althoughparsethrows for it. It is the hook failing, not its output (RFC 5.5, "an error from the MCP call").codexHookOutput.ts: Codex'slooks_like_jsonrule. Text that starts with{or[must be a JSON object, so[]or a list of findings is malformed. Other text, a bare JSON scalar such astrueincluded, is plain text and is ignored, as in Codex.docs/hooks/plugins.mdx: new "What blocks aPreToolUsecall" list and a rewritten "What fails open" list.builtInSkillContent.generated.tsis regenerated from the page.Validation
CodexPluginHookServiceandEventSpine, Xum's MCP client and a real stdio MCP server. At the base, every malformed case letsrm -rf buildrun. At the head, each one blocks with one notice. A tool error, a missing server, a timeout, valid output and plain text still let the call through.Risks
permissionDecision: "allow". Codex reports that as unsupported and runs the call. Xum now blocks it. See the release note.Release note
A Codex
PreToolUsehook whose output is malformed or fails its schema check now blocks the tool call instead of being ignored. A chat line names the plugin and the hook, and says how to turn the hook off in Settings > Plugins.This includes eight outputs that Codex marks as a failed hook run and then runs the call anyway. In Xum, each of them now blocks a matching call (an explicit deny in the same output still applies with its own reason):
permissionDecision: "allow"(withoutupdatedInput).permissionDecision: "ask".decision: "approve".continue: false.stopReason.suppressOutput: true.updatedInputwithoutpermissionDecision: "allow".reasonorpermissionDecisionReason).Text that starts with
{or[but is not a JSON object (for example[]or a list of findings) and a result over 1 MiB block too. Text that does not start with{or[, a bare JSON scalar such astrueincluded, stays plain text and is ignored, as in Codex.A timeout, an MCP error result, a missing server and broken output from
PostToolUse,UserPromptSubmitandStopstill fail open.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh