Skip to content

Validate submodule names before filesystem operations - #2202

Draft
Byron wants to merge 1 commit into
mainfrom
submodule-name-check
Draft

Validate submodule names before filesystem operations#2202
Byron wants to merge 1 commit into
mainfrom
submodule-name-check

Conversation

@Byron

@Byron Byron commented Aug 1, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Advisory

https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-hmq2-w58f-27jc

Advisory summary

  • GHSA: GHSA-hmq2-w58f-27jc
  • Severity: High
  • Package: GitPython (pip)
  • Affected versions: <= 3.1.57
  • Patched versions: not yet assigned
  • CVE: not yet assigned

This change validates submodule names before filesystem operations. Details are intentionally concise while the advisory remains a draft.

Changes

  • Reject empty, rooted, drive-qualified, and parent-component submodule names.
  • Validate before constructing module paths and before opening or mutating existing checkouts, covering repositories initialized by older vulnerable versions.
  • Validate programmatic add and rename inputs before making changes.
  • Add local regression coverage for both new initialization and an existing separate Git directory outside the clone.

Git baseline

Matches the name-validation behavior introduced by Git commit 0383bbb901 (submodule-config: verify submodule names as paths), with additional handling for Python path-join semantics.

Validation

  • pytest -q test/test_submodule.py on Python 3.14.6: 39 passed, 1 skipped, 1 xfailed
  • Ruff check and format check: passed
  • mypy for git/objects/submodule/base.py: passed

No Docker reproduction was used.

Submodule names read from .gitmodules can influence the separate Git directory path. Reject empty names, absolute or drive-qualified names, and parent components with either path separator.

Validate before constructing module paths and before opening or mutating existing checkouts, so a repository initialized by an older vulnerable version cannot bypass the guard. Validate programmatic add and rename inputs before making changes as well.

Add local-repository regression coverage for both new initialization and an existing separate Git directory outside the clone. This follows Git commit 0383bbb901 (submodule-config: verify submodule names as paths) while also accounting for os.path.join absolute-path semantics.

Advisory: GHSA-hmq2-w58f-27jc

Validation:
- pytest -q test/test_submodule.py on Python 3.14.6 (39 passed, 1 skipped, 1 xfailed)
- ruff check and format --check on changed files
- mypy git/objects/submodule/base.py
@Byron
Byron force-pushed the submodule-name-check branch from e1d07cc to b88d913 Compare August 1, 2026 03:10
@Byron Byron changed the title Validate submodule names before creating module paths Validate submodule names before filesystem operations Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants