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:
sayan-oai
2026-11-03 01:41:16 +00:00
committed by copyberry
parent 80a8710546
commit f58acd6ede
16 changed files with 296 additions and 62 deletions
+11 -6
View File
@@ -197,7 +197,7 @@ pub struct PreparedMcpCall {
pub enum McpPermissionSource<'a> {
Environment {
environment_id: &'a str,
sandbox: &'a FileSystemSandboxContext,
sandbox: &'a Arc<FileSystemSandboxContext>,
},
Thread {
profile: &'a PermissionProfile,
@@ -205,6 +205,15 @@ pub enum McpPermissionSource<'a> {
},
}
impl<'a> McpPermissionSource<'a> {
pub fn profile(&self) -> &'a PermissionProfile {
match self {
Self::Environment { sandbox, .. } => &sandbox.permissions,
Self::Thread { profile, .. } => profile,
}
}
}
#[derive(Clone)]
pub(crate) struct PreparedToolInfo {
catalog: Arc<[ToolInfo]>,
@@ -291,11 +300,7 @@ impl PreparedMcpCall {
/// Returns the owner permissions validated when this immutable call was prepared.
pub fn permission_profile(&self) -> &PermissionProfile {
let Some(permission_profile) = self.config.permission_profile_for_server(&self.server_name)
else {
unreachable!("prepared MCP calls retain their immutable permission authority");
};
permission_profile
self.permission_source().profile()
}
/// Attach policy aliases and the server-host launcher, replacing stale authority.