GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix CVE-2023-41040 by facutuesca · Pull Request #1644 · gitpython-developers/GitPython

Fix CVE-2023-41040 #1644

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.

Sign up for GitHub

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
Byron merged 2 commits into gitpython-developers:main from trail-of-forks:fix-cve-2023-41040
Sep 7, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

Fix CVE-2023-41040 #1644

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
64ebb9f
Fix CVE-2023-41040
facutuesca Sep 5, 2023
65b8c6a
Add test for CVE-2023-41040
facutuesca Sep 5, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

2 changes: 2 additions & 0 deletions 2 git/refs/symbolic.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def _get_ref_info_helper(
"""Return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None. target_ref_path is the reference we
point to, or None"""
if ".." in str(ref_path):
raise ValueError(f"Invalid reference '{ref_path}'")
tokens: Union[None, List[str], Tuple[str, str]] = None
repodir = _git_dir(repo, ref_path)
try:
Expand Down
15 changes: 15 additions & 0 deletions 15 test/test_refs.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

from itertools import chain
from pathlib import Path

from git import (
Reference,
Expand All @@ -20,9 +21,11 @@
from git.objects.tag import TagObject
from test.lib import TestBase, with_rw_repo
from git.util import Actor
from gitdb.exc import BadName

import git.refs as refs
import os.path as osp
import tempfile


class TestRefs(TestBase):
Expand Down Expand Up @@ -616,3 +619,15 @@ def test_dereference_recursive(self):

def test_reflog(self):
assert isinstance(self.rorepo.heads.master.log(), RefLog)

def test_refs_outside_repo(self):
# Create a file containing a valid reference outside the repository. Attempting
# to access it should raise an exception, due to it containing a parent directory
# reference ('..'). This tests for CVE-2023-41040.
git_dir = Path(self.rorepo.git_dir)
repo_parent_dir = git_dir.parent.parent
with tempfile.NamedTemporaryFile(dir=repo_parent_dir) as ref_file:
ref_file.write(b"91b464cd624fe22fbf54ea22b85a7e5cca507cfe")
ref_file.flush()
ref_file_name = Path(ref_file.name).name
self.assertRaises(BadName, self.rorepo.commit, f"../../{ref_file_name}")
Comment thread
Byron marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.