mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
implement per-workspace capability SIDs for workspace specific ACLs (#10189)
Today, there is a single capability SID that allows the sandbox to write to * workspace (cwd) * tmp directories if enabled * additional writable roots This change splits those up, so that each workspace has its own capability SID, while tmp and additional roots, which are installation-wide, are still governed by the "generic" capability SID This isolates workspaces from each other in terms of sandbox write access. Also allows us to protect <cwd>/.codex when codex runs in a specific <cwd>
This commit is contained in:
1 parent
654fcb4962
commit
aabe0f259c
11 files changed
+336
-104
No files matched your search
@@ -3,6 +3,7 @@ use crate::acl::path_mask_allows;
|
||||
use crate::cap::cap_sid_file;
|
||||
use crate::cap::load_or_create_cap_sids;
|
||||
use crate::logging::{debug_log, log_note};
|
||||
use crate::path_normalization::canonical_path_key;
|
||||
use crate::policy::SandboxPolicy;
|
||||
use crate::token::convert_string_sid_to_sid;
|
||||
use crate::token::world_sid;
|
||||
@@ -31,11 +32,6 @@ const SKIP_DIR_SUFFIXES: &[&str] = &[
|
||||
"/programdata",
|
||||
];
|
||||
|
||||
pub(crate) fn normalize_path_key(p: &Path) -> String {
|
||||
let n = dunce::canonicalize(p).unwrap_or_else(|_| p.to_path_buf());
|
||||
n.to_string_lossy().replace('\\', "/").to_ascii_lowercase()
|
||||
}
|
||||
|
||||
fn unique_push(set: &mut HashSet<PathBuf>, out: &mut Vec<PathBuf>, p: PathBuf) {
|
||||
if let Ok(abs) = p.canonicalize() {
|
||||
if set.insert(abs.clone()) {
|
||||
@@ -131,7 +127,7 @@ pub fn audit_everyone_writable(
|
||||
checked += 1;
|
||||
let has = check_world_writable(&p);
|
||||
if has {
|
||||
let key = normalize_path_key(&p);
|
||||
let key = canonical_path_key(&p);
|
||||
if seen.insert(key) {
|
||||
flagged.push(p);
|
||||
}
|
||||
@@ -149,7 +145,7 @@ pub fn audit_everyone_writable(
|
||||
checked += 1;
|
||||
let has_root = check_world_writable(&root);
|
||||
if has_root {
|
||||
let key = normalize_path_key(&root);
|
||||
let key = canonical_path_key(&root);
|
||||
if seen.insert(key) {
|
||||
flagged.push(root.clone());
|
||||
}
|
||||
@@ -181,7 +177,7 @@ pub fn audit_everyone_writable(
|
||||
checked += 1;
|
||||
let has_child = check_world_writable(&p);
|
||||
if has_child {
|
||||
let key = normalize_path_key(&p);
|
||||
let key = canonical_path_key(&p);
|
||||
if seen.insert(key) {
|
||||
flagged.push(p);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user