Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions news/9827.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**SECURITY**: Stop splitting on unicode separators in git references,
which could be maliciously used to install a different revision on the
repository.
10 changes: 8 additions & 2 deletions src/pip/_internal/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ def get_revision_sha(cls, dest, rev):
on_returncode='ignore',
)
refs = {}
for line in output.strip().splitlines():
# NOTE: We do not use splitlines here since that would split on other
# unicode separators, which can be maliciously used to install a
# different revision.
for line in output.strip().split("\n"):
line = line.rstrip("\r")
if not line:
continue
try:
ref_sha, ref_name = line.split()
ref_sha, ref_name = line.split(" ", maxsplit=2)
except ValueError:
# Include the offending line to simplify troubleshooting if
# this error ever occurs.
Expand Down