gitpython@0.3.0-beta2

GitPython is a Python library used to interact with Git repositories

  • latest version

    3.1.59

  • latest non vulnerable version

  • first published

    16 years ago

  • latest version published

    1 days ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the gitpython package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the from_tree, reset, or merge_tree process. An attacker can overwrite or destroy arbitrary files with a valid git-index blob by injecting malicious arguments into the positional parameters, leading to file corruption or loss at attacker-controlled writable locations.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    Arbitrary Code Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Code Injection via the Repo.init process. An attacker can execute arbitrary code by supplying a malicious template parameter that points to a directory containing executable git hooks, which are then copied into the repository and triggered on subsequent git operations. This is only exploitable if the application forwards a user-controlled template argument and the attacker is able to stage an executable hook directory at a known path.

    How to fix Arbitrary Code Injection?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    External Control of File Name or Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to External Control of File Name or Path in the remove and checkout functions. An attacker can access the contents of arbitrary files by supplying crafted arguments to these functions, causing the entire file contents to be returned in error messages.

    How to fix External Control of File Name or Path?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    External Control of File Name or Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to External Control of File Name or Path via the handling of submodule names in the .gitmodules configuration. An attacker can cause arbitrary directories and Git repositories to be created outside the intended working tree by supplying a crafted submodule name containing directory traversal sequences. This can lead to unauthorized modification of the filesystem and potential disruption of system integrity when a victim clones a malicious repository and initializes submodules.

    How to fix External Control of File Name or Path?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the set_value process. An attacker can execute arbitrary commands by injecting specially crafted option names that are written verbatim into the configuration file, resulting in unintended directives being parsed and executed during subsequent operations.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the check_unsafe_options process. An attacker can execute arbitrary OS commands by supplying specially crafted keyword arguments that bypass internal option guards.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.58 or higher.

    [,3.1.58)
    • H
    External Control of File Name or Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to External Control of File Name or Path in the Repo.archive. An attacker can access arbitrary files on the filesystem by supplying specially crafted options that are not properly denied by the existing guard, such as --add-file or --add-virtual-file, which allow reading files outside the intended repository and including their contents in the generated archive.

    How to fix External Control of File Name or Path?

    Upgrade GitPython to version 3.1.57 or higher.

    [,3.1.57)
    • M
    External Control of File Name or Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to External Control of File Name or Path in the Repo.archive. An attacker can access arbitrary files on the filesystem by supplying specially crafted options that are not properly denied by the existing guard, such as --add-file or --add-virtual-file, which allow reading files outside the intended repository and including their contents in the generated archive.

    How to fix External Control of File Name or Path?

    Upgrade GitPython to version 3.1.57 or higher.

    [,3.1.57)
    • H
    External Control of File Name or Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to External Control of File Name or Path via the forwarding of unguarded options in the checkout and create functions. An attacker can overwrite arbitrary files or read arbitrary files by supplying crafted arguments to these functions, which are then passed directly to underlying git commands without proper validation.

    How to fix External Control of File Name or Path?

    Upgrade GitPython to version 3.1.57 or higher.

    [,3.1.57)
    • M
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the Commit.count function. An attacker can cause arbitrary files to be truncated to zero bytes by injecting the output argument, leading to loss of data integrity and availability.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.56 or higher.

    [,3.1.56)
    • H
    Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') through improper sanitization of section or subsection names in configuration headers. An attacker can inject arbitrary configuration directives by supplying specially crafted submodule names, leading to the execution of malicious commands during subsequent git operations.

    How to fix Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')?

    Upgrade GitPython to version 3.1.53 or higher.

    [,3.1.53)
    • H
    Information Exposure

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Information Exposure in the Repo.create_remote process when attacker-controlled URLs are passed and environment variables are expanded into the URL. An attacker can obtain sensitive environment secrets by supplying a crafted URL containing environment variable references, which are then expanded and stored in configuration files and transmitted to attacker-controlled servers during subsequent network operations.

    How to fix Information Exposure?

    Upgrade GitPython to version 3.1.55 or higher.

    [,3.1.55)
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the diff process. An attacker can overwrite or corrupt arbitrary files with attacker-influenced diff content by injecting malicious arguments into the other parameter or by supplying crafted keyword arguments, leading to unauthorized file modification at the process privilege level.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.54 or higher.

    [,3.1.54)
    • H
    Incomplete List of Disallowed Inputs

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Incomplete List of Disallowed Inputs via the clone_from process. An attacker can execute arbitrary commands by supplying a crafted directory containing malicious hooks as the template parameter during a clone operation. This is only exploitable if the attacker can provide a directory with executable hooks accessible to the target system, such as through shared filesystems, upload directories, or attacker-writable network paths.

    How to fix Incomplete List of Disallowed Inputs?

    Upgrade GitPython to version 3.1.54 or higher.

    [,3.1.54)
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the check_unsafe_options process. An attacker can execute arbitrary commands by smuggling a malicious option token inside the value of a single-character keyword argument, which bypasses the intended guard and results in the execution of attacker-supplied commands.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.54 or higher.

    [,3.1.54)
    • H
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection via the Repo.archive(), Repo.iter_commits(), Repo.blame(), and Git.ls_remote() call paths in git/repo/base.py, git/objects/commit.py, and git/cmd.py. An attacker can execute arbitrary Git helpers or clobber files by supplying unsafe archive/ls-remote options or a revision string such as --output=/path to iter_commits() or blame(). In Repo.archive(), caller-controlled keyword arguments are forwarded into git archive, allowing options like --exec or --output; in Git.ls_remote(), upload_pack is turned into --upload-pack without rejection. In Repo.iter_commits() and Repo.blame(), a revision value placed before -- is parsed as a Git option, letting an attacker trigger file truncation or overwrite before revision parsing fails.

    Notes

    • Repo.archive() is only dangerous when callers forward user-influenced remote, exec, or output values; the write-up’s command-execution and file-clobber behavior depends on those arguments being passed through as archive options, not on ordinary tree export use.
    • Repo.iter_commits() and Repo.blame() are exposed to the overwrite primitive when the revision string or rev_opts can begin with -; the affected path is the revision parser’s pre--- handling, so applications that only pass fixed refs or validated commit IDs miss the issue.

    Workarounds

    • Use allow_unsafe_options=False (the default) on Repo.archive(), Repo.iter_commits(), Repo.blame(), and git.ls_remote() and do not pass user-controlled options such as exec, output, rev_opts, or upload_pack; this blocks attacker-supplied Git flags from reaching helper execution or file-overwrite options.
    • Set allow_unsafe_protocols=False on Repo.archive() and avoid remote= values that resolve to unsafe protocols such as ext::...; this prevents git archive from invoking an arbitrary remote helper path.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.51 or higher.

    [,3.1.51)
    • H
    Incomplete List of Disallowed Inputs

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Incomplete List of Disallowed Inputs through Git.check_unsafe_options in git/cmd.py. An attacker can execute arbitrary commands by supplying abbreviated unsafe option names such as upload_p in a clone, fetch, pull, or push call, causing GitPython’s exact-match blocklist to miss the option and pass it to Git as a dangerous long-option prefix. This can run attacker-controlled programs like --upload-pack or --receive-pack under the caller’s process, leading to remote code execution in applications that forward user-controlled keyword names into GitPython operations.

    Notes

    • Git’s unsafe-option guard is only exercised when the host application forwards user-controlled keyword names into clone, fetch, pull, or push; fixed call sites that pass literal option names are not exposed by this variant.
    • The bypass hinges on Git’s long-option prefix parsing, so abbreviated spellings like upload_p can be interpreted as blocked command-executing options even when the exact unsafe name is not used.

    How to fix Incomplete List of Disallowed Inputs?

    Upgrade GitPython to version 3.1.51 or higher.

    [,3.1.51)
    • H
    Insertion of Sensitive Information Into Sent Data

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Insertion of Sensitive Information Into Sent Data via Git.polish_url() in Repo.clone_from() and the stored-origin normalization path in git/repo/base.py. An attacker can make the server send secrets to an attacker-controlled host by supplying a clone URL containing $NAME, ${NAME}, or %NAME% tokens. Repo.clone_from() passes the attacker-controlled URL through Git.polish_url() before invoking git clone, so the process environment is expanded into the remote URL on native and Cygwin platforms. That exposes values such as API tokens or cloud credentials in the outbound request, causing secret leakage whenever an application accepts untrusted repository URLs.

    Notes

    • The issue is exploitable in the common “import repository from URL” pattern, where a server-side service accepts a user-supplied clone URL and runs Repo.clone_from() under its own environment; the leaked values come from that process environment, so secrets like deployment tokens or cloud credentials can be disclosed without any separate secret-management misconfiguration.
    • The stored-origin path is also in scope: after a successful clone, GitPython persists the normalized remote URL back into the repository config, so a URL containing expansion tokens can leave the secret embedded in the saved origin metadata as well as in the outbound clone request.

    How to fix Insertion of Sensitive Information Into Sent Data?

    Upgrade GitPython to version 3.1.52 or higher.

    [,3.1.52)
    • H
    Command Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Command Injection via the set_value function when the section parameter is not properly validated for newline characters. An attacker can execute arbitrary code by injecting malicious section headers into the .git/config file, which can redirect core.hooksPath to an attacker-controlled directory and trigger execution when a git hook runs.

    Note: This vulnerability bypasses the patch for CVE-2026-42215.

    How to fix Command Injection?

    Upgrade GitPython to version 3.1.50 or higher.

    [,3.1.50)
    • H
    Arbitrary Code Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Code Injection via the set_value function. An attacker can achieve arbitrary code execution by injecting newline characters into configuration values, which allows the creation of malicious Git configuration entries such as core.hooksPath. This enables execution of attacker-controlled scripts during Git operations that invoke hooks.

    How to fix Arbitrary Code Injection?

    Upgrade GitPython to version 3.1.49 or higher.

    [,3.1.49)
    • H
    Directory Traversal

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Directory Traversal through insufficient validation of reference paths in the creation, renaming, and deletion. An attacker can write, overwrite, move, or delete files outside the intended directory by supplying crafted reference paths to the relevant APIs.

    How to fix Directory Traversal?

    Upgrade GitPython to version 3.1.48 or higher.

    [,3.1.48)
    • C
    Arbitrary Argument Injection

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Arbitrary Argument Injection in the multi_options parameter of the _clone function, which may be passed in via the clone_from(), clone(), or Submodule.update() functions. An attacker can execute arbitrary code by supplying specially crafted input that manipulates Git configuration options, leading to the execution of malicious hooks during cloning.

    How to fix Arbitrary Argument Injection?

    Upgrade GitPython to version 3.1.47 or higher.

    [,3.1.47)
    • H
    Untrusted Search Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Untrusted Search Path via the use of an untrusted search path on Windows. An attacker can execute arbitrary code by placing a malicious git.exe or bash.exe in the current directory, which may then be executed instead of the legitimate binaries when certain GitPython features are used.

    Notes:

    1. This is a completion of the fix for CVE-2023-40590.

    2. When GitPython runs git directly rather than through a shell, the GitPython process performs the path search, and omits the current directory by setting NoDefaultCurrentDirectoryInExePath in its own environment during the Popen call.

    3. GitPython sets the subprocess CWD to the root of a repository's working tree. Using a shell will run a malicious git.exe in an untrusted repository even if GitPython itself is run from a trusted location. This also applies if git.execute is called directly with shell=True or after git.USE_SHELL = True, to run any command.

    4. On Windows, GitPython uses bash.exe to run hooks that appear to be scripts. However, unlike when running git, no steps are taken to avoid finding and running bash.exe in the current directory. While bash.exe is a shell, this is a separate scenario from when git is run using the unrelated Windows cmd.exe shell.

    How to fix Untrusted Search Path?

    Upgrade GitPython to version 3.1.41 or higher.

    [,3.1.41)
    • M
    Directory Traversal

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Directory Traversal due to improper validation of the final path. Although this vulnerability cannot be used to read the contents of files, it could potentially be used to trigger a denial of service for the program.

    How to fix Directory Traversal?

    Upgrade GitPython to version 3.1.35 or higher.

    [,3.1.35)
    • H
    Untrusted Search Path

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Untrusted Search Path allowing an attacker to run any arbitrary commands through a downloaded repository with a malicious git executable.

    Note: This vulnerability affects only Windows systems.

    How to fix Untrusted Search Path?

    Upgrade GitPython to version 3.1.33 or higher.

    [,3.1.33)
    • C
    Remote Code Execution (RCE)

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Remote Code Execution (RCE) due to an improper fix for CVE-2022-24439, which allows insecure non-multi options in clone and clone_from.

    How to fix Remote Code Execution (RCE)?

    Upgrade GitPython to version 3.1.32 or higher.

    [,3.1.32)
    • H
    Remote Code Execution (RCE)

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Remote Code Execution (RCE) due to improper user input validation, which makes it possible to inject a maliciously crafted remote URL into the clone command. Exploiting this vulnerability is possible because the library makes external calls to git without sufficient sanitization of input arguments. This is only relevant when enabling the ext transport protocol.

    How to fix Remote Code Execution (RCE)?

    Upgrade GitPython to version 3.1.30 or higher.

    [0,3.1.30)
    • M
    Regular Expression Denial of Service (ReDoS)

    GitPython is a python library used to interact with Git repositories

    Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) when a user controls the input passed to the pattern matching function.

    How to fix Regular Expression Denial of Service (ReDoS)?

    Upgrade GitPython to version 3.1.27 or higher.

    [,3.1.27)