mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Use MCP owner permissions for Guardian reviews and score reuse (#59489)
## Why An MCP server can belong to a different environment from the turn's primary environment. An early Guardian score based on the issuing context must not bypass review when the server owner's permissions differ. ## What changed - Capture the owning environment's permissions when preparing an MCP call and retain them for server-initiated approvals tied to that still-running call. - Use the captured permissions consistently in Guardian review prompts and permission context. - Require a fresh synchronous review when the captured owner permissions do not match the early score's authorization. ## Testing Extend regression coverage for MCP score reuse across environments and for follow-up approvals from a local MCP server during a remote-primary turn. Assert that reviews use the owner's denied paths and require a fresh review when permissions differ. GitOrigin-RevId: eb5eeb1259732c57f39765c38e34148fa0787dae
This commit is contained in:
@@ -1187,6 +1187,15 @@ async fn review_guardian_mcp_elicitation(
|
||||
}
|
||||
};
|
||||
guardian_request.category = guardian_scope;
|
||||
// Keep the action the server asked about, but use its owner's rules from the original call.
|
||||
if let Ok(crate::guardian::GuardianApprovalRequest::McpToolCall {
|
||||
prompt_permissions, ..
|
||||
}) = &mut guardian_request.request
|
||||
&& let Some(permissions) =
|
||||
approval_context.and_then(|context| context.environment_permissions)
|
||||
{
|
||||
*prompt_permissions = Some(permissions);
|
||||
}
|
||||
let declined_reason = guardian_request.request.as_ref().err().cloned();
|
||||
let decision = crate::guardian::decide_approval(
|
||||
session,
|
||||
|
||||
Reference in New Issue
Block a user