mirror of
https://github.com/openai/codex.git
synced 2026-11-21 15:10:25 +00:00
Harden unsandboxed patch filesystem access (#39659)
## Why An `apply_patch` path can be replaced with a symlink after verification, allowing an unsandboxed patch operation to reach a different file than the one that was approved. ## What changed - Add `follow_symlinks` options to executor filesystem reads, writes, metadata lookups, directory creation, and removal, including the corresponding `followSymlinks` protocol fields. - Implement no-follow filesystem operations on Unix and Windows that reject links in any path component and restrict file access to regular files. - Run `apply_patch` with symlink traversal disabled when an otherwise-required sandbox is bypassed, while retaining the existing follow-symlink default for standalone callers. ## Testing - Cover leaf and ancestor symlinks across patch add, update, delete, and move operations, including a path swap after verification. - Exercise local and remote no-follow filesystem behavior, concurrent directory creation, special-file rejection, and Windows reparse points. GitOrigin-RevId: 43fd479084891493ce13564fbd894b98f329c6dd
This commit is contained in:
1 parent
4e1a772a7d
commit
e3e5ad2847
88 files changed
+2782
-302
No files matched your search
@@ -1,6 +1,8 @@
|
||||
use crate::manifest::parse_plugin_manifest_uri;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server::ExecutorFileSystem;
|
||||
use codex_exec_server::GetMetadataOptions;
|
||||
use codex_exec_server::ReadFileOptions;
|
||||
use codex_plugin::PluginProvider;
|
||||
use codex_plugin::ResolvedPlugin;
|
||||
use codex_plugin::ResolvedPluginError;
|
||||
@@ -156,7 +158,11 @@ async fn resolve_plugin_root(
|
||||
let root_id = &selected_root.id;
|
||||
let CapabilityRootLocation::Environment { environment_id, .. } = &selected_root.location;
|
||||
let root_metadata = file_system
|
||||
.get_metadata(&plugin_root, /*sandbox*/ None)
|
||||
.get_metadata(
|
||||
&plugin_root,
|
||||
GetMetadataOptions::default(),
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
.map_err(|source| ExecutorPluginProviderError::InspectRoot {
|
||||
root_id: root_id.clone(),
|
||||
@@ -181,7 +187,11 @@ async fn resolve_plugin_root(
|
||||
}
|
||||
})?;
|
||||
match file_system
|
||||
.get_metadata(&candidate_uri, /*sandbox*/ None)
|
||||
.get_metadata(
|
||||
&candidate_uri,
|
||||
GetMetadataOptions::default(),
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(metadata) if metadata.is_file => {
|
||||
@@ -203,7 +213,11 @@ async fn resolve_plugin_root(
|
||||
return Ok(None);
|
||||
};
|
||||
let contents = file_system
|
||||
.read_file_text(&manifest_uri, /*sandbox*/ None)
|
||||
.read_file_text(
|
||||
&manifest_uri,
|
||||
ReadFileOptions::default(),
|
||||
/*sandbox*/ None,
|
||||
)
|
||||
.await
|
||||
.map_err(|source| ExecutorPluginProviderError::ReadManifest {
|
||||
root_id: root_id.clone(),
|
||||
|
||||
Reference in new issue
Block a user