Skip to content

agentHost: use workspace-scoped Codex permission profiles - #334945

Draft
Giuseppe Cianci (Giuspepe) wants to merge 8 commits into
mainfrom
agents/debug-vscode-issue-334925-fix
Draft

agentHost: use workspace-scoped Codex permission profiles#334945
Giuseppe Cianci (Giuspepe) wants to merge 8 commits into
mainfrom
agents/debug-vscode-issue-334925-fix

Conversation

@Giuspepe

@Giuspepe Giuseppe Cianci (Giuspepe) commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • define VS Code-owned Codex permission profiles for Default and Auto-Review and apply them across thread starts, turns, forks, resumes, backing chats, multi-root workspaces, additional directories, and Agent Merge
  • on macOS and Linux, deny arbitrary filesystem reads outside the active workspace roots while retaining Codex's required :minimal system/runtime reads and isolated temporary-directory access
  • preserve Full Access as unrestricted, and keep additional writable directories separate from persisted workspace roots so clearing them revokes access
  • describe Default and Auto-Review as platform-sandboxed rather than promising literal workspace-only reads

Related to #334925

Platform behavior

  • macOS/Linux: Default and Auto-Review deny an ordinary user file outside the workspace; files included in Codex's :minimal runtime set can remain readable
  • Windows: Codex's unelevated sandbox cannot enforce workspace-scoped read restrictions, so this change retains its supported fallback profile; elevated sandbox provisioning should be integrated separately before making the same guarantee there

Validation

  • npm run compile
  • npm run hygiene
  • focused Codex launch/config tests: 14 passing
  • git diff --check
  • live Code OSS verification of all three picker modes:
    • Default: synthetic user file outside the workspace is denied
    • Auto-Review: the same outside file is denied
    • Full Access: the same outside file is readable
    • /etc/passwd remains readable in sandboxed modes because Codex includes required system/runtime paths in :minimal

Copilot AI balanced review requested due to automatic review settings September 7, 2026 16:12
@Giuspepe
Giuseppe Cianci (Giuspepe) marked this pull request as ready for review September 7, 2026 16:13

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

Copilot review overview

🟡 Changes recommended

Workspace-root handling can retain or persist additional-directory access after it should be revoked.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity

New issues introduced by this change (1)
Severity Finding
High severity src/​vs/​platform/​agentHost/​node/​codex/​codexAgent.ts — Mixing additional writable directories into runtimeWorkspaceRoots also makes them…
What changed in this PR

Restricts Codex’s default filesystem permissions to workspace-scoped profiles while preserving existing permission presets.

Changes:

  • Defines VS Code-owned Codex permission profiles.
  • Applies profiles across starts, turns, forks, and resumes.
  • Expands focused permission and workspace-root tests.
File Description
codexSessionConfigKeys.test.ts Tests updated preset descriptions.
codexPrewarmEviction.test.ts Tests profile propagation and workspace roots.
codexLaunchConfig.test.ts Tests profile definitions and resume overrides.
codexLaunchConfig.ts Defines and selects permission profiles.
codexAgent.ts Applies profiles throughout session lifecycles.
Suppressed comments (1)

src/vs/platform/agentHost/node/codex/codexAgent.ts:1764

  • runtimeWorkspaceRoots is sticky on turn/start (the protocol says this field replaces the roots only when supplied). For a single-root thread started in workspace-write mode with an additional directory, switching to read-only returns undefined here, so Codex retains the additional directory in :workspace_roots; the read-only profile can then still read outside the workspace. Always send the actual workspace roots when selecting read-only so prior additional roots are removed.
			: workingDirectories.length > 1 ? distinctAbsolutePaths(workingDirectories) : [];

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

Comment thread src/vs/platform/agentHost/node/codex/codexAgent.ts Outdated
@Giuspepe
Giuseppe Cianci (Giuspepe) marked this pull request as draft September 8, 2026 08:32
auto-merge was automatically disabled September 8, 2026 08:32

Pull request was converted to draft

@Giuspepe
Giuseppe Cianci (Giuspepe) force-pushed the agents/debug-vscode-issue-334925-fix branch 2 times, most recently from cb07c3d to 740b893 Compare September 8, 2026 10:10
Use named Codex permission profiles for default and auto-review sessions while preserving the existing full-access behavior. Apply the selected profile across thread start, turns, forks, resumes, and backing chats.
Keep app-server runtime roots from promoting additional writable directories into persisted workspace state. Send explicit roots for read-only sessions, use portable protected-path overrides, and keep generic Codex E2E fixtures on full access.
@Giuspepe
Giuseppe Cianci (Giuspepe) force-pushed the agents/debug-vscode-issue-334925-fix branch from 740b893 to 4dd4e9e Compare September 8, 2026 11:08
@Giuspepe
Giuseppe Cianci (Giuspepe) marked this pull request as ready for review September 8, 2026 12:58
@Giuspepe
Giuseppe Cianci (Giuspepe) marked this pull request as draft September 8, 2026 12:59
@Giuspepe Giuseppe Cianci (Giuspepe) changed the title agentHost: Restrict Codex default permissions to workspace agentHost: use workspace-scoped Codex permission profiles Sep 8, 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