Restrict hosted MCP credentials to local environments (#36306)

## Why

Executor-owned MCP servers must not receive hosted ChatGPT actor credentials or credentials from the host's OAuth store.

## What changed

- Provide the ChatGPT auth provider and consult stored OAuth credentials only for MCP servers in the local environment.
- Require non-local servers configured with `auth = "chatgpt"` to supply a non-empty, valid static `Authorization` header. Reject environment-backed authorization so host secrets are not resolved for an executor-owned server.
- Report unsupported authentication and fail startup before connecting when an executor-owned server has no acceptable explicit authorization.

## Testing

Add coverage for local credential forwarding, non-local credential isolation, static header validation, auth status, OAuth lookup avoidance, and startup rejection.

GitOrigin-RevId: e18f1878f260c93d9babd390a5a7eac86172299b
This commit is contained in:
jif authored and copyberry committed 2026-07-31 10:42:02 +00:00
1 parent f0c30e528a
commit bf4d3f51ea
5 files changed
+310 -2

No files matched your search

+9
View File
@@ -20,6 +20,7 @@ use tracing::warn;
use crate::runtime::McpRuntimeContext;
use crate::server::EffectiveMcpServer;
use crate::server::has_explicit_http_authorization;
#[derive(Debug, Clone)]
pub struct McpOAuthLoginConfig {
@@ -216,6 +217,14 @@ async fn compute_auth_status(
return Ok(McpAuthState::Unsupported);
}
if matches!(config.auth, McpServerAuth::ChatGpt) && !config.is_local_environment() {
return Ok(if has_explicit_http_authorization(config) {
McpAuthState::BearerToken
} else {
McpAuthState::Unsupported
});
}
if has_runtime_auth {
return Ok(McpAuthState::BearerToken);
}