Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(llm): keep provider credentials on their origin

lhzapata2f1630938893
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fee7fa0b..e1cf2cd0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,13 @@ version in [`docs/changelog/`](docs/changelog/):
## [Unreleased]
### Fixed
+- Stopped LLM provider and embedder requests from following a redirect to
+ another origin. reqwest drops `Authorization` on a cross-host hop but keeps
+ every other header, so `x-api-key`, `x-goog-api-key` and operator headers
+ from `llm_headers` reached whatever host a configured endpoint redirected
+ to. Redirects inside the same origin still work; one that changes scheme,
+ host or port now fails the request and names the origin it pointed at.
+ ([#1396](https://github.com/akitaonrails/ai-memory/pull/1396))
- Fixed `memory_lint` reporting findings for TTL-expired pages. The lint pass
now omits expired pages before evaluating episodic staleness, rule suggestions,
duplicate titles, and vector or LLM contradiction candidates, preventing
diff --git a/crates/ai-memory-llm/src/anthropic.rs b/crates/ai-memory-llm/src/anthropic.rs
index ed4cf494..fb5a0587 100644
--- a/crates/ai-memory-llm/src/anthropic.rs
+++ b/crates/ai-memory-llm/src/anthropic.rs
@@ -68,7 +68,9 @@ impl AnthropicProvider {
/// Returns a `reqwest::Error` if the underlying HTTP client cannot
/// be built.
pub fn new(api_key: SecretString, model: impl Into<String>) -> LlmResult<Self> {
- let client = reqwest::Client::builder().build()?;
+ let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()?;
Ok(Self {
client,
auth: AnthropicAuth::ApiKey(api_key),
@@ -91,7 +93,9 @@ impl AnthropicProvider {
/// Returns a `reqwest::Error` if the underlying HTTP client cannot
/// be built.
pub fn new_oauth(token: SecretString, model: impl Into<String>) -> LlmResult<Self> {
- let client = reqwest::Client::builder().build()?;
+ let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()?;
Ok(Self {
client,
auth: AnthropicAuth::OAuth(token),
diff --git a/crates/ai-memory-llm/src/codex.rs b/crates/ai-memory-llm/src/codex.rs
index dfc2a11c..2a975028 100644
--- a/crates/ai-memory-llm/src/codex.rs
+++ b/crates/ai-memory-llm/src/codex.rs
@@ -74,7 +74,10 @@ impl CodexProvider {
pub fn new(auth: CodexAuth, model: impl Into<String>) -> LlmResult<Self> {
read_credentials(&auth.auth_file)?;
Ok(Self {
- client: reqwest::Client::builder().build().map_err(LlmError::from)?,
+ client: reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()
+ .map_err(LlmError::from)?,
model: model.into(),
auth,
timeout: Duration::from_secs(crate::DEFAULT_REQUEST_TIMEOUT_SECS),
diff --git a/crates/ai-memory-llm/src/copilot.rs b/crates/ai-memory-llm/src/copilot.rs
index 3abf872d..ae081c26 100644
--- a/crates/ai-memory-llm/src/copilot.rs
+++ b/crates/ai-memory-llm/src/copilot.rs
@@ -210,6 +210,7 @@ impl CopilotAuthState {
)));
}
let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
.user_agent(COPILOT_USER_AGENT)
.build()
.map_err(LlmError::from)?;
diff --git a/crates/ai-memory-llm/src/embedding.rs b/crates/ai-memory-llm/src/embedding.rs
index 6d39274a..062f240e 100644
--- a/crates/ai-memory-llm/src/embedding.rs
+++ b/crates/ai-memory-llm/src/embedding.rs
@@ -156,6 +156,7 @@ impl OpenAiEmbedder {
// sub-second. When the embedder still fails, memory_query
// degrades gracefully to FTS5 + entity + graph (see server.rs).
let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
.timeout(Duration::from_secs(120))
.build()?;
Ok(Self {
@@ -443,6 +444,7 @@ impl OpenAiCompatEmbedder {
// Same cold-load tolerance as OpenAiEmbedder: first request
// after an Ollama model unload can take ~30s.
let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
.timeout(Duration::from_secs(120))
.build()?;
Ok(Self {
@@ -555,6 +557,7 @@ impl VoyageEmbedder {
// sub-second. When the embedder still fails, memory_query
// degrades gracefully to FTS5 + entity + graph (see server.rs).
let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
.timeout(Duration::from_secs(120))
.build()?;
Ok(Self {
diff --git a/crates/ai-memory-llm/src/gemini.rs b/crates/ai-memory-llm/src/gemini.rs
index cdc0894d..cfe625ed 100644
--- a/crates/ai-memory-llm/src/gemini.rs
+++ b/crates/ai-memory-llm/src/gemini.rs
@@ -41,7 +41,9 @@ impl GeminiProvider {
/// # Errors
/// Returns a `reqwest::Error` if the HTTP client cannot be built.
pub fn new(api_key: SecretString, model: impl Into<String>) -> LlmResult<Self> {
- let client = reqwest::Client::builder().build()?;
+ let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()?;
Ok(Self {
client,
api_key,
diff --git a/crates/ai-memory-llm/src/google.rs b/crates/ai-memory-llm/src/google.rs
index be52ea56..84a1053f 100644
--- a/crates/ai-memory-llm/src/google.rs
+++ b/crates/ai-memory-llm/src/google.rs
@@ -38,6 +38,7 @@ impl GoogleEmbedder {
/// Propagates HTTP client construction errors.
pub fn new(api_key: SecretString, model: impl Into<String>, dim: u32) -> LlmResult<Self> {
let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
.timeout(Duration::from_secs(120))
.build()?;
let model = normalize_model_id(model.into());
diff --git a/crates/ai-memory-llm/src/lib.rs b/crates/ai-memory-llm/src/lib.rs
index fa0018d8..ce9a70c7 100644
--- a/crates/ai-memory-llm/src/lib.rs
+++ b/crates/ai-memory-llm/src/lib.rs
@@ -98,6 +98,7 @@ pub mod types;
mod auth_file;
mod codex_responses;
+mod redirect;
mod response;
mod stored_token;
mod text;
diff --git a/crates/ai-memory-llm/src/openai.rs b/crates/ai-memory-llm/src/openai.rs
index a8f59d31..fb1749bb 100644
--- a/crates/ai-memory-llm/src/openai.rs
+++ b/crates/ai-memory-llm/src/openai.rs
@@ -138,7 +138,9 @@ impl OpenAiProvider {
/// # Errors
/// Returns a `reqwest::Error` if the HTTP client cannot be built.
pub fn new(api_key: SecretString, model: impl Into<String>) -> LlmResult<Self> {
- let client = reqwest::Client::builder().build()?;
+ let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()?;
Ok(Self {
client,
api_key,
diff --git a/crates/ai-memory-llm/src/openai_oauth.rs b/crates/ai-memory-llm/src/openai_oauth.rs
index 416c516c..a9951d9d 100644
--- a/crates/ai-memory-llm/src/openai_oauth.rs
+++ b/crates/ai-memory-llm/src/openai_oauth.rs
@@ -154,7 +154,10 @@ impl OpenAiOAuthProvider {
token_path.display()
))
})?;
- let client = reqwest::Client::builder().build().map_err(LlmError::from)?;
+ let client = reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()
+ .map_err(LlmError::from)?;
Ok(Self {
client,
model: model.into(),
diff --git a/crates/ai-memory-llm/src/opencode.rs b/crates/ai-memory-llm/src/opencode.rs
index 7d462fbf..8fd1680e 100644
--- a/crates/ai-memory-llm/src/opencode.rs
+++ b/crates/ai-memory-llm/src/opencode.rs
@@ -340,7 +340,9 @@ struct OpenCodeResponsesProvider {
impl OpenCodeResponsesProvider {
fn new(api_key: SecretString, model: String, base_url: String) -> LlmResult<Self> {
Ok(Self {
- client: reqwest::Client::builder().build()?,
+ client: reqwest::Client::builder()
+ .redirect(crate::redirect::same_origin_redirects())
+ .build()?,
api_key,
base_url,
model,
diff --git a/crates/ai-memory-llm/src/redirect.rs b/crates/ai-memory-llm/src/redirect.rs
new file mode 100644
index 00000000..4bf56d32
--- /dev/null
+++ b/crates/ai-memory-llm/src/redirect.rs
@@ -0,0 +1,34 @@
+//! Redirect policy for provider and embedder clients.
+//!
+//! reqwest's default policy follows up to ten redirects and strips only
+//! `Authorization`, cookies and the proxy headers when the host changes.
+//! Provider credentials that travel in headers of their own (`x-api-key`,
+//! `x-goog-api-key`, operator headers from `llm_headers`) survive that hop,
+//! so a configured endpoint that redirects elsewhere would hand them to a
+//! host the operator never configured. Following redirects only inside the
+//! origin the request was sent to keeps path rewrites working and refuses
+//! the rest, like the relay's `Policy::none()` does for its batches.
+
+/// Same hop limit as reqwest's default policy.
+const MAX_REDIRECTS: usize = 10;
+
+/// Follow a redirect only when it stays on the scheme, host and port of the
+/// previous request.
+pub(crate) fn same_origin_redirects() -> reqwest::redirect::Policy {
+ reqwest::redirect::Policy::custom(|attempt| {
+ let same_origin = attempt
+ .previous()
+ .last()
+ .is_some_and(|previous| previous.origin() == attempt.url().origin());
+ if !same_origin {
+ let target = attempt.url().origin().ascii_serialization();
+ attempt.error(format!(
+ "refused a redirect to another origin ({target}); set the endpoint to its final URL"
+ ))
+ } else if attempt.previous().len() > MAX_REDIRECTS {
+ attempt.error("too many redirects")
+ } else {
+ attempt.follow()
+ }
+ })
+}
diff --git a/crates/ai-memory-llm/tests/suite/mod.rs b/crates/ai-memory-llm/tests/suite/mod.rs
index cd14007b..1f2beb74 100644
--- a/crates/ai-memory-llm/tests/suite/mod.rs
+++ b/crates/ai-memory-llm/tests/suite/mod.rs
@@ -11,3 +11,4 @@ mod fallback_provider;
mod openai_compat_embedder;
mod openai_compat_guardrails;
mod openai_compat_strict;
+mod redirect_credentials;
diff --git a/crates/ai-memory-llm/tests/suite/redirect_credentials.rs b/crates/ai-memory-llm/tests/suite/redirect_credentials.rs
new file mode 100644
index 00000000..d71d33a0
--- /dev/null
+++ b/crates/ai-memory-llm/tests/suite/redirect_credentials.rs
@@ -0,0 +1,261 @@
+//! What a provider request carries when its endpoint answers with a
+//! cross-origin redirect. Two loopback mocks on different ports are two
+//! origins: `first` answers 307 pointing at `second`, and the assertions
+//! read what `second` received.
+//!
+//! reqwest strips `Authorization` (and cookies) on a cross-host redirect, but
+//! nothing else, so a credential in a header of its own would reach whatever
+//! host the redirect names. Provider clients therefore follow a redirect only
+//! inside one origin.
+
+use ai_memory_llm::types::ChatRequest;
+use ai_memory_llm::{
+ Embedder, ExtraHeaders, GoogleEmbedder, ProviderAuth, ProviderChoice, ProviderConfig,
+ build_provider,
+};
+use secrecy::SecretString;
+use wiremock::matchers::any;
+use wiremock::{Mock, MockServer, Request, ResponseTemplate};
+
+/// A mock that answers every request with `status` and a `Location`
+/// pointing at `target`.
+async fn redirecting_to(target: &str, status: u16) -> MockServer {
+ let server = MockServer::start().await;
+ Mock::given(any())
+ .respond_with(ResponseTemplate::new(status).insert_header("location", target))
+ .mount(&server)
+ .await;
+ server
+}
+
+/// A mock that records everything and answers 500, so a provider that does
+/// reach it fails fast instead of retrying a parse.
+async fn recording() -> MockServer {
+ let server = MockServer::start().await;
+ Mock::given(any())
+ .respond_with(ResponseTemplate::new(500))
+ .mount(&server)
+ .await;
+ server
+}
+
+async fn received(server: &MockServer) -> Vec<Request> {
+ server.received_requests().await.expect("mock records")
+}
+
+fn has_header(request: &Request, name: &str) -> bool {
+ request.headers.get(name).is_some()
+}
+
+fn config(provider: ProviderChoice, auth: ProviderAuth, base_url: String) -> ProviderConfig {
+ ProviderConfig {
+ provider,
+ model: "m".into(),
+ auth,
+ base_url: Some(base_url),
+ compat_strict: false,
+ compat_disable_thinking: false,
+ request_timeout_secs: 5,
+ reasoning_effort: None,
+ extra_headers: ExtraHeaders::parse(["x-gateway-key: gateway-secret"]).expect("valid"),
+ }
+}
+
+/// Gemini authenticates with `x-goog-api-key`, which reqwest's redirect
+/// guard does not know about.
+#[tokio::test]
+async fn gemini_api_key_does_not_follow_a_cross_origin_redirect() {
+ let second = recording().await;
+ let first = redirecting_to(&format!("{}/elsewhere", second.uri()), 307).await;
+ let provider = build_provider(config(
+ ProviderChoice::Gemini,
+ ProviderAuth::required_api_key_from_env(
+ "GEMINI_API_KEY",
+ Some(SecretString::from("gemini-secret".to_string())),
+ ),
+ first.uri(),
+ ))
+ .expect("provider builds");
+
+ let _ = provider.complete(ChatRequest::user_prompt("hi")).await;
+
+ let leaked: Vec<_> = received(&second)
+ .await
+ .into_iter()
+ .filter(|r| has_header(r, "x-goog-api-key") || has_header(r, "x-gateway-key"))
+ .collect();
+ assert!(
+ leaked.is_empty(),
+ "the redirect target received the API key or an operator header ({} request(s))",
+ leaked.len()
+ );
+}
+
+/// Anthropic sends `x-api-key`, and honours `base_url` for a gateway.
+#[tokio::test]
+async fn anthropic_api_key_does_not_follow_a_cross_origin_redirect() {
+ let second = recording().await;
+ let first = redirecting_to(&format!("{}/elsewhere", second.uri()), 307).await;
+ let provider = build_provider(config(
+ ProviderChoice::Anthropic,
+ ProviderAuth::required_api_key_from_env(
+ "ANTHROPIC_API_KEY",
+ Some(SecretString::from("anthropic-secret".to_string())),
+ ),
+ first.uri(),
+ ))
+ .expect("provider builds");
+
+ let _ = provider.complete(ChatRequest::user_prompt("hi")).await;
+
+ let leaked: Vec<_> = received(&second)
+ .await
+ .into_iter()
+ .filter(|r| has_header(r, "x-api-key") || has_header(r, "x-gateway-key"))
+ .collect();
+ assert!(
+ leaked.is_empty(),
+ "the redirect target received the API key or an operator header ({} request(s))",
+ leaked.len()
+ );
+}
+
+/// The gateway case: `openai-compat` with a key and an operator header.
+/// `Authorization` is the control — reqwest already strips it — and the
+/// operator header is the one that survives.
+#[tokio::test]
+async fn operator_headers_do_not_follow_a_cross_origin_redirect() {
+ let second = recording().await;
+ let first = redirecting_to(&format!("{}/elsewhere", second.uri()), 307).await;
+ let provider = build_provider(config(
+ ProviderChoice::OpenAiCompat,
+ ProviderAuth::optional_api_key_from_env(
+ "LLM_API_KEY",
+ Some(SecretString::from("bearer-secret".to_string())),
+ ),
+ first.uri(),
+ ))
+ .expect("provider builds");
+
+ let _ = provider.complete(ChatRequest::user_prompt("hi")).await;
+
+ let at_second = received(&second).await;
+ assert!(
+ at_second.iter().all(|r| !has_header(r, "authorization")),
+ "control: reqwest strips Authorization on a cross-host redirect"
+ );
+ assert!(
+ at_second.iter().all(|r| !has_header(r, "x-gateway-key")),
+ "the redirect target received the operator header ({} request(s))",
+ at_second.len()
+ );
+}
+
+/// Control: a redirect inside the same origin keeps working, so a fix that
+/// only refuses origin changes does not break a gateway that rewrites paths.
+#[tokio::test]
+async fn a_same_origin_redirect_still_reaches_the_provider() {
+ let server = MockServer::start().await;
+ Mock::given(wiremock::matchers::path("/landing"))
+ .respond_with(ResponseTemplate::new(500))
+ .with_priority(1)
+ .mount(&server)
+ .await;
+ Mock::given(any())
+ .respond_with(
+ ResponseTemplate::new(307)
+ .insert_header("location", format!("{}/landing", server.uri())),
+ )
+ .with_priority(2)
+ .mount(&server)
+ .await;
+ let provider = build_provider(config(
+ ProviderChoice::Gemini,
+ ProviderAuth::required_api_key_from_env(
+ "GEMINI_API_KEY",
+ Some(SecretString::from("gemini-secret".to_string())),
+ ),
+ server.uri(),
+ ))
+ .expect("provider builds");
+
+ let _ = provider.complete(ChatRequest::user_prompt("hi")).await;
+
+ let landed: Vec<_> = received(&server)
+ .await
+ .into_iter()
+ .filter(|r| r.url.path() == "/landing")
+ .collect();
+ assert!(
+ !landed.is_empty(),
+ "the same-origin redirect was not followed"
+ );
+ assert!(
+ landed.iter().all(|r| has_header(r, "x-goog-api-key")),
+ "a same-origin redirect keeps the key"
+ );
+}
+
+/// The Google embedder sends the same `x-goog-api-key` from its own client.
+#[tokio::test]
+async fn google_embedder_key_does_not_follow_a_cross_origin_redirect() {
+ let second = recording().await;
+ let first = redirecting_to(&format!("{}/elsewhere", second.uri()), 307).await;
+ let embedder = GoogleEmbedder::new(
+ SecretString::from("google-secret".to_string()),
+ "gemini-embedding-001",
+ 768,
+ )
+ .expect("embedder builds")
+ .with_base_url(first.uri());
+
+ let _ = embedder.embed("hi").await;
+
+ let leaked: Vec<_> = received(&second)
+ .await
+ .into_iter()
+ .filter(|r| has_header(r, "x-goog-api-key"))
+ .collect();
+ assert!(
+ leaked.is_empty(),
+ "the redirect target received the embedder key ({} request(s))",
+ leaked.len()
+ );
+}
+
+/// The refusal names the origin it would have gone to, so an operator can
+/// point the endpoint at its final URL.
+#[tokio::test]
+async fn a_refused_redirect_says_where_it_pointed() {
+ let second = recording().await;
+ let first = redirecting_to(&format!("{}/elsewhere", second.uri()), 308).await;
+ let provider = build_provider(config(
+ ProviderChoice::Gemini,
+ ProviderAuth::required_api_key_from_env(
+ "GEMINI_API_KEY",
+ Some(SecretString::from("gemini-secret".to_string())),
+ ),
+ first.uri(),
+ ))
+ .expect("provider builds");
+
+ let err = provider
+ .complete(ChatRequest::user_prompt("hi"))
+ .await
+ .expect_err("a cross-origin redirect fails the request");
+
+ assert!(
+ received(&second).await.is_empty(),
+ "nothing reaches the other origin"
+ );
+ let mut message = err.to_string();
+ let mut source = std::error::Error::source(&err);
+ while let Some(cause) = source {
+ message.push_str(&format!(": {cause}"));
+ source = cause.source();
+ }
+ assert!(
+ message.contains("another origin") && message.contains(&second.uri()),
+ "the error explains the refusal: {message}"
+ );
+}
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 797b8fb9..f5cdc2d2 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -1312,7 +1312,10 @@ AI_MEMORY_LLM_BASE_URL required for openai-compat (Ollama, vLLM); optional o
Applies to every HTTP API provider: naming ai-memory
is how an operator says a vendor endpoint is proxied
on purpose. The ChatGPT backend (openai-oauth, codex)
- and cursor's CLI have no override
+ and cursor's CLI have no override. Provider and
+ embedder clients follow a redirect only on the
+ origin they sent to, so set the URL a gateway
+ redirects to rather than one that moves hosts
LLM_BASE_URL the unprefixed cross-tool convention, accepted for
openai-compat and opencode only. Providers with a
fixed vendor endpoint (anthropic, openai, gemini,
diff --git a/docs/security-boundaries.md b/docs/security-boundaries.md
index 3a359d43..bff1465a 100644
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@ -130,6 +130,7 @@ means the boundary is not built yet.
| 25 | Opt-in consolidation residue cannot turn captured observation text into prompt structure or a direct wiki write (#1215) | `ai-memory-consolidate/src/projection.rs` `render_verbatim_residue` excludes routing text, passes prompt-shaped observations through `profile::user_written`, strips tool metadata, mines bounded literal classes, rejects every Unicode/ASCII line end, and renders one indented token per line under an explicit untrusted-data header; total, group, token and observation-pruning caps bound work and disclosure. `Consolidator` includes the block only when `[consolidation] verbatim_residue` is true and still accepts only the existing JSON-schema structured response through the normal wiki-write boundary | projection `residue_keeps_hostile_lines_indented_and_never_forges_observation_headers` (instruction-shaped error plus forged header and mixed line endings; legitimate path control), `residue_refuses_harness_prompts_but_keeps_the_same_user_written_error` (harness block refused, user-written control admitted), `residue_stays_inside_projection_and_group_budgets_without_clipping`, `residue_off_is_byte_identical_and_on_is_inert_without_missing_text`; integration `verbatim_residue_consolidation::residue_changes_only_the_provider_request_not_the_stored_page` captures both requests and proves the fixed structured response produces the same page | STRONG for prompt framing and the direct-write boundary; enabling the option deliberately sends a wider bounded subset of already-sanitized capture to the configured provider |
| 26 | Cross-harness native-history continuation stays checkout-scoped and client-local | `ai-memory-store/src/workstream.rs` `prepare_run` selects the newest current native session only when its harness differs from the destination and pins that typed identity on the run before destination linking can change recency; `ai-memory-cli/src/commands/run.rs` validates the returned `NativeSessionIdentity`, resolves only known adapter flavors, requires `native_session_in_checkout`, exports through the bounded read-only adapter, and writes an untrusted-history dossier to a private temporary directory exposed only to the child as `AI_MEMORY_PREVIOUS_SESSION_HISTORY`; the server wire type deliberately has no path/content field and same-harness launches select no source; `ai-memory-hooks/src/router.rs` keeps the server-authored resume directive outside the untrusted-history fence while fencing the transcript evidence itself, and `ai-memory-core/src/routing_snippet.rs` gives installed project instructions the same wrapper-variable-gated fallback | Core `prepare_response_carries_only_previous_native_identity`, `older_prepare_response_defaults_to_no_adoption`, and `snippets_route_managed_continue_to_the_previous_native_history`; store `managed_adoption_stops_after_any_harness_links_the_workstream` (switch control, destination-link recency cannot replace the pinned source, same-harness refusal); hooks `managed_context_points_at_local_history_on_a_harness_switch` (no session id rendered, directive precedes the untrusted fence); CLI `previous_session_history_is_private_local_and_checkout_scoped` (legitimate control, foreign checkout refused, private local file removed with its owner) | STRONG for checkout isolation, prompt-boundary placement, and server path/content privacy. The dossier is a bounded visible-history projection, not raw hidden reasoning; if the source store is absent, remote, unreadable, or over bounds, the child receives only the portable ledger and handoff |
+| 27 | Provider credentials stay on the configured origin | `ai-memory-llm/src/redirect.rs` `same_origin_redirects`, set on every provider and embedder client (`anthropic.rs`, `codex.rs`, `copilot.rs`, `embedding.rs`, `gemini.rs`, `google.rs`, `openai.rs`, `openai_oauth.rs`, `opencode.rs`): a redirect is followed only when scheme, host and port match the previous request, with reqwest's ten-hop limit; any other redirect fails the request. reqwest's own guard strips only `Authorization`, cookies and the proxy headers, so `x-api-key`, `x-goog-api-key` and `llm_headers` values depend on this one. The local model download (`local.rs`) carries no credential and keeps the default policy for its CDN redirects; OIDC and CLI login requests refuse every redirect on clients of their own (`oidc.rs`, `auth.rs` `auth_http_client`) | `ai-memory-llm` `tests/suite/redirect_credentials.rs` `gemini_api_key_does_not_follow_a_cross_origin_redirect`, `anthropic_api_key_does_not_follow_a_cross_origin_redirect`, `operator_headers_do_not_follow_a_cross_origin_redirect` (with `Authorization` stripped as the control), `google_embedder_key_does_not_follow_a_cross_origin_redirect`, `a_refused_redirect_says_where_it_pointed`; legitimate control `a_same_origin_redirect_still_reaches_the_provider` (the key follows a path redirect on one origin); each cross-origin test fails with the policy removed | STRONG for the provider and embedder clients in `ai-memory-llm` |
### IBM Bob evidence