fix(exec_policy) heredoc parsing file_redirect#20113
Conversation
- anomalyco/opencode#24877: session directory routing fix (merge-after-nits) - anomalyco/opencode#24852: JSON skill serialization for non-Anthropic models (merge-after-nits) - openai/codex#20113: heredoc file_redirect sandbox bypass fix (merge-after-nits) - openai/codex#20096: remote installed plugin cache for skills/MCP (merge-after-nits)
|
I found two security issues that look worth fixing before this lands.
Recommended fix: reject
This PR correctly marks heredoc and file redirect fallback parsing as complex so auto derived amendments are suppressed. But model supplied Recommended fix: apply the same complex parsing gate to requested amendments. In practice, compute I think the first item is directly in the parser lines touched here. The second item is a related policy boundary issue that this PR is now depending on, so it would be best to close both while the heredoc policy behavior is being tightened. |
Windows read-only sandbox policy prompts for the unreduced fallback command, so keep this assertion on platforms where the sandboxed fallback result is stable. Co-authored-by: Codex <noreply@openai.com>
|
Thanks for the Slack discussion. I agree this should not block the PR. The risky case is a broad saved rule like The remaining case saves the exact shell command. That is much less reusable. It also keeps the normal user flow where an approved command can offer a saved rule. So I am good with this PR. If we want stricter behavior for complex shell scripts, we can handle that as follow up work. |
evawong-oai
left a comment
There was a problem hiding this comment.
Approving based on the thread. The remaining exact command rule concern does not need to block this PR.
| Ok((event, Some(command.to_string()))) | ||
| } | ||
| ActionKind::RunCommandWithPolicy { command, .. } => { | ||
| // Bazel Linux runners can be heavily oversubscribed while this |
Summary
Fixes a regression introduced in #10941 so that heredocs do not permit file redirects to be approved by rules, and adds scenario tests to cover this behavior.
Previously, heredoc command parsing would allow redirects and environment variables:
This conflicts with the Codex Rules documentation; heredoc parsing logic should abide by the same strictness of parsing.
Tests