8000 [security][3.3] bpo-30730: Prevent environment variables injection in subprocess on Windows. (GH-2325) by serhiy-storchaka · Pull Request #2363 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[security][3.3] bpo-30730: Prevent environment variables injection in subprocess on Windows. (GH-2325) #2363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 19, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests.
  • Loading branch information
serhiy-storchaka committed Jul 12, 2017
commit 5e22721e586344b547194f0f7ea67fd425f94e72
8 changes: 4 additions & 4 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,24 +591,24 @@ def test_empty_env(self):
def test_invalid_cmd(self):
# null character in the command name
cmd = sys.executable + '\0'
with self.assertRaises(ValueError):
with self.assertRaises((ValueError, TypeError)):
subprocess.Popen([cmd, "-c", "pass"])

# null character in the command argument
with self.assertRaises(ValueError):
with self.assertRaises((ValueError, TypeError)):
subprocess.Popen([sys.executable, "-c", "pass#\0"])

def test_invalid_env(self):
# null character in the enviroment variable name
newenv = os.environ.copy()
newenv["FRUIT\0VEGETABLE"] = "cabbage"
with self.assertRaises(ValueError):
with self.assertRaises((ValueError, TypeError)):
subprocess.Popen([sys.executable, "-c", "pass"], env=newenv)

# null character in the enviroment variable value
newenv = os.environ.copy()
newenv["FRUIT"] = "orange\0VEGETABLE=cabbage"
with self.assertRaises(ValueError):
with self.assertRaises((ValueError, TypeError)):
subprocess.Popen([sys.executable, "-c", "pass"], env=newenv)

# equal character in the enviroment variable name
Expand Down
0