Skip to content

fix(cloud-environment): pass curl -q in vault-exec so a planted .curlrc cannot redirect tokens - #717

Merged
kyle-sexton merged 1 commit into
mainfrom
feature/nice-thompson-05u2ui-710
Oct 6, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
feature/nice-thompson-05u2ui-710

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #710

Summary

vault-exec called curl without -q, so a .curlrc under CURL_HOME, XDG_CONFIG_HOME or HOME could add a url, proxy or trace line and send Key Vault responses (or the token the proxy adds) to a second destination. pages-publish already guards against this since #706; this brings vault-exec in line and records pages-publish's trusted inputs.

Fix

  • components/cloud-environment/vault-exec: the Key Vault read in fetch(), its only curl call, now starts with -q (curl honors it only as the first argument), with a comment saying it must stay first.
  • components/cloud-environment/vault-exec.test.sh: asserts -q is curl's first argument, and runs the real curl against a hostile .curlrc (a trace-ascii line, with CURL_HOME/HOME/XDG_CONFIG_HOME pointing at it and the proxy set to a closed local port), asserting the trace file is never written.
  • components/cloud-environment/README.md: the pages-publish section notes the -q guard and adds a "Trusted inputs" paragraph: a caller-set HTTPS_PROXY/CURL_CA_BUNDLE is trusted by design (cloud sessions route through the agent proxy), and the 0600, owner-checked config is trusted (forging it needs write access to the home directory).

Verification

  • With -q temporarily removed, both new assertions fail (expected -q got -sS; planted-trace found). With it, they pass.
  • bash components/cloud-environment/vault-exec.test.sh, pages-publish.test.sh, setup.test.sh: all pass.
  • shellcheck and shfmt -i 2 -ci -d clean; markdownlint-cli2 0 issues; lefthook pre-commit (editorconfig, typos, gitleaks, shellcheck, markdownlint) passed.
  • Not exercised: a live Key Vault read through the agent proxy (offline test only).

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs


Generated by Claude Code

…rc cannot redirect tokens

vault-exec's Key Vault read now starts curl with -q, the same guard
pages-publish gained in #706, so a .curlrc under CURL_HOME,
XDG_CONFIG_HOME or HOME cannot add a url, proxy or trace line. The test
asserts -q is curl's first argument and runs the real curl against a
hostile .curlrc whose trace-ascii line must never write its file.

The README records pages-publish's trusted inputs: a caller-set
HTTPS_PROXY or CURL_CA_BUNDLE (cloud sessions route through the agent
proxy) and the owner-checked 0600 config.

Closes #710

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 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-06T03:05:26.645904Z 0766c84 PR opened
ℹ️ 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.

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 35s —— View job


Security review — vault-exec .curlrc fix

  • Gather context (PR diff, changed files)
  • Review vault-exec curl change
  • Review vault-exec.test.sh changes
  • Review README.md changes
  • Check for instruction-surface deletions (none; no rules/policy files touched)
  • Adversarial self-check of the fix's correctness
  • Post final review

No security issues found. This is a well-scoped, correct hardening fix.

What I checked:

  • vault-exec line 76: -q is the literal first token passed to curl (curl -q -sS --fail-with-body ...), which is the only position curl honors it in — confirmed correct per curl's own requirement that -q/--disable must be the first argument to suppress reading .curlrc from CURL_HOME, XDG_CONFIG_HOME, or HOME.
  • Confirmed this is the only curl invocation in vault-exec (fetch() is its single call site), so there's no second unguarded call left unpatched.
  • Checked sibling files in the same component for parity: pages-publish already carries the same -q-first guard (from feat(cloud-environment): add pages-publish and install it in cloud setup #706); the unrelated curl calls in setup.sh (installing packages, fetching dotnet-install.sh, bootstrapping scripts) carry no secrets through them and are untouched by this PR, so they're out of scope here.
  • vault-exec.test.sh lines 66–83: the new test is a real exploit simulation, not just an argv check — it runs the actual curl binary (symlinked into realbin, ahead of the stub on PATH) against a planted .curlrc with a trace-ascii line under CURL_HOME/HOME/XDG_CONFIG_HOME, with HTTPS_PROXY pointed at a closed local port so the test stays fully offline. It asserts the trace file is never created, which is the correct falsifiable check (removing -q would make this fail, as the PR description confirms was verified).
  • README.md: the new "Trusted inputs" paragraph accurately matches existing code — the 0600/owner check it references is pages-publish's existing config-loading behavior, and trusting a caller-set HTTPS_PROXY/CURL_CA_BUNDLE is consistent with -q only suppressing config-file reads, not environment variables (which was never the exploit vector here).
  • No rules, policy, or instruction files (CLAUDE.md, AGENTS.md, hook allow/deny lists) are touched by this diff, so the instruction-surface-deletion lens doesn't apply.

No CRITICAL / IMPORTANT / SUGGESTION findings to report.

@claude

claude Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

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


Claude's review

  • Gather context (PR diff, changed files, CLAUDE.md/REVIEW.md)
  • Review vault-exec fix
  • Review vault-exec.test.sh changes
  • Review README.md changes
  • Post findings

No high-signal correctness findings. This is a tightly scoped fix and the change holds up under review:

  • vault-exec puts -q as curl's literal first argument, which is the only position where curl honors it — correct per curl's own parsing rule (it only special-cases -q/--disable as argv[1]).
  • The new test block in vault-exec.test.sh is a good regression guard: it runs the real curl (via a symlink that bypasses the stub on PATH) against a planted hostile .curlrc with trace-ascii, points CURL_HOME/HOME/XDG_CONFIG_HOME all at it, routes through a closed local proxy port (hermetic — no real network dependency), and asserts the trace file is never created. That's a real exercise of the fix, not just an argv-order check. The argv-order assertion (line 66-67) and the behavioral assertion complement each other well.
  • The retry loop in vault-exec (lines 91-103) correctly continues retrying on a non-22, non-zero curl_rc (e.g. connection-refused from the test's dead proxy), so the hostile-.curlrc test exercises the same code path a real transient failure would.
  • README.md's new "Trusted inputs" paragraph and the -q mention are consistent with the actual code in both vault-exec and pages-publish (which already carries the identical -q-must-stay-first guard from feat(cloud-environment): add pages-publish and install it in cloud setup #706).
  • Scope check: vault-exec's fetch() is the only curl call in the file, matching the PR's claim that it's the only call needing the guard.

Not independently verified (author-claimed only): I was unable to execute shell commands (bash components/cloud-environment/vault-exec.test.sh, shellcheck, shfmt) in this review environment — those invocations required approval that isn't available in this unattended run. The PR body's test/lint results are the author's own claims, not something I confirmed myself. Static reading of the diff and the test harness (harness/shell/lib.sh) supports that the new assertions (assert_eq, assert_exit, assert_file_absent) are used correctly and would behave as described.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

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

@kyle-sexton
kyle-sexton merged commit 5fdceb2 into main Oct 6, 2026
22 checks passed
@kyle-sexton
kyle-sexton deleted the feature/nice-thompson-05u2ui-710 branch October 6, 2026 03:07
kyle-sexton added a commit that referenced this pull request Oct 6, 2026
…publish (#723)

Closes #707

## Summary

The pages Worker (melodic-software/provisioning#705) scans a normalized
copy of every upload, but `pages-publish` scanned only the raw bytes.
Its early check therefore missed HTML-escaped, tag-split and
JSON-escaped credential, path and hostname shapes. The client now scans
decoded copies too, so it refuses an upload, or forces it private,
before sending. The Worker remains the enforcing layer.

## Fix

- `components/cloud-environment/pages-publish` builds two decoded copies
in linear POSIX-awk passes, with no new dependency:
- **Host copy**: exactly the Worker's `normalize()`. Tags are stripped.
`&#NN;`, `&#xHH;`, amp, lt, gt, quot, apos and nbsp are decoded only
when the `;` is present. `\\` becomes `\`. A credential found here exits
4, the same page the Worker would refuse with a 422.
- **Wide copy**: adds the extra named entities, numeric entities without
their `;`, and JS escapes (`\/`, `\"`, `\uXXXX`, `\u{…}`, `\xHH`). A
credential found only here forces the page private instead of refusing
it.
- An invalid decoded code point (NUL, above U+10FFFF, or overlong)
becomes U+FFFD, so it never joins two fragments into a token shape.
- Machine-path and hostname shapes only ever force private, on the raw
copy and both decoded copies. gitleaks, when present, runs on the raw
page.
- Path shapes are reconciled with
`components/path-detection/machine-path-patterns.sh`:
- `setup.sh` installs the script as a single file, so the five `HPP_*`
bodies are copied in word for word, and a test fails if the copy and the
library differ.
- On decoded copies they add home paths with no trailing slash, the
forward-slash and 8.3 Windows forms, and Windows checkout roots.
- The cloud-environment README documents the decoded scan and a
**Rollout of the decoded scan** paragraph (lifecycle exception for a
check that blocks from day one, with the Worker evidence below). The
path-detection README names the embedded copy.

## Verification

- `bash components/cloud-environment/pages-publish.test.sh`: 233
assertions pass.
- The escaped-form, HPP-only-shape, invalid-code-point and sync tests
all fail against the old script.
  - Tests pin which escaped forms are refused and which go private.
  - An escaped placeholder and stray entities stay public.
  - A 2 MiB single line of each separator scans in under 20 s.
- The Worker's own `scan()` (provisioning main `0809074`) was run over
the samples.
- It flags the entity, hex-entity and tag-split token forms. The client
refuses those.
- It flags nothing for the `_`, `\"`, `&lowbar;` and `&#95`-without-`;`
forms. The client forces those private.
- `machine-path-patterns.test.sh` and `setup.test.sh` pass. shellcheck,
`shfmt -i 2 -ci -d` and markdownlint-cli2 are clean. The ci-workflows
`check-machine-specific-paths.sh` driver reports nothing.
- Follow-ups left out of scope:
- the Worker's "fleet hostname" and `CLOUDFLARE|CF_API_TOKEN` shapes,
which the client lacks;
  - a pre-existing `pgup_` length mismatch (client 16+, Worker 20+).

## Related

- melodic-software/provisioning#705 (the Worker's normalized scan,
`cloudflare/pages-worker/src/scan.js`)
- `components/path-detection/machine-path-patterns.sh`
- #717 (vault-exec `-q`, same component)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

vault-exec: pass curl -q so a planted .curlrc cannot redirect Key Vault tokens

1 participant