new file mode 100644
@@ -0,0 +1,174 @@
+From eca51fe4d3741f64b4204a6da04536d428390a4f Mon Sep 17 00:00:00 2001
+From: "GPT 5.6" <codex@openai.com>
+Date: Wed, 15 Jul 2026 16:44:13 +0200
+Subject: [PATCH 13/38] fix: prevent environment expansion in clone URLs
+
+Repo.clone_from() expanded environment-variable references in caller-supplied
+URLs before passing them to git clone. This could expose process environment
+values to an untrusted remote and made protocol validation apply to a different
+value than Git received.
+
+Polish clone URLs without variable or home expansion on native and Cygwin
+Git, then apply unsafe-protocol validation to that exact normalized value.
+Preserve the literal URL when normalizing the stored origin after a successful
+clone, while retaining the existing Git.polish_url() default for callers
+that intentionally normalize local paths. Add regression coverage for
+POSIX and Windows variable syntax, Cygwin conversion, stored origins, and
+post-normalization protocol validation.
+
+Git baseline: git clone passes URL arguments through literally; t/t5601-clone.sh
+covers the accepted URL forms without shell-style environment expansion.
+
+Security: GHSA-rwj8-pgh3-r573.
+
+CVE: CVE-2026-67322
+Upstream-Status: Backport [https://github.com/gitpython-developers/GitPython/commit/8ac5a30519b6f4af85398b9b9d7064ff4d452da2]
+
+Backport Changes:
+- Omit upstream regression test changes because the current
+ PyPI source archive does not include its test suite.
+
+Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
+(cherry picked from commit 8ac5a30519b6f4af85398b9b9d7064ff4d452da2)
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ git/cmd.py | 29 ++++++++++++++++-------------
+ git/repo/base.py | 7 ++++---
+ git/util.py | 15 +++++++++------
+ 3 files changed, 29 insertions(+), 22 deletions(-)
+
+diff --git a/git/cmd.py b/git/cmd.py
+index 1903bb01..46619459 100644
+--- a/git/cmd.py
++++ b/git/cmd.py
+@@ -497,31 +497,34 @@ class Git(LazyMixin):
+
+ @overload
+ @classmethod
+- def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str:
+- ...
++ def polish_url(cls, url: str, is_cygwin: Literal[False] = ..., expand_vars: bool = ...) -> str: ...
+
+ @overload
+ @classmethod
+- def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
+- ...
++ def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None, expand_vars: bool = True) -> str: ...
+
+ @classmethod
+- def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
+- """Remove any backslashes from urls to be written in config files.
++ def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None, expand_vars: bool = True) -> PathLike:
++ """Remove any backslashes from URLs to be written in config files.
++
++ Windows might create config files containing paths with backslashes, but git
++ stops liking them as it will escape the backslashes. Hence we undo the escaping
++ just to be sure.
+
+- Windows might create config files containing paths with backslashes,
+- but git stops liking them as it will escape the backslashes. Hence we
+- undo the escaping just to be sure.
++ :param expand_vars:
++ Expand environment variables and an initial ``~``. Disable this for values
++ obtained from an untrusted source, such as remote URLs.
+ """
+ if is_cygwin is None:
+ is_cygwin = cls.is_cygwin()
+
+ if is_cygwin:
+- url = cygpath(url)
++ url = cygpath(url, expand_vars=expand_vars)
+ else:
+- url = os.path.expandvars(url)
+- if url.startswith("~"):
+- url = os.path.expanduser(url)
++ if expand_vars:
++ url = os.path.expandvars(url)
++ if url.startswith("~"):
++ url = os.path.expanduser(url)
+ url = url.replace("\\\\", "\\").replace("\\", "/")
+ return url
+
+diff --git a/git/repo/base.py b/git/repo/base.py
+index 5b255997..0440a92d 100644
+--- a/git/repo/base.py
++++ b/git/repo/base.py
+@@ -1316,8 +1316,9 @@ class Repo:
+ if multi_options:
+ multi = shlex.split(" ".join(multi_options))
+
++ clone_url = Git.polish_url(url, expand_vars=False)
+ if not allow_unsafe_protocols:
+- Git.check_unsafe_protocols(str(url))
++ Git.check_unsafe_protocols(clone_url)
+ if not allow_unsafe_options:
+ Git.check_unsafe_options(
+ options=Git._option_candidates([], kwargs),
+@@ -1329,7 +1330,7 @@ class Repo:
+ proc = git.clone(
+ multi,
+ "--",
+- Git.polish_url(str(url)),
++ clone_url,
+ clone_path,
+ with_extended_output=True,
+ as_process=True,
+@@ -1370,7 +1371,7 @@ class Repo:
+ # sure.
+ if repo.remotes:
+ with repo.remotes[0].config_writer as writer:
+- writer.set_value("url", Git.polish_url(repo.remotes[0].url))
++ writer.set_value("url", Git.polish_url(repo.remotes[0].url, expand_vars=False))
+ # END handle remote repo
+ return repo
+
+diff --git a/git/util.py b/git/util.py
+index 5a136d18..d3eaeb8b 100644
+--- a/git/util.py
++++ b/git/util.py
+@@ -361,13 +361,13 @@ def py_where(program: str, path: Optional[PathLike] = None) -> List[str]:
+ return progs
+
+
+-def _cygexpath(drive: Optional[str], path: str) -> str:
++def _cygexpath(drive: Optional[str], path: str, expand_vars: bool = True) -> str:
+ if osp.isabs(path) and not drive:
+ # Invoked from `cygpath()` directly with `D:Apps\123`?
+ # It's an error, leave it alone just slashes)
+ p = path # convert to str if AnyPath given
+ else:
+- p = path and osp.normpath(osp.expandvars(osp.expanduser(path)))
++ p = path and osp.normpath(osp.expandvars(osp.expanduser(path)) if expand_vars else path)
+ if osp.isabs(p):
+ if drive:
+ # Confusing, maybe a remote system should expand vars.
+@@ -395,7 +395,7 @@ _cygpath_parsers: Tuple[Tuple[Pattern[str], Callable, bool], ...] = (
+ )
+
+
+-def cygpath(path: str) -> str:
++def cygpath(path: str, expand_vars: bool = True) -> str:
+ """Use :meth:`git.cmd.Git.polish_url` instead, that works on any environment."""
+ path = str(path) # Ensure is str and not AnyPath.
+ # Fix to use Paths when 3.5 dropped. Or to be just str if only for URLs?
+@@ -403,12 +403,15 @@ def cygpath(path: str) -> str:
+ for regex, parser, recurse in _cygpath_parsers:
+ match = regex.match(path)
+ if match:
+- path = parser(*match.groups())
++ if parser is _cygexpath:
++ path = parser(*match.groups(), expand_vars=expand_vars)
++ else:
++ path = parser(*match.groups())
+ if recurse:
+- path = cygpath(path)
++ path = cygpath(path, expand_vars=expand_vars)
+ break
+ else:
+- path = _cygexpath(None, path)
++ path = _cygexpath(None, path, expand_vars=expand_vars)
+
+ return path
+
+--
+2.35.6
@@ -26,6 +26,7 @@ SRC_URI += " file://CVE-2026-42284.patch \
file://CVE-2026-67325_p1.patch \
file://CVE-2026-67325_p2.patch \
file://CVE-2026-67324.patch \
+ file://CVE-2026-67322.patch \
"
SRC_URI[sha256sum] = "2d99869e0fef71a73cbd242528105af1d6c1b108c60dfabd994bf292f76c3ceb"
This patch applies the upstream fix as referenced in [2], using the commit shown in [1] [1] https://github.com/gitpython-developers/GitPython/commit/8ac5a30519b6f4af85398b9b9d7064ff4d452da2 [2] https://www.cve.org/CVERecord?id=CVE-2026-67322 Signed-off-by: Yogita Urade <yurade@cisco.com> --- .../python/python3-git/CVE-2026-67322.patch | 174 ++++++++++++++++++ .../python/python3-git_3.1.42.bb | 1 + 2 files changed, 175 insertions(+) create mode 100644 meta/recipes-devtools/python/python3-git/CVE-2026-67322.patch