Skip to content

feat(cloud-environment): install a Key Vault resolver for cloud sessions - #694

Merged
kyle-sexton merged 3 commits into
mainfrom
feat/cloud-vault-exec
Oct 4, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
feat/cloud-vault-exec

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: part of the key vault split for cross-account page publishing; follows #691 and melodic-software/provisioning#697.

Summary

Cloud sessions can now read Key Vault secrets. A cloud environment on Pro or Max can hold an OAuth 2.0 client credentials API credential for *.vault.azure.net, which Anthropic's agent proxy uses to add the bearer token outside the sandbox. A live probe on 2026-10-04 confirmed that a plain curl from a session reads a secret with no token in the VM. This adds a small cloud vault-exec that the shared setup script installs, using the same argv contract as the workstation resolver, so mcp-launcher and other callers work unchanged in cloud sessions.

Fix

  • New components/cloud-environment/vault-exec: vault-exec [--optional] --env NAME=secret -- cmd.
    • Each secret is one curl GET, and python3 reads the value from a pipe. The command then runs via exec with the variables set.
    • Exit codes: 1 on a failed read without --optional, 2 on bad usage. These match the workstation resolver.
    • No secret value ever appears in a command's arguments, on stdout or stderr, or in a log, and the caller's stdin is never read.
    • The default vault is kv-melo-devtools-prod, the only vault the cloud identity can read; VAULT_EXEC_VAULT overrides it.
  • setup.sh fetches the script from this repository's raw URL, the same way it fetches the plugin catalog and permission floor. It checks the file with bash -n and a marker line, then installs it to ~/.local/bin/vault-exec. A vault-exec already there without the marker is left alone. The step is best-effort, and SCRIPT_VERSION is now 2026-10-04.1.
  • README: new "Key Vault resolver" section. Secrets can't be read at setup-script time, because the proxy attaches credentials only after Claude Code starts.
  • mcp-launcher README: the cloud sentence now covers the installed resolver.
  • CI: the cloud-environment job also runs vault-exec.test.sh.

Verification

  • vault-exec.test.sh: 41 assertions against a stubbed curl. They cover success, a 403 or 404 with and without --optional, the vault override, stdin and exit-code pass-through, the secret staying out of curl's arguments and out of the output, and nine bad-usage cases.
  • setup.test.sh: 84 assertions, including the new install cases (fresh install, replacing our older copy, refusing a copy that isn't ours, refusing a fetched file without the marker).
  • shellcheck and shfmt are clean. Pre-commit (editorconfig, typos, markdownlint, gitleaks, shellcheck) passes.
  • Exit codes checked against the workstation resolver's usage text: 1 for an unresolved secret, 2 for a usage error or no --env.
  • Live: the 2026-10-04 probe read a 32-character dummy secret with HTTP 200 through the proxy credential.

Related

  • docs(azure-naming): split key vaults by isolation class #691: the isolation-class vault rule.
  • melodic-software/provisioning#697: the host-credential vault and the sp-cloudagent-prod rotation runbook.
  • Environments pick this up on their next cache rebuild. A trivial edit to the setup script field forces one.

🤖 Generated with Claude Code

Add a cloud vault-exec with the workstation resolver's argv contract
(vault-exec [--optional] --env NAME=secret-name ... -- <command>). It reads
each secret from kv-melo-devtools-prod (VAULT_EXEC_VAULT overrides) with no
auth header, relying on the environment's OAuth client-credentials API
credential that the agent proxy attaches, then execs the command.

setup.sh fetches it from this component's published path and installs it,
mode 0755, to ~/.local/bin/vault-exec, where the mcp-launcher looks. A
vault-exec without this component's marker line is never replaced. The step
is best-effort and only installs: setup-script requests never get the
credential.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 4, 2026 19:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 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-10-04T19:05:50.019576Z b05e963 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: b05e963715

ℹ️ 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".

Comment thread components/cloud-environment/vault-exec Resolved
Comment thread components/cloud-environment/vault-exec Resolved
kyle-sexton and others added 2 commits October 4, 2026 15:09
…ec under 60 seconds

Retry in bash, one curl call per attempt, so a 500-then-200 sequence no
longer hands json.load concatenated bodies. Only transport errors and
HTTP 408, 429 and 5xx are retried, at most three 10-second attempts per
secret, and all reads share a 45-second budget so Codex's 60-second
startup timeout never fires before the --optional fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@claude

claude Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 2m 33s —— View job


Security review (/review:security-review)

  • Gather context (PR diff, changed files, prior review comments)
  • Check skip gate — security-relevant surface (Key Vault secret resolver), full review performed
  • Review vault-exec for injection / secret-leak / auth bypass issues
  • Review setup.sh changes (fetch/install logic) for supply-chain issues
  • Review instruction-surface changes — none in this diff (no AGENTS.md/CLAUDE.md/rules files touched)
  • Post findings

No security issues found in this diff.

Scope: components/cloud-environment/vault-exec, vault-exec.test.sh, setup.sh, setup.test.sh, the two README.md files, and the pr-require-checks.yml test-list addition.

Notes from the review:

  • Both injection surfaces (--env NAME=secret, VAULT_EXEC_VAULT) are allowlist-regex validated before being embedded in the curl URL (vault-exec#L29-L35, #L52-L53); the secret value never reaches curl's argv, stdout, or an error message — only the secret name and HTTP status are logged.
  • The two findings from Codex's earlier review on this PR are both resolved in the current head (e32e10f):
    • Concatenated retry bodies (P1): the retry loop now issues one curl call per attempt and re-parses resp/status fresh each time (vault-exec#L75-L94), instead of relying on curl --retry. Covered by new tests asserting "only the final response sets the value" and "curl is never asked to retry itself" in vault-exec.test.sh.
    • Unbounded retry time (P2): a shared deadline=$((SECONDS + budget)) (default 45s) now bounds the whole read loop, with each attempt separately capped at ≤10s (vault-exec#L63-L65), keeping the resolver safely under the 60s launcher timeout. Covered by the new budget-exhaustion test case.
  • setup.sh's fetch-and-install step for vault-exec (install_vault_exec) follows the same marker-gated, syntax-checked, atomic-rename pattern already used for the permission floor composer in this file, fetched over pinned HTTPS from the same trusted host as the existing plugin-catalog/permission-floor fetches — no new trust boundary introduced.
  • No secret read is possible during the setup-script phase (the agent proxy only attaches credentials after Claude Code starts), which the README correctly documents, so there's no window where the install step itself could exfiltrate a secret.
  • No GitHub Actions trigger, permission, or pin changes — the workflow diff only adds vault-exec.test.sh to the existing test invocation list.

@claude

claude Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 15s —— View job


Claude is reviewing this PR

  • Gather context (PR body, diff, review comments)
  • Invoke /review:code-review skill
  • Analyze changed files (vault-exec, setup.sh, tests, READMEs, CI workflow)
  • Adversarial verification of candidate findings
  • Post findings as inline comments
  • Post summary comment

Note: I'm unable to run the test suite or shellcheck/shfmt — the sandbox requires approval for script execution that isn't available in this context. Reviewing statically instead.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

claude-security-review has reviewed this pull request through e32e10f; a later push is reviewed from there.

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown

claude-review has reviewed this pull request through e32e10f; a later push is reviewed from there.

@kyle-sexton
kyle-sexton merged commit 52868f2 into main Oct 4, 2026
51 checks passed
@kyle-sexton
kyle-sexton deleted the feat/cloud-vault-exec branch October 4, 2026 19:19
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.

1 participant