CVE-2022-24826: Github.com/git lfs/git lfs/v3 Git LFS Can Execute A Vulnerability

CRITICAL
Advisory Identifier: GHSA-6rw3-3whw-jvjj
CVSS 9.8
CWE-426
Published
Advisory Summary

CVE-2022-24826 is a CRITICAL (CVSS 9.8) git lfs can execute a vulnerability (CWE-426: Untrusted Search Path) affecting Github.com/git lfs/git lfs/v3 libraries in the Go ecosystem. The issue involves git lfs can execute a binary from the current directory on windows. Remediation is available by upgrading affected packages to version 3.1.3.

CVE-2022-24826 at a Glance

CVE Identifier CVE-2022-24826
GHSA Identifier GHSA-6rw3-3whw-jvjj
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-426: Untrusted Search Path
Affected Product Github.com/git lfs/git lfs/v3
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-24826

To remediate this vulnerability, upgrade all affected Github.com/git lfs/git lfs/v3 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/git-lfs/git-lfs/v3 fixed: 3.1.3
Upgrade github.com/git-lfs/git-lfs/v3 to 3.1.3
github.com/git-lfs/git-lfs fixed: Latest secure release
Upgrade github.com/git-lfs/git-lfs to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/git-lfs/git-lfs/v3

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-24826, inspect your project dependencies for Github.com/git lfs/git lfs/v3:

inspect dependencies for github.com/git-lfs/git-lfs/v3

Analyze the terminal output to locate any version of Github.com/git lfs/git lfs/v3 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-426: Untrusted Search Path, where the product searches for critical resources using an externally-supplied search path that can point to resources that are not under the product's direct control. In Github.com/git lfs/git lfs/v3, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact On Windows, if Git LFS operates on a malicious repository with a `..exe` file as well as a file named `git.exe`, and `git.exe` is not found in `PATH`, the `..exe` program will be executed, permitting the attacker to execute arbitrary code. This does not affect Unix systems. Similarly, if the malicious repository contains files named `..exe` and `cygpath.exe`, and `cygpath.exe` is not found in `PATH`, the `..exe` program will be executed when certain Git LFS commands are run. More generally, if the current working directory contains any file with a base name of `.` and a file extension from `PATHEXT` (except `.bat` and `.cmd`), and also contains another file with the same base name as a program Git LFS intends to execute (such as `git`, `cygpath`, or `uname`) and any file extension from `PATHEXT` (including `.bat` and `.cmd`), then, on Windows, when Git LFS attempts to execute the intended program the `..exe`, `..com`, etc., file will be executed instead, but only if the intended program is not found in any directory listed in `PATH`. The vulnerability occurs because when Git LFS detects that the program it intends to run does not exist in any directory listed in `PATH` then Git LFS passes an empty string as the executable file path to the Go `os/exec` package, which contains a bug such that, on Windows, it prepends the name of the current working directory (i.e., `.`) to the empty string without adding a path separator, and as a result searches in that directory for a file with the base name `.` combined with any file extension from `PATHEXT`, executing the first one it finds. (The reason `..bat` and `..cmd` files are not executed in the same manner is that, although the Go `os/exec` package tries to execute them just as it does a `..exe` file, the Microsoft Win32 API `CreateProcess()` family of functions have an undocumented feature in that they apparently recognize when a caller is attempting to execute a batch script file and instead run the `cmd.exe` command interpreter, passing the full set of command line arguments as parameters. These are unchanged from the command line arguments set by Git LFS, and as such, the intended program's name is the first, resulting in a command line like `cmd.exe /c git`, which then fails.) Git LFS has resolved this vulnerability by always reporting an error when a program is not found in any directory listed in `PATH` rather than passing an empty string to the Go `os/exec` package in this case. The bug in the Go `os/exec` package has been reported to the Go project and is expected to be patched after this security advisory is published. ### Patches The problem was introduced in v2.12.1 and is patched in v3.1.3 and v3.1.4. Users of affected versions should upgrade to v3.1.4. ### Workarounds There are no known workarounds at this time. ### References * https://github.com/git-lfs/git-lfs/security/advisories/GHSA-6rw3-3whw-jvjj * https://nvd.nist.gov/vuln/detail/CVE-2022-24826 * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24826 * https://github.com/git-lfs/git-lfs/releases/tag/v3.1.4 * [git-lfs/git-lfs@762ccd4a49](https://github.com/git-lfs/git-lfs/commit/762ccd4a498f5c17723b91d56b9304434ada5540) ### For more information If you have any questions or comments about this advisory: * For general questions, start a discussion in the Git LFS [discussion forum](https://github.com/git-lfs/git-lfs/discussions). * For reports of additional vulnerabilities, please follow the Git LFS [security reporting policy](https://github.com/git-lfs/git-lfs/blob/main/SECURITY.md).

CVE-2022-24826 Affected Github.com/git lfs/git lfs/v3 Versions

2 component(s)
Fixed Versions:
3.1.3
Product / Package Ecosystem Affected Versions Fixed Version
github.com/git-lfs/git-lfs/v3
Go
≥ 3.0.0
< 3.1.3
3.1.3
github.com/git-lfs/git-lfs
Go
≥ 2.12.1

References

Frequently Asked Questions

What is CVE-2022-24826?
CVE-2022-24826 is a security vulnerability in Github.com/git lfs/git lfs/v3 involving Git LFS can execute a binary from the current directory on Windows under CWE-426: Untrusted Search Path.
Which Github.com/git lfs/git lfs/v3 versions are affected?
Affected versions include releases prior to 3.1.3 across affected packages: github.com/git-lfs/git-lfs/v3, github.com/git-lfs/git-lfs.
What version fixes CVE-2022-24826?
Upgrading to 3.1.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/git-lfs/git-lfs/v3 affected?
Yes, github.com/git-lfs/git-lfs/v3 is affected in releases prior to 3.1.3. Upgrade your dependency to 3.1.3 or later.
Is github.com/git-lfs/git-lfs affected?
Yes, github.com/git-lfs/git-lfs is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2022-24826?
CVE-2022-24826 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-24826?
CVE-2022-24826 is classified under CWE-426: Untrusted Search Path (The product searches for critical resources using an externally-supplied search path that can point to resources that are not under the product's direct control.).
How can I check Go dependencies for CVE-2022-24826?
Run the dependency tree command: 'inspect dependencies for github.com/git-lfs/git-lfs/v3'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6rw3-3whw-jvjj",
  "modified" : "2022-04-22T20:13:21Z",
  "published" : "2022-04-22T20:13:21Z",
  "aliases" : [ "CVE-2022-24826" ],
  "summary" : "Git LFS can execute a binary from the current directory on Windows",
  "details" : "### Impact\nOn Windows, if Git LFS operates on a malicious repository with a `..exe` file as well as a file named `git.exe`, and `git.exe` is not found in `PATH`, the `..exe` program will be executed, permitting the attacker to execute arbitrary code.  This does not affect Unix systems.\n\nSimilarly, if the malicious repository contains files named `..exe` and `cygpath.exe`, and `cygpath.exe` is not found in `PATH`, the `..exe` program will be executed when certain Git LFS commands are run.\n\nMore generally, if the current working directory contains any file with a base name of `.` and a file extension from `PATHEXT` (except `.bat` and `.cmd`), and also contains another file with the same base name as a program Git LFS intends to execute (such as `git`, `cygpath`, or `uname`) and any file extension from `PATHEXT` (including `.bat` and `.cmd`), then, on Windows, when Git LFS attempts to execute the intended program the `..exe`, `..com`, etc., file will be executed instead, but only if the intended program is not found in any directory listed in `PATH`.\n\nThe vulnerability occurs because when Git LFS detects that the program it intends to run does not exist in any directory listed in `PATH` then Git LFS passes an empty string as the executable file path to the Go `os/exec` package, which contains a bug such that, on Windows, it prepends the name of the current working directory (i.e., `.`) to the empty string without adding a path separator, and as a result searches in that directory for a file with the base name `.` combined with any file extension from `PATHEXT`, executing the first one it finds.\n\n(The reason `..bat` and `..cmd` files are not executed in the same manner is that, although the Go `os/exec` package tries to execute them just as it does a `..exe` file, the Microsoft Win32 API `CreateProcess()` family of functions have an undocumented feature in that they apparently recognize when a caller is attempting to execute a batch script file and instead run the `cmd.exe` command interpreter, passing the full set of command line arguments as parameters.  These are unchanged from the command line arguments set by Git LFS, and as such, the intended program's name is the first, resulting in a command line like `cmd.exe /c git`, which then fails.)\n\nGit LFS has resolved this vulnerability by always reporting an error when a program is not found in any directory listed in `PATH` rather than passing an empty string to the Go `os/exec` package in this case.\n\nThe bug in the Go `os/exec` package has been reported to the Go project and is expected to be patched after this security advisory is published.\n\n### Patches\nThe problem was introduced in v2.12.1 and is patched in v3.1.3 and v3.1.4.  Users of affected versions should upgrade to v3.1.4.\n\n### Workarounds\nThere are no known workarounds at this time.\n\n### References\n* https://github.com/git-lfs/git-lfs/security/advisories/GHSA-6rw3-3whw-jvjj\n* https://nvd.nist.gov/vuln/detail/CVE-2022-24826\n* https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24826\n* https://github.com/git-lfs/git-lfs/releases/tag/v3.1.4\n* [git-lfs/git-lfs@762ccd4a49](https://github.com/git-lfs/git-lfs/commit/762ccd4a498f5c17723b91d56b9304434ada5540)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* For general questions, start a discussion in the Git LFS [discussion forum](https://github.com/git-lfs/git-lfs/discussions).\n* For reports of additional vulnerabilities, please follow the Git LFS [security reporting policy](https://github.com/git-lfs/git-lfs/blob/main/SECURITY.md).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/git-lfs/git-lfs/v3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/git-lfs/git-lfs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.12.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/git-lfs/git-lfs/security/advisories/GHSA-6rw3-3whw-jvjj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24826"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/git-lfs/git-lfs"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-426" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-22T20:13:21Z",
    "nvd_published_at" : "2022-04-20T00:16:00Z"
  }
}