Harden cloud runtime local access boundaries

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Liang-Ting Jiang
2026-05-16 08:02:44 +00:00
co-authored by Codex
parent 326e31ab65
commit af2e9b3b04
9 changed files with 312 additions and 61 deletions
+7 -3
View File
@@ -261,9 +261,13 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_environment_manager(
let (tx_event, rx_event) = unbounded();
drop(rx_event);
let environment = environment_manager
let runtime_environment = environment_manager
.default_environment()
.unwrap_or_else(|| environment_manager.local_environment());
.or_else(|| environment_manager.try_local_environment())
.map_or_else(
|| McpRuntimeEnvironment::without_environment(config.cwd.to_path_buf()),
|environment| McpRuntimeEnvironment::new(environment, config.cwd.to_path_buf()),
);
let (mut mcp_connection_manager, cancel_token) = McpConnectionManager::new(
&mcp_servers,
@@ -273,7 +277,7 @@ pub async fn list_accessible_connectors_from_mcp_tools_with_environment_manager(
INITIAL_SUBMIT_ID.to_owned(),
tx_event,
PermissionProfile::default(),
McpRuntimeEnvironment::new(environment, config.cwd.to_path_buf()),
runtime_environment,
config.codex_home.to_path_buf(),
codex_apps_tools_cache_key(auth.as_ref()),
host_owned_codex_apps_enabled,
+9 -5
View File
@@ -294,14 +294,18 @@ impl Session {
Arc::clone(&turn_environment.environment),
turn_environment.cwd.to_path_buf(),
),
None => McpRuntimeEnvironment::new(
None => {
#[allow(deprecated)]
let fallback_cwd = turn_context.cwd.to_path_buf();
self.services
.environment_manager
.default_environment()
.unwrap_or_else(|| self.services.environment_manager.local_environment()),
#[allow(deprecated)]
turn_context.cwd.to_path_buf(),
),
.or_else(|| self.services.environment_manager.try_local_environment())
.map_or_else(
|| McpRuntimeEnvironment::without_environment(fallback_cwd.clone()),
|environment| McpRuntimeEnvironment::new(environment, fallback_cwd.clone()),
)
}
};
{
let mut guard = self.services.mcp_startup_cancellation_token.lock().await;
+18 -7
View File
@@ -1045,13 +1045,24 @@ impl Session {
Arc::clone(&turn_environment.environment),
turn_environment.cwd.to_path_buf(),
),
None => McpRuntimeEnvironment::new(
sess.services
.environment_manager
.default_environment()
.unwrap_or_else(|| sess.services.environment_manager.local_environment()),
session_configuration.cwd.to_path_buf(),
),
None => sess
.services
.environment_manager
.default_environment()
.or_else(|| sess.services.environment_manager.try_local_environment())
.map_or_else(
|| {
McpRuntimeEnvironment::without_environment(
session_configuration.cwd.to_path_buf(),
)
},
|environment| {
McpRuntimeEnvironment::new(
environment,
session_configuration.cwd.to_path_buf(),
)
},
),
};
let (mcp_connection_manager, cancel_token) = McpConnectionManager::new(
&mcp_servers,