Skip to content

fix: validate private state before access - #481

Open
mldangelo-oai wants to merge 6 commits into
mainfrom
agent/explain-unsafe-output-ancestors
Open

fix: validate private state before access#481
mldangelo-oai wants to merge 6 commits into
mainfrom
agent/explain-unsafe-output-ancestors

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make unsafe output-parent errors actionable and validate configured state paths before state-backed operations access data.

The existing ancestry restriction is intentional: a private child can still be renamed or replaced through a writable, non-sticky parent. This change keeps that protection in place.

Changes

  • Include the offending parent's octal permission mode and safe recovery guidance in the existing error.
  • Require an existing state root to be private to the current user, while retaining the sticky-bit exception for trusted parent directories.
  • Check lexical symlink paths and their targets before selecting state, including the direct workbench entry point. Preserve trusted aliases and non-mutating validation of missing paths.
  • Apply state validation to history, authentication, and publication entry points. Keep the validated canonical state location for each operation.
  • Create missing state directories one component at a time with private permissions, including under restrictive umasks, and check the workbench's canonical directory before opening SQLite. Preserve ownership-specific recovery guidance.
  • Add synthetic regression tests for state privacy, path aliases, early rejection, and local CLI error handling. Simplify the CLI test to inject its typed error directly.
  • Document the separate output, persistent-state, and temporary-directory settings.
  • Update both bundled-plugin version markers to 0.1.24 so existing cached installations refresh the workbench.

This complements the overlap checks in #418. The structured-error work in #463 addresses a separate concern.

Testing

Current metadata-only follow-up df0ad83f:

  • Exact two-file/version-only diff, JSON/version agreement, targeted Prettier, and git diff --check: passed.
  • Independent source review and two fresh native source-only reviews with independent verification: no findings.
  • No application or runtime tests were rerun for this metadata-only follow-up.

Historical published head 5254d5fc:

  • Focused shared-state, publication, direct-workbench, history-preflight, and compact-MCP regressions passed.
  • bun test --randomize --seed 12345: 1,323 passed, 11 skipped, 0 failed.
  • pnpm run test: 1,323 passed, 11 skipped, 0 failed.
  • pnpm run types, pnpm run format, Ruff lint on the changed Python script, and git diff --check: passed.

An unchanged login-cleanup test timed out in an earlier full run. It passed in isolated checks on the earlier revisions and in both final full runs. No authentication cleanup code was changed.

Risk and rollout

Existing state roots with group or other permissions, including older 0755 directories, now fail state-backed operations. Use a dedicated private state directory, or correct its permissions only when it is yours and safe to change. New workbench state is created privately. The existing global output-ancestry rules are unchanged, and POSIX ownership and mode checks remain platform-gated. The new validation does not change existing state or parent permissions, silently relocate explicit paths, or migrate history or credentials. No dependency or npm-package release change is included. The metadata-only follow-up changes no application behavior. Current main b4fe2d87 still needs an additive conflict-resolution merge and validation before this PR can merge; keep both bundled-plugin versions synchronized with the final integration order.

Public disclosure review

Newly authored material was reviewed for public disclosure. Existing automated review comments contain access-restricted report references; maintainer cleanup remains outstanding.

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review commit 8f4c05113d6b4dc7e7a3b4df642c899d3fe3da0f.

@github-actions github-actions Bot added the bug Something isn't working label Aug 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 8f4c05113d

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8f4c05113d

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review August 16, 2026 07:02

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

ℹ️ 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 sdk/typescript/src/api.ts Outdated
Comment thread sdk/typescript/src/api.ts Outdated
@mldangelo-oai mldangelo-oai changed the title fix(runtime): explain unsafe output ancestors fix: validate private state before access Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head: 5254d5f.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5254d5fcf0

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 5254d5fcf0

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@zcrab-oai zcrab-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.

Found a deployment gap that prevents the new workbench security checks from reaching existing plugin installations.

requested = requested_state_dir()
root = Path(requested)
try:
require_secure_state_ancestry(requested)

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.

[P1] Refresh installed plugins when shipping this workbench security fix

Could we bump both bundled-plugin version declarations, or explicitly land this before a coordinated plugin-version bump? bootstrapPlugin reuses an already staged marketplace when the version is unchanged, and the installed MCP server loads workbench_db.py from its own installed root. Existing 0.1.20 installations therefore keep running the previous workbench without this new private-state and ancestry validation after an SDK upgrade.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head df0ad83fb167c739936ed27be8a4cffefa76a933. The latest commit only synchronizes the two bundled-plugin version markers. Please review critically for correctness and unnecessary complexity.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: df0ad83fb1

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: df0ad83fb1

ℹ️ 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 sdk/typescript/src/api.ts
Comment on lines +1796 to +1798
await validateCodexSecurityStateDirectory(stateDirectory, (canonical) =>
requireOutputOutsideRepository(protectedRoot, canonical),
);

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 Retain the canonical state path after validation

When CODEX_SECURITY_STATE_DIR traverses a repository-controlled symlink, this call validates the resolved destination but discards the returned canonical path; #localScanInputs subsequently returns the original alias, which is passed to scanRuntimeCodexConfig as a writable filesystem root and exported to the workbench. The repository can retarget that alias after preflight, causing later workbench operations to resolve and write a different state location. Fresh evidence despite the earlier addressed comment is that the current head still propagates the original stateDirectory at lines 1805, 549, 823, and 986. Store and propagate the canonical value returned here instead.

AGENTS.md reference: sdk/typescript/AGENTS.md:L19-L20

Useful? React with 👍 / 👎.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants