Skip to content

fix: Add provenance-aware untrusted stdin mode - #137

Merged
jbeckwith-oai merged 5 commits into
mainfrom
codex/untrusted-stdin-provenance
Aug 25, 2026
Merged

fix: Add provenance-aware untrusted stdin mode#137
jbeckwith-oai merged 5 commits into
mainfrom
codex/untrusted-stdin-provenance

Conversation

@jbeckwith-oai

Copy link
Copy Markdown
Contributor

Summary

  • Add opt-in OPENAI_UNTRUSTED_STDIN=1 handling for JSON/YAML request documents without changing trusted-input defaults.
  • Preserve stdin-versus-CLI provenance across aliases, nested maps and arrays, inner flags, headers, query parameters, and multipart uploads.
  • Treat stdin-origin @, @file://, and @data:// strings literally and reject stdin-origin FileInput paths before sending a request, while preserving explicitly supplied file flags.
  • Document the mode and add end-to-end HTTP regressions, provenance unit tests, mixed-origin compatibility coverage, and Windows-safe test helpers.

Motivation

Pipelines that consume untrusted request documents need a way to prevent stdin-provided values from being reinterpreted as local file references. The new behavior is explicitly enabled for compatibility; existing trusted heredocs and explicit CLI uploads keep their current behavior.

Verification

GOFLAGS=-buildvcs=false go test ./internal/requestflag ./pkg/cmd -run 'Stdin|ApplyStdinDataToFlags' -count=1
GOFLAGS=-buildvcs=false go test -race ./internal/requestflag ./pkg/cmd -run 'Stdin|ApplyStdinDataToFlags' -count=1
GOFLAGS=-buildvcs=false go test ./... -run '^$'
GOFLAGS=-buildvcs=false ./scripts/lint
GOFLAGS=-buildvcs=false go vet ./...

The full integration suite, Windows amd64 test compilation, module verification, vulnerability-check harness, and GoReleaser installer test also passed during final private review. No Castiron-generated source, generator-owned template, workflow, or custom-code budget was changed.

Copilot AI lite review requested due to automatic review settings August 24, 2026 23:00
@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner August 24, 2026 23:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 24, 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-08-24T23:29:38.694202Z 834d5c3 New commits
🔒 Security Review Completed 2026-08-24T23:30:07.058862Z 834d5c3 New commits
ℹ️ 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.

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Castiron custom code

✅ No new custom-code files detected.

5 mixed files remain; 0 existing customizations changed.

Compared 1f3ba6cc8e8f834d5c3ddd97. Generated baselines verified.

5 existing customizations unchanged
  • pkg/cmd/adminorganizationcertificate.go
  • pkg/cmd/cmd.go
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 32789434458 --repo openai/openai-cli \
  --name castiron-custom-code-32789434458-1 --dir /tmp/castiron-custom-code-32789434458-1
git apply --stat /tmp/castiron-custom-code-32789434458-1/custom-code.patch
cat /tmp/castiron-custom-code-32789434458-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 1f3ba6cc8e8f9ac31744b35093e7a6be4acf2dd0 834d5c3ddd97e2cb7137c803470356be2d6d7fca
python3 scripts/castiron/custom_code_report.py report \
  --base 1f3ba6cc8e8f9ac31744b35093e7a6be4acf2dd0 \
  --head 834d5c3ddd97e2cb7137c803470356be2d6d7fca --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-834d5c3ddd97
cat /tmp/castiron-custom-code-834d5c3ddd97/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@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: 93857fcab1

ℹ️ 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 pkg/cmd/stdinsecurity.go Outdated

Copilot AI 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.

Pull request overview

Adds an opt-in “untrusted stdin” mode to prevent stdin-provided JSON/YAML values from being reinterpreted as local file references, while preserving existing trusted-input behavior by default.

Changes:

  • Introduces OPENAI_UNTRUSTED_STDIN and provenance tracking so stdin-origin values are treated as literal data at the file-expansion boundary.
  • Rejects stdin-origin FileInput paths early (before any file can be opened) while keeping explicit CLI file flags working as before.
  • Adds documentation plus unit and end-to-end regression tests covering mixed-origin behavior and Windows-friendly helpers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents OPENAI_UNTRUSTED_STDIN and how behavior changes when enabled.
pkg/cmd/stdinsecurity.go Implements stdin provenance marking and literalization at the embed boundary.
pkg/cmd/stdinsecurity_test.go Adds unit + end-to-end coverage for untrusted stdin behavior and regression cases.
pkg/cmd/flagoptions.go Wires provenance-aware stdin application into request assembly and file embedding.
internal/requestflag/stdinprovenance.go Adds provenance callback support when applying stdin data to flags.
internal/requestflag/stdinprovenance_test.go Tests provenance reporting behavior for stdin-set flags.
internal/requestflag/requestflag.go Refactors stdin-to-flags logic to support provenance and explicit-inner preservation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/requestflag/stdinprovenance.go Outdated
@jbeckwith-oai jbeckwith-oai changed the title Add provenance-aware untrusted stdin mode fix: Add provenance-aware untrusted stdin mode Aug 24, 2026
Copilot AI review requested due to automatic review settings August 24, 2026 23:09

@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: 8bec3e463d

ℹ️ 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 pkg/cmd/stdinsecurity.go

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

pkg/cmd/flagoptions.go:436

  • The FileInput comment block is now an incomplete sentence ("the value is always"), which makes the documentation confusing at this call site. Consider rewriting it as a single coherent explanation of trusted vs untrusted-stdin behavior.
	// For flags marked as FileInput (type: string, format: binary), the value is always
	// A FileInput value is a file path, so wrap trusted values with FilePathValue
	// for automatic expansion. In untrusted-stdin mode, reject piped file paths.
	if err := wrapFileInputValues(cmd, &requestContents); err != nil {

Copilot AI review requested due to automatic review settings August 24, 2026 23:18

@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: 2a6a485c91

ℹ️ 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 internal/requestflag/stdinprovenance.go Outdated

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 24, 2026 23:27
@jbeckwith-oai
jbeckwith-oai force-pushed the codex/untrusted-stdin-provenance branch from 2a6a485 to 834d5c3 Compare August 24, 2026 23:27

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@apcha-oai apcha-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[sdk codex review] Approved after two independent full reviews of all seven changed files at 834d5c3ddd97e2cb7137c803470356be2d6d7fca, including supporting request/multipart paths and all existing feedback. The four previously reported upload-provenance and explicit-value-precedence issues are substantively fixed; no remaining actionable blocker or duplicate inline finding was identified.

Reviewed correctness, security implications, compatibility, tests and maintainability, including opt-in behavior, aliases, mixed-origin nested fields, explicit uploads, and empty/null/numeric stdin values. Existing hosted test and lint logs verify merge 131aff0fcfb3e8e6e94f6d67bd2075d7e2e9f4db of this exact head into current base 1f3ba6cc8e8f9ac31744b35093e7a6be4acf2dd0, using Go 1.25.14 on Linux; the full repository suite passed. Windows coverage here is compilation, not native test execution. Current check runs and budget statuses are successful apart from the expected queue-signal skip. No local code, tests or scans were executed for this review.

Final checks confirmed the unchanged head/base, Justin’s authorship, and open, non-draft, mergeable status. This is an automated code review under the explicit robot-review permission in Slack, not an assertion that any separate human/CODEOWNER approval requirement has been satisfied.

@jbeckwith-oai
jbeckwith-oai added this pull request to the merge queue Aug 25, 2026
Merged via the queue into main with commit a133707 Aug 25, 2026
15 checks passed
@jbeckwith-oai
jbeckwith-oai deleted the codex/untrusted-stdin-provenance branch August 25, 2026 00:51
@openai-sdks openai-sdks Bot mentioned this pull request Aug 25, 2026
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.

3 participants