Residui OpenAI: nessun nome di dominio OpenAI nel binario (B)

Parte "sicurezza" di 854c7a66 (senza la rimozione della memoria nativa):
- via openai_docs_source_attribution (intestazioni verso developers.openai.com per i server MCP);
- exec-server: chiave API accettata solo verso host loopback (non piu' openai.com/openai.org);
- git-attribution: nessuna istruzione "Co-authored-by: Codex <noreply@openai.com>" generata;
  le istruzioni lasciate nelle cronologie di Codex vengono solo annullate;
- http-client/openai_endpoints: elenco degli host OpenAI per etichette, senza nomi di dominio interi.
Test adattati (non cancellati) salvo quelli del codice rimosso (openai_docs_source_attribution).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:47:29 +01:00
parent 77a19832b3
commit a354f0f00c
10 changed files with 120 additions and 272 deletions

View File

@@ -43,22 +43,12 @@ pub(super) fn validate_api_key_remote_host(base_url: &str) -> anyhow::Result<()>
url::Host::Ipv4(ip) => ip.is_loopback(),
url::Host::Ipv6(ip) => ip.is_loopback(),
};
let is_openai_host = match &host {
url::Host::Domain(host) => ["openai.com", "openai.org"].into_iter().any(|domain| {
host.eq_ignore_ascii_case(domain)
|| host.to_ascii_lowercase().ends_with(&format!(".{domain}"))
}),
_ => false,
};
let is_allowed = match url.scheme() {
"https" => is_loopback || is_openai_host,
"http" => is_loopback,
_ => false,
};
// aKode: the API key never leaves the machine (no OpenAI-hosted registration).
let is_allowed = matches!(url.scheme(), "https" | "http") && is_loopback;
if !is_allowed {
anyhow::bail!(
"remote exec-server API-key authentication is restricted to HTTPS openai.com and openai.org hosts and subdomains or loopback hosts"
"remote exec-server API-key authentication is restricted to loopback hosts"
);
}

View File

@@ -11,13 +11,22 @@ fn exec_server_remote_auth_accepts_api_key_auth() {
}
#[test]
fn exec_server_remote_api_key_auth_accepts_https_openai_domains() {
fn exec_server_remote_api_key_auth_rejects_remote_https_hosts() {
// aKode never sends the API key to a remote registration host, OpenAI's included.
for base_url in [
"https://openai.com/api",
"https://service.openai.com/api",
"https://openai.org/api",
"https://service.openai.org/api",
"https://example.com/api",
] {
let error = validate_api_key_remote_host(base_url).expect_err("reject remote host");
assert_eq!(error.to_string(), "remote exec-server API-key authentication is restricted to loopback hosts");
}
}
#[test]
fn exec_server_remote_api_key_auth_accepts_https_loopback() {
for base_url in ["https://localhost:8098/api", "https://127.0.0.1:8098/api"] {
assert!(validate_api_key_remote_host(base_url).is_ok());
}
}
@@ -44,7 +53,7 @@ fn exec_server_remote_api_key_auth_rejects_http_openai_domain() {
assert_eq!(
error.to_string(),
"remote exec-server API-key authentication is restricted to HTTPS openai.com and openai.org hosts and subdomains or loopback hosts"
"remote exec-server API-key authentication is restricted to loopback hosts"
);
}
}
@@ -56,6 +65,6 @@ fn exec_server_remote_api_key_auth_rejects_suffix_spoof() {
assert_eq!(
error.to_string(),
"remote exec-server API-key authentication is restricted to HTTPS openai.com and openai.org hosts and subdomains or loopback hosts"
"remote exec-server API-key authentication is restricted to loopback hosts"
);
}

View File

@@ -1,6 +1,5 @@
---
source: exec-server-cli/src/exec_server_args_tests.rs
assertion_line: 318
expression: help
---
[EXPERIMENTAL] Run the standalone exec-server service
@@ -24,7 +23,7 @@ Options:
--strict-config
Error out when config.toml contains fields that are not recognized by
this version of Codex
this version of aKode
--linux-sandbox-pid-namespace <MODE>
Linux PID namespace: isolate (default) or inherit. Inherit allows