Skip to content

feat(runtime): accept launcher TLS trust snapshots - #7943

Open
shellz-n-stuff wants to merge 1 commit into
codex/launcher-endpointsfrom
codex/launcher-tls
Open

shellz-n-stuff wants to merge 1 commit into
codex/launcher-endpointsfrom
codex/launcher-tls

Conversation

@shellz-n-stuff

@shellz-n-stuff shellz-n-stuff commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Allow an external launcher to supply a certificate snapshot for agent and CLI HTTPS requests. Without the environment setting, normal platform trust remains unchanged. Invalid snapshots fail closed and hostname checks remain enabled.

Stack 2/3: base codex/launcher-endpoints; next: credential broker.

Validation: synthetic TLS tests (trusted certificate, wrong hostname, missing snapshot) and 12 CLI regressions pass. Tests are included in this slice. No credential broker or plugin dependency.

Review / merge order: #7942 → #7943 → #7944. Related: #5286. Replaces #7940.

Required push checks passed for this branch. Hosted CI is tracked on the PR.

// Explicit Buzz-owned OAuth root for named demo builds. The agent may spawn
// auth-capable child tools after clearing its ambient environment.
"BUZZ_AGENT_CONFIG_DIR",
// Read-only launcher trust snapshot; do not forward the auth-broker capability.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So taking this path as an env var is the key security piece here. We could require/enforce a specific directory but I think that's explicitly easier to exploit than injecting an env var into what's running Buzz

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 I agree the env var is the right transport for the launcher. My worry is a different injection path: desktop merges user and persona env into managed agents, and BUZZ_SANDBOX_TLS_ROOTS isn't in RESERVED_ENV_KEYS (desktop/src-tauri/src/managed_agents/reserved_env_keys.rs). That list exists for exactly this kind of security gate, and BUZZ_RELAY_URL and BUZZ_AGENT_CONFIG_DIR are already on it. If this key can be set through ordinary agent env config, then setting it together with HTTPS_PROXY would let whoever holds that proxy see model API keys and the CLI's NIP-98 / x-auth-tag headers. Before this PR, HTTPS_PROXY on its own would just fail TLS verification. Would you be open to reserving the key in desktop in this PR? The launcher sets the child env directly, so I don't think that affects Sandpit.

Separately, the "do not forward the auth-broker capability" part of this comment refers to #7944, so it might read better to move that line over there.

@shellz-n-stuff
shellz-n-stuff marked this pull request as ready for review September 28, 2026 15:20
@shellz-n-stuff
shellz-n-stuff requested a review from a team as a code owner September 28, 2026 15:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T15:25:57.449472Z b640a33 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b640a332a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

impl Llm {
pub fn new(cfg: &Config) -> Result<Self, AgentError> {
let http = Client::builder()
let http = crate::sandbox_runtime::http_builder()?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Apply the trust snapshot to the OAuth client

When BUZZ_SANDBOX_TLS_ROOTS contains the only CA trusted for a Databricks workspace and DATABRICKS_TOKEN is unset, the LLM client trusts the snapshot but build_token_source constructs PkceOAuthTokenSource with the unchanged Client::builder() in auth.rs. Its OIDC discovery, refresh, and token requests therefore reject the workspace certificate, preventing authentication and model discovery before any LLM request can run. Construct the PKCE HTTP client from the shared snapshot-aware builder as well.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 +1, this still reproduces at 1815161. PkceOAuthTokenSource::new_with_http_timeout (auth.rs:417) builds from plain Client::builder(), and that's the client used for discovery, code exchange, and refresh in build_token_source, catalog discovery, and buzz-agent auth. #7944 skips PKCE when the broker is configured, but #7943 is meant to work on its own, and with a snapshot-only CA the model call would trust the endpoint while token refresh wouldn't. I'd route it through http_builder() and keep the timeout. It'd also be good to add a private-CA test that goes through the production constructor, so the test breaks if the wiring gets removed.

Comment on lines +19 to +20
let bytes = std::fs::read(path).map_err(|_| fail())?;
if bytes.len() > 8 * 1024 * 1024 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the snapshot while reading it

If the launcher supplies a very large file or a non-terminating device such as /dev/zero, std::fs::read consumes the entire input before the 8 MiB check executes, so malformed input can exhaust memory or hang startup instead of failing closed. Read through a limit of 8 MiB plus one byte, then reject overflow before parsing.

AGENTS.md reference: AGENTS.md:L240-L248

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 +1. I'd cap the read itself with something like File::open(path)?.take(8 MiB + 1) and reject if you get the extra byte. A metadata() check alone wouldn't catch /dev/zero or a file that grows while you're reading it.

Signed-off-by: Alex Rosenzweig <arosenzweig@squareup.com>

@wpfleger96 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 hey @shellz-n-stuff, the core TLS piece looks solid to me. As far as I can tell, tls_certs_only on reqwest 0.13.4 really does move the wired clients onto local rustls verification with only the snapshot roots, hostname checks still apply, and a bad snapshot makes client construction fail instead of silently falling back. Unset means nothing changes.

I left the bigger items as replies on the existing threads so they don't get duplicated. The main ones are that the Databricks OAuth client still ignores the snapshot, and whether desktop should reserve BUZZ_SANDBOX_TLS_ROOTS. The inline comments below are smaller.

On coverage, I think it'd help to document which clients honor the snapshot and which don't. It isn't every HTTPS/WSS client in the agent and CLI yet:

  • The CLI's ephemeral publish (publish_ephemeral_event → buzz_ws_client::publish_event → tokio-tungstenite with webpki roots) doesn't honor it, so something like buzz users set-presence won't pick up the snapshot.
  • Forwarding the var to MCP children doesn't make their clients use it either. For example, buzz-dev-mcp's view_image still builds a plain reqwest client.
  • DatabricksConnection::new also uses a plain builder. I wouldn't just swap that one, though, since DATABRICKS_REUSE.md describes it as runtime-config-independent. Probably the caller should pass trust explicitly, if it needs it at all.

I don't think all of those need fixing in this PR. The doc comment should just say what's covered.

use std::{path::Path, sync::Arc};

/// Path to the immutable certificate snapshot supplied by the launcher.
pub const ROOTS_ENV: &str = "BUZZ_SANDBOX_TLS_ROOTS";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: this const is a duplicate of buzz_runtime_support::tls::ROOTS_ENV, and nothing uses it. mcp.rs also writes the name out as a string literal. I'd keep just the runtime-support one and reference it from PASSTHROUGH_ENV.

mod tests {
use super::*;
use reqwest::StatusCode;
#[test]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 I think these tests belong in buzz-runtime-support next to the code, which would also let you drop the test-only builder_with_roots wrapper here. A few things aren't covered yet:

  • the http_builder() env branch: unset should give platform trust, set should give the snapshot
  • each rejection path: bad JSON, empty array, bad DER (which fails at build(), not from_der), an oversized file, and an unreadable path

The untrusted client at the end is mostly testing reqwest rather than this code, so I'd swap it for one of those.

if bytes.len() > 8 * 1024 * 1024 {
return Err(fail());
}
let roots: Vec<Vec<u8>> = serde_json::from_slice(&bytes).map_err(|_| fail())?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Small question: why a JSON array of DER byte arrays rather than a PEM bundle? JSON number arrays are roughly 4x bigger, and the usual SSL_CERT_FILE-style tooling can't produce this format. If the launcher already emits it that's fine. A one-line comment on the format choice would help whoever writes the next launcher.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants