Skip to content

shellIntegration.ps1 Leaks Variables To Global Scope #250000

@mattcargile

Description

@mattcargile

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version:
1.100.2
848b80aeb52026648a8ff9f7c45a9b0a80641e2e
x64
  • OS Version: Microsoft Windows 11 Enterprise

Steps to Reproduce:

  1. Use Shell Integration
  2. Run Get-Variable
  3. See below variables. ( NOTE: I see some with underscores which may be necessary unfortunately. The other more generic ones could prove problematic if someone uses the same name )
$var = @(
                <# VSCode Shell Integration #>
		'__vscode_shell_env_reporting'
                '__LastHistoryId'
                '__psEditorServices_userInput'
                '__VSCodeOriginalPrompt'
                '__VSCodeOriginalPSConsoleHostReadLine'
                'isStable'
                'isWindows10'
                'Nonce'
                'osVersion'
                '__VSCodeIsInExecution'
                'ContinuationPrompt'
                'envVarsToReport'
)

Additionally, lines like the below suggest a script scope but the script is dot-sourced in to the global scope making $global: prefixes unecessary.

# Store the nonce in script scope and unset the global

Below is the execution from procexp.exe.

"C:\Program Files\PowerShell\7\pwsh.exe" -noexit -command "try { . \"c:\Users\MyUserName\scoop\apps\vscode\1.100.2\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1\" } catch {}"

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugterminal-shell-pwshAn issue in the terminal specific to PowerShell, including shell integrationverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions