-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Undocumented risky behaviour in subprocess module #101283
Copy link
Copy link
Closed
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowsrelease-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue
Metadata
Metadata
Assignees
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.7 (EOL)end of lifeend of life3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifeOS-windowsrelease-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-securityA security issueA security issue
Projects
Status
Done
Bug report - Undocumented risky behaviour in subprocess module
When using
subprocess.Popenwithshell=Trueon Windows and without aCOMSPECenvironment variable, acmd.exeis launched. The problem is thecmd.exefull path is not written, Windows will search the executable in the current directory and in the PATH. If an arbitrary executable file is written to the current directory or to a directory in the PATH, it can be run instead of the real cmd.exe.See the code here and a POC here.
cmd.exestring byC:\WINDOWS\system32\cmd.exe.Linked PRs
versionchangedof gh-101283 (3.12 only) #101728