Repository navigation
Trust only nonce-verified terminal cwd for command approval - #335978
Anthony Kim (anthonykim1) wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Backend CWD lookup failures can still authorize against the stale initial directory, and the new security-sensitive paths lack effective regression coverage.
Get a fresh assessment by requesting another Copilot review.
Review tier: Balanced
Findings: 1
Open findings (3)
What changed in this PR
Authenticates terminal CWD reporting and prevents untrusted paths from influencing command authorization.
Changes:
- Adds nonce authentication to shell CWD sequences.
- Resolves untrusted CWD through the terminal backend.
- Prevents workspace fallback for existing terminals with unknown CWD.
| File | Description |
|---|---|
shellIntegrationAddon.ts |
Requires a non-empty matching nonce. |
terminalInstance.ts |
Selects trusted or backend-reported CWD. |
runInTerminalTool.ts |
Avoids unsafe workspace fallback. |
shellIntegration.ps1 |
Adds nonce to PowerShell CWD updates. |
shellIntegration.fish |
Persists and sends the Fish nonce. |
shellIntegration-rc.zsh |
Adds nonce to Zsh CWD updates. |
shellIntegration-bash.sh |
Adds nonce to Bash CWD updates. |
shellIntegrationAddon.test.ts |
Tests nonce trust classification. |
terminalInstance.test.ts |
Adds trusted-CWD scenarios. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Screenshot ChangesBase: Changed (1)3 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. blocks-ci screenshots changedReplace the contents of Updated blocks-ci-screenshots.md<!-- auto-generated by CI — do not edit manually -->
#### agentSessionsViewer/SessionWithPeerChat/Light

#### baseUI/KeyboardFocusedToggle/Light

#### chat/chatPetAccessoryRig/chatPetAccessoryRig/AllAccessoriesFacing/Light

#### chat/chatPetAccessoryRig/chatPetAccessoryRig/AllRuntimeStates/Light

#### chat/chatPetAccessoryRig/chatPetAccessoryRig/CoveredAntennaeComparison/Light

#### chat/chatPetAccessoryRig/chatPetAccessoryRig/CriticalPoses/Light

#### chat/chatPetAccessoryRig/chatPetAccessoryRig/LiveEyeLayering/Light

#### chat/chatQuestionCarousel/MarkdownLinks/Light

#### chat/input/chatInput/CompactWithProviderIcon/Light

#### chat/input/chatInput/CopilotHarnessCompactPickers/Light

#### chat/petAchievements/standaloneModal/chatPetAchievementsEditor/MixedSelected/Light

#### comments/commentTree/CommentTreeMetadataZoomed/Light

#### editor/codeEditor/CodeEditor/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthClassification/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthCode/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthFont/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthProportionalFont/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthSelection/Light

#### editor/fullwidthCharacterWidth/FullwidthCharacterWidthTwoCells/Light

#### editor/injectedTextDecorations/ColorDecorators/Light

#### editor/injectedTextDecorations/InlayHints/Light

#### editor/injectedTextDecorations/InlineProgress/Light

#### editor/injectedTextDecorations/SelectedColorDecorator/Light

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Light

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Light

#### editor/wordWrapIndicator/WordWrapIndicator/Light

#### editor/wordWrapIndicator/WordWrapIndicatorDisabled/Light

#### editor/wordWrapIndicator/WordWrapIndicatorFixedColumnBeyondViewport/Light

#### editor/wordWrapIndicator/WordWrapIndicatorVariableLineHeight/Light

#### editor/wordWrapIndicator/WordWrapIndicatorViewportWrapping/Light

#### sessions/accountMenu/petAchievementBadges/chatPetAchievementBadges/AllBadges/Light

#### sessions/chat/newWidget/newChatWidget/MigrationsBackground/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionAttachedContext/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionAutoModel/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionChatBackground/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionCompactAutoModel/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionExperimentalComposerBackground/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionGitHubContextPicker/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionPhoneAttachedContext/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionRemoteWorkspace/Light

#### sessions/chat/newWidget/newChatWidget/NewSessionWorkspacePicker/Light

#### sessions/chat/view/chatView/AssistantResponseBackground/Light

#### sessions/chat/view/chatView/AssistantResponsePlain/Light

#### sessions/chat/view/chatView/CheckpointControlsBackground/Light

#### sessions/chat/view/chatView/RequestAttachmentBackground/Light

#### sessions/sessionsList/SessionsList_ArchivedNestedChat/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge_Accent/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge_Narrow/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge_Running/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge_Soft/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge_Unread/Light

#### sessions/sessionsList/SessionsList_AutomationsNewBadge/Light

#### sessions/sessionsList/SessionsList_CompactArchivedNestedChat/Light

#### sessions/sessionsList/SessionsList_CompactChatRename/Light

#### sessions/sessionsList/SessionsList_CompactNeedsInput/Light

#### sessions/sessionsList/SessionsList_CompactNestedChatActions/Light

#### sessions/sessionsList/SessionsList_CompactNestedChatApprovals/Light

#### sessions/sessionsList/SessionsList_CompactNestedChatPrimaryAction/Light

#### sessions/sessionsList/SessionsList_CompactNestedChats/Light

#### sessions/sessionsList/SessionsList_CompactSessionRename/Light

#### sessions/sessionsList/SessionsList_CompactUnreadStatusIcons/Light

#### sessions/sessionsList/SessionsList_LightweightNewButton/Light

#### sessions/sessionsList/SessionsList_LightweightNewButtonWithKeybindingBackground/Light

#### sessions/sessionsList/SessionsList_NarrowHoverToolbar/Light

#### sessions/sessionsList/SessionsList_NestedChatHierarchyGuides/Light

#### sessions/sessionsList/SessionsList_PeerChatInProgress/Light

#### sessions/sessionsList/SessionsList_SelectedKeyboardFocus/Light

#### sessions/sessionsList/SessionsList_UnreadStatusIcons/Light

#### workbench/activityBarMenu/CompactActivityBarMenu_CompactDensity/Light

#### workbench/activityBarMenu/CompactActivityBarMenu_DefaultDensity/Light

#### workbench/statusBar/statusBar/CompactDensity/Light

#### workbench/statusBar/statusBar/DefaultDensity/Light
Patch--- test/componentFixtures/blocks-ci-screenshots.md 2026-10-01 04:02:35.130422158 +0000
+++ /tmp/blocks-ci-updated.md 2026-10-01 04:09:30.239181330 +0000
@@ -172,7 +172,7 @@

#### sessions/sessionsList/SessionsList_CompactNestedChatPrimaryAction/Light
-
+
#### sessions/sessionsList/SessionsList_CompactNestedChats/Light
 |
Co-authored-by: Copilot <[email protected]> Copilot-Session: cca5e5b9-d046-4b57-b3af-78d6efa639cb
Addresses review thread comments 3997723189 and 3997723220. Return unknown when authorization CWD lookup fails and exercise the production method in tests.
Addresses review thread comment 3997723253. Keep command analysis from substituting the session workspace for an associated terminal with unknown CWD.
6b3df72 to
0b56cf9
Compare
Keep Agent Host terminal CWD state compatible with nonce-bearing OSC 633 properties and ignore mismatched nonces. Co-authored-by: Copilot <[email protected]> Copilot-Session: cca5e5b9-d046-4b57-b3af-78d6efa639cb
Remove shell-integration nonce and Agent Host protocol changes while retaining authoritative CWD resolution for terminal auto-approval. Co-authored-by: Copilot <[email protected]> Copilot-Session: cca5e5b9-d046-4b57-b3af-78d6efa639cb
Copilot-Session: cca5e5b9-d046-4b57-b3af-78d6efa639cb
Replace the mock-only changes with one test of the real getCwdResourceForAuthorization and getCwdResource behavior.
Send the shell integration nonce with the cwd from the bash, zsh, fish, and PowerShell scripts, drop that nonce in the Agent Host parser, and treat an untrusted cwd as unknown when preparing terminal commands. Revert the process cwd lookup, which is no longer needed.
|
Replaced by #350618, which has the same change rebased onto current Authored with Copilot on behalf of anthonykim1 |


OSC 633 ; P ; Cwdfrom the bash, zsh, fish, and PowerShell scripts, so the cwd they report is trusted. The parser already accepts this optional nonce and marks a cwd without it as untrusted.E.Testing:
npm run transpile-client(passed)./scripts/test.sh --run src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts --run src/vs/workbench/contrib/terminal/test/browser/xterm/shellIntegrationAddon.test.ts(289 passing, 108 pending); the new test fails without the changenpm run test-node -- --run src/vs/platform/agentHost/test/node/osc633Parser.test.ts --run src/vs/platform/agentHost/test/node/agentHostTerminalManager.test.ts(57 passing); the updated parser test fails without the changebash -n,zsh -n, andfish -non the changed scripts (passed); the bash and fish forms emitESC ] 633 ; P ; Cwd=/x ; <nonce> BELnpm run eslint -- <4 changed TypeScript files>(passed)npm run typecheck-client(no errors in changed files; the remaining errors are in Agent Host Copilot and local transcription files and come from locally linked packages that differ from the versions pinned onmain)Inspirations from:
CwdinShellIntegrationAddon.EnvJsonin the same prompt.Enonce handling.RunInTerminalTool.prepareToolInvocation.