Retire the untrusted approval policy (#39630)

## What changed

- Remove `untrusted` from the CLI, configuration schema, and MCP tool interface. Explicit `approval_policy = "untrusted"` settings now fail with an actionable error.
- Remove the known-safe command allowlist. Projects marked untrusted now request approval for every command unless an explicit exec policy rule allows it.
- Keep command parsing conservative by treating in-place `sed` forms as mutating and ignoring unrecognized commands when recording memory usage.

## Testing

- Cover rejection of the retired configuration value and approval requests for commands in untrusted projects.

GitOrigin-RevId: d6bf425edddfffbb325eee6acf383434af5fd33b
This commit is contained in:
jif authored and copyberry committed 2026-08-20 07:03:02 +00:00
1 parent 9ca99b5171
commit 942af8447b
43 files changed
+218 -1380

No files matched your search

+11 -14
View File
@@ -9319,7 +9319,7 @@ async fn model_catalog_json_rejects_empty_catalog() -> std::io::Result<()> {
fn create_test_fixture() -> std::io::Result<PrecedenceTestFixture> {
let toml = r#"
model = "o3"
approval_policy = "untrusted"
approval_policy = "on-request"
[analytics]
enabled = true
@@ -10405,7 +10405,7 @@ async fn test_untrusted_project_gets_unless_trusted_approval_policy() -> anyhow:
)
.await?;
// Verify that untrusted projects get UnlessTrusted approval policy
// Verify that untrusted projects get the internal always-prompt policy.
assert_eq!(
config.permissions.approval_policy.value(),
AskForApproval::UnlessTrusted,
@@ -10805,8 +10805,7 @@ trust_level = "untrusted"
}
#[tokio::test]
async fn explicit_approval_policy_falls_back_when_disallowed_by_requirements() -> std::io::Result<()>
{
async fn explicit_untrusted_approval_policy_is_rejected() -> std::io::Result<()> {
let codex_home = TempDir::new()?;
std::fs::write(
codex_home.path().join(CONFIG_TOML_FILE),
@@ -10814,19 +10813,17 @@ async fn explicit_approval_policy_falls_back_when_disallowed_by_requirements() -
"#,
)?;
let config = ConfigBuilder::without_managed_config_for_tests()
let error = ConfigBuilder::without_managed_config_for_tests()
.codex_home(codex_home.path().to_path_buf())
.fallback_cwd(Some(codex_home.path().to_path_buf()))
.cloud_config_bundle(
CloudConfigBundleFixture::loader_with_enterprise_requirement(
r#"allowed_approval_policies = ["on-request"]"#,
),
)
.build()
.await?;
assert_eq!(
config.permissions.approval_policy.value(),
AskForApproval::OnRequest
.await
.expect_err("untrusted approval policy should be rejected");
assert!(
error
.to_string()
.contains("approval_policy = \"untrusted\" is no longer supported"),
"unexpected error: {error}"
);
Ok(())
}
+11
View File
@@ -186,6 +186,11 @@ pub(crate) use resolved_permission_profile::PermissionProfileState;
const DEFAULT_IGNORE_LARGE_UNTRACKED_DIRS: i64 = 200;
const DEFAULT_IGNORE_LARGE_UNTRACKED_FILES: i64 = 10 * 1024 * 1024;
/// Signals that a public config selected the retired `untrusted` approval policy.
#[derive(Debug, thiserror::Error)]
#[error("approval_policy = \"untrusted\" is no longer supported; remove this setting")]
pub struct UnsupportedUntrustedApprovalPolicyError;
/// Compatibility-only config retained so legacy `ghost_snapshot` settings
/// continue to load even though snapshots are no longer produced.
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -3554,6 +3559,12 @@ impl Config {
}
configured_network_proxy_config.enabled = true;
}
if cfg.approval_policy == Some(AskForApproval::UnlessTrusted) {
return Err(std::io::Error::new(
ErrorKind::InvalidData,
UnsupportedUntrustedApprovalPolicyError,
));
}
let approval_policy_was_explicit =
approval_policy_override.is_some() || cfg.approval_policy.is_some();
let mut approval_policy = approval_policy_override