Lightweight coding agent that runs in your terminal
Rust
Protect the guardian decisions API key from environment forwarding (#50019)
swastik-oai9552906b2b83
diff --git a/codex-rs/exec-server/src/client/route_aware_http_client.rs b/codex-rs/exec-server/src/client/route_aware_http_client.rsindex 81dd4607dd..66c82bc9e5 100644--- a/codex-rs/exec-server/src/client/route_aware_http_client.rs+++ b/codex-rs/exec-server/src/client/route_aware_http_client.rs@@ -46,6 +46,7 @@ const HTTP_HEADER_ENV_DENYLIST: &[&str] = &[OPENAI_IDENTITY_TOKEN_FILE_ENV_VAR,OPENAI_WORKLOAD_IDENTITY_CONTEXT_ENV_VAR,"OPENAI_API_KEY",+ "CODEX_GUARDIAN_DECISIONS_API_KEY","CODEX_API_KEY","CODEX_ACCESS_TOKEN","CODEX_CONNECTORS_TOKEN",diff --git a/codex-rs/exec-server/tests/http_request.rs b/codex-rs/exec-server/tests/http_request.rsindex 55144de11e..537b7fb346 100644--- a/codex-rs/exec-server/tests/http_request.rs+++ b/codex-rs/exec-server/tests/http_request.rs@@ -157,6 +157,8 @@ async fn exec_server_http_request_rejects_protected_environment_headers() -> any"CODEX_EXEC_SERVER_NOISE_AUTH_TOKEN","codex_exec_server_noise_auth_token","OPENAI_API_KEY",+ "CODEX_GUARDIAN_DECISIONS_API_KEY",+ "codex_guardian_decisions_api_key","CODEX_ACCESS_TOKEN","CODEX_CONNECTORS_TOKEN","AWS_SECRET_ACCESS_KEY",diff --git a/codex-rs/protocol/src/shell_environment.rs b/codex-rs/protocol/src/shell_environment.rsindex e8bdaa40ca..427fe4969f 100644--- a/codex-rs/protocol/src/shell_environment.rs+++ b/codex-rs/protocol/src/shell_environment.rs@@ -14,6 +14,7 @@ pub const OPENAI_WORKLOAD_IDENTITY_CONTEXT_ENV_VAR: &str = "OPENAI_WORKLOAD_IDENpub const NON_INHERITABLE_ENV_VARS: &[&str] = &[CODEX_EXEC_SERVER_NOISE_AUTH_TOKEN_ENV_VAR,"NODE_REPL_AUTH_TOKEN",+ "CODEX_GUARDIAN_DECISIONS_API_KEY",OPENAI_FEDERATION_RULE_ID_ENV_VAR,OPENAI_IDENTITY_TOKEN_FILE_ENV_VAR,OPENAI_WORKLOAD_IDENTITY_CONTEXT_ENV_VAR,diff --git a/codex-rs/protocol/src/shell_environment_tests.rs b/codex-rs/protocol/src/shell_environment_tests.rsindex 2ec577e9b4..c987f631db 100644--- a/codex-rs/protocol/src/shell_environment_tests.rs+++ b/codex-rs/protocol/src/shell_environment_tests.rs@@ -13,6 +13,10 @@ const TEST_NAME: &str =fn non_inheritable_environment_is_removed_after_policy_overrides() {let vars = [("SAFE".to_string(), "inherited".to_string()),+ (+ "codex_guardian_decisions_api_key".into(),+ "synthetic-inherited-key".into(),+ ),("node_repl_auth_token".into(), "inherited-token".into()),("openai_federation_rule_id".to_string(),@@ -32,6 +36,10 @@ fn non_inheritable_environment_is_removed_after_policy_overrides() {ignore_default_excludes: true,r#set: HashMap::from([("SAFE".to_string(), "override".to_string()),+ (+ "CODEX_GUARDIAN_DECISIONS_API_KEY".into(),+ "synthetic-override-key".into(),+ ),("Node_Repl_Auth_Token".into(), "configured-token".into()),("OpenAI_Identity_Token_File".to_string(),@@ -57,6 +65,10 @@ fn command_scrubber_removes_names_from_real_child_environment() {let output = Command::new(std::env::current_exe().expect("locate current test binary")).args([TEST_NAME, "--exact", "--nocapture"]).env(CHILD_MODE_ENV_VAR, "1")+ .env(+ "Codex_Guardian_Decisions_Api_Key",+ "synthetic-inherited-key",+ ).env("Node_Repl_Auth_Token", "inherited-token").env("OpenAI_Federation_Rule_Id", "inherited-rule").env(@@ -86,6 +98,7 @@ fn command_scrubber_removes_names_from_real_child_environment() {CODEX_EXEC_SERVER_NOISE_AUTH_TOKEN_ENV_VAR,"configured-noise-token",)+ .env("CODEX_GUARDIAN_DECISIONS_API_KEY", "synthetic-override-key").env("SAFE", "value");scrub_non_inheritable_env_vars(&mut command);let output = command.output().expect("read child environment");