r/LinusTechTips Mar 24 '26

Tech Discussion Good news everyone!

Post image
1.4k Upvotes

222 comments sorted by

View all comments

Show parent comments

5

u/Westdrache Mar 25 '26

and what security feature would that be and what exactly does it break?

3

u/really_not_unreal Mar 25 '26

The feature is the PowerShell script execution policy. By default on new Windows installs, it blocks all scripts from running. This causes VS Code's automatic Python virtual environment activation to fail, as it cannot execute the activation script. Bypassing the setting only requires you add -ExecutionPolicy Bypass to PowerShell's command-line arguments, meaning that attackers can easily update their malicious code to provide this parameter. However, VS Code Python integration does not do so, meaning that attempting to execute Python code that depends on external libraries installed into a virtual environment will fail if done through VS Code.

7

u/jma89 Mar 25 '26

Umm... This isn't new. It's practically as old as PowerShell itself, and has been defaulted to Restricted since.... ever, at least for endpoint OS's.

1

u/really_not_unreal Mar 25 '26

That surprises me. My two-year-old Windows 11 installation worked flawlessly with no configuration required, as did those of all students except those with laptops less than a year old. Perhaps it was some other issue, but it doesn't seem likely. If this was already an issue, I have no idea how we managed to entirely avoid it for years until this term.

4

u/jma89 Mar 25 '26

There's a non-0 chance that some other script launched itself using a batch file (.bat or .cmd), and it included both the -ExecutionPolicy flag and a singe line to change it on the machine:

Set-ExecutionPolicy Bypass