mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Use prepared MCP owner permissions in Guardian reviews (#59028)
## Why An MCP server's environment permissions can change after a tool step captures its context. Guardian reviews of direct MCP calls could therefore miss denied paths present in the permissions used to prepare the call. ## What changed Pass the prepared server environment's sandbox context through MCP approvals and use it to build Guardian's permission evidence, including denied paths and globs resolved for that environment. Keep the sandbox context out of serialized approval actions. ## Testing Add a regression test that updates a remote MCP owner's permissions after the step starts and verifies that Guardian sees the owner's denied temporary directory. Extend the approval JSON test to verify that supplying sandbox context preserves the serialized action shape. GitOrigin-RevId: cab0d7c60112a97adf98e5548cdc066b260bb073
This commit is contained in:
@@ -136,6 +136,8 @@ pub(crate) enum ApprovalAction {
|
||||
approval_mode: AppToolApproval,
|
||||
allow_session_remember: bool,
|
||||
allow_persistent_approval: bool,
|
||||
#[serde(skip_serializing)]
|
||||
prompt_permissions: Option<(String, Arc<codex_file_system::FileSystemSandboxContext>)>,
|
||||
},
|
||||
NetworkAccess {
|
||||
id: String,
|
||||
@@ -399,6 +401,7 @@ impl ApprovalAction {
|
||||
tool_title,
|
||||
tool_description,
|
||||
annotations,
|
||||
prompt_permissions,
|
||||
..
|
||||
} => crate::guardian::GuardianApprovalRequest::McpToolCall {
|
||||
id,
|
||||
@@ -412,6 +415,7 @@ impl ApprovalAction {
|
||||
tool_title,
|
||||
tool_description,
|
||||
annotations,
|
||||
prompt_permissions,
|
||||
},
|
||||
Self::NetworkAccess {
|
||||
id,
|
||||
|
||||
@@ -210,6 +210,7 @@ async fn explicit_mcp_reviewer_override_takes_precedence_over_action_context() {
|
||||
approval_mode: AppToolApproval::Prompt,
|
||||
allow_session_remember: false,
|
||||
allow_persistent_approval: false,
|
||||
prompt_permissions: None,
|
||||
};
|
||||
let mut review_context = GuardianReviewContext::from(&turn);
|
||||
review_context.approval_policy = AskForApproval::OnRequest;
|
||||
|
||||
Reference in New Issue
Block a user