Skip to content
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

Don't split git references on unicode separators #9827

Merged
merged 2 commits into from
Apr 24, 2021
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")
pradyunsg marked this conversation as resolved.
Show resolved Hide resolved
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