mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Protect the guardian decisions API key from environment forwarding (#50019)
## What changed Add `CODEX_GUARDIAN_DECISIONS_API_KEY` to the non-inheritable environment variables and the HTTP header environment denylist. Case-insensitive filtering removes it from child process environments, including explicit shell policy and command overrides, and rejects its use through `http/request` header `value_env_var`. ## Testing Extend regression coverage for inherited and overridden variables, mixed-case names, and HTTP header rejection before any network request is sent. GitOrigin-RevId: 1adeef814fdccb2d6c77dd68f7a5dfcec0b41cc6
This commit is contained in:
@@ -14,6 +14,7 @@ pub const OPENAI_WORKLOAD_IDENTITY_CONTEXT_ENV_VAR: &str = "OPENAI_WORKLOAD_IDEN
|
||||
pub 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,
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user