fix(sandboxing): reject WSL1 bubblewrap sandboxing (#17559)

## Summary

- detect WSL1 before Codex probes or invokes the Linux bubblewrap
sandbox
- fail early with a clear unsupported-operation message when a command
would require bubblewrap on WSL1
- document that WSL2 follows the normal Linux bubblewrap path while WSL1
is unsupported

## Why

Codex 0.115.0 made bubblewrap the default Linux sandbox. WSL1 cannot
create the user namespaces that bubblewrap needs, so shell commands
currently fail later with a raw bwrap namespace error. This makes the
unsupported environment explicit and keeps non-bubblewrap paths
unchanged.

The WSL detection reads /proc/version, lets an explicit WSL<version>
marker decide WSL1 vs WSL2+, and only treats a bare Microsoft marker as
WSL1 when no explicit WSL version is present.

addresses https://github.com/openai/codex/issues/16076

---------

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
viyatb-oaiandCodex authored and GitHub committed 2026-04-12 14:08:14 -07:00
1 parent a4d5112b37
commit cb870a169a
7 files changed
+169 -2

No files matched your search

+30
View File
@@ -44,6 +44,36 @@ exit 1
assert_eq!(system_bwrap_warning_for_path(Some(fake_bwrap_path)), None);
}
#[test]
fn detects_wsl1_proc_version_formats() {
assert!(proc_version_indicates_wsl1(
"Linux version 4.4.0-22621-Microsoft"
));
assert!(proc_version_indicates_wsl1(
"Linux version 5.15.0-microsoft-standard-WSL1"
));
assert!(proc_version_indicates_wsl1(
"Linux version 5.15.0-wsl-microsoft-standard-WSL1"
));
}
#[test]
fn does_not_treat_wsl2_or_native_linux_as_wsl1() {
assert!(!proc_version_indicates_wsl1(
"Linux version 6.6.87.2-microsoft-standard-WSL2"
));
assert!(!proc_version_indicates_wsl1(
"Linux version 6.6.87.2-wsl-microsoft-standard-WSL2"
));
assert!(!proc_version_indicates_wsl1(
"Linux version 4.19.104-microsoft-standard"
));
assert!(!proc_version_indicates_wsl1(
"Linux version 6.6.87.2-microsoft-standard-WSL3"
));
assert!(!proc_version_indicates_wsl1("Linux version 6.8.0"));
}
#[test]
fn finds_first_executable_bwrap_in_joined_search_path() {
let temp_dir = tempdir().expect("temp dir");