You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/llm_client.rs
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,12 @@ pub async fn ask_llm(
37
37
// 2. Generic OpenAI-compatible endpoint
38
38
let url = config.base_url.clone().unwrap_or_else(|| "https://api.openai.com/v1/chat/completions".to_string());
39
39
let env_var = config.api_key_env.as_deref().unwrap_or("OPENAI_API_KEY");
40
+
41
+
// P0 Security Fix: Prevent exfiltration of arbitrary host env vars (like AWS_SECRET_ACCESS_KEY or SSH_PRIVATE_KEY) via malicious plasticity.json
42
+
if !env_var.ends_with("_API_KEY") && !env_var.ends_with("_TOKEN") && env_var != "API_KEY"{
43
+
anyhow::bail!("Security Exception: To prevent credential exfiltration, `api_key_env` must end in '_API_KEY' or '_TOKEN'. Attempted to use: {}", env_var);
44
+
}
45
+
40
46
let api_key = std::env::var(env_var).unwrap_or_default();
0 commit comments