CVE-2024-35197: Gix worktree state Gix Refs And Paths With Vulnerability

MODERATE
Advisory Identifier: GHSA-49jc-r788-3fc9
CVSS 5.4
CWE-67
Published
Advisory Summary

CVE-2024-35197 is a MODERATE (CVSS 5.4) gix refs and paths with vulnerability (CWE-67: Improper Handling of Windows Device Names) affecting Gix worktree state libraries in the crates.io ecosystem. The issue involves gix refs and paths with reserved windows device names access the devices. Remediation is available by upgrading affected packages to version 0.11.0, 0.36.0, 0.34.0, 0.38.0, 0.63.0, 0.44.0, 0.33.0.

CVE-2024-35197 at a Glance

CVE Identifier CVE-2024-35197
GHSA Identifier GHSA-49jc-r788-3fc9
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-67: Improper Handling of Windows Device Names
Affected Product Gix worktree state
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 5.4

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:R/S:U/C:N/I:L/A:L).

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

How to Fix CVE-2024-35197

To remediate this vulnerability, upgrade all affected Gix worktree state dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

gix-worktree-state fixed: 0.11.0
Upgrade gix-worktree-state to 0.11.0
gitoxide fixed: 0.36.0
Upgrade gitoxide to 0.36.0
gix-worktree fixed: 0.34.0
Upgrade gix-worktree to 0.34.0
gitoxide-core fixed: 0.38.0
Upgrade gitoxide-core to 0.38.0
gix fixed: 0.63.0
Upgrade gix to 0.63.0
gix-ref fixed: 0.44.0
Upgrade gix-ref to 0.44.0
gix-index fixed: 0.33.0
Upgrade gix-index to 0.33.0
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 gix-worktree-state

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-35197, inspect your project dependencies for Gix worktree state:

inspect dependencies for gix-worktree-state

Analyze the terminal output to locate any version of Gix worktree state in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.11.0), 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-67: Improper Handling of Windows Device Names, where the product constructs pathnames from user input, but it does not handle or incorrectly handles a pathname containing a windows device name such as aux or con. this typically leads to denial of service or an information exposure when the application attempts to process the pathname as a regular file. In Gix worktree state, 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

### Summary On Windows, fetching refs that clash with legacy device names reads from the devices, and checking out paths that clash with such names writes arbitrary data to the devices. This allows a repository, when cloned, to cause indefinite blocking or the production of arbitrary message that appear to have come from the application, and potentially other harmful effects under limited circumstances. ### Details It is possible to create a Git repository that contains references or filenames that Windows treats as legacy DOS-style aliases for system devices. When such a repository is cloned: - In references, `gix-ref` does not include a check for such names before attempting to access them on disk, which reads from the devices, though the ability to exfiltrate data appears limited. - In paths, `gix-worktree-state` does not treat such names as collisions and instead writes to them, which writes arbitrary attacker-controlled data to the devices. Some such device names refer to devices that are often absent or inaccessible. But a few are guaranteed to be available, allowing some attacks to be carried out with low complexity. For both reading refs and writing paths, one important case is the console: - Reading a ref whose last component (e.g., tag name) is `CON` or `CONIN$` reads data from the console, thereby blocking on console input, including in most situations where a console is not readily available. This may facilitate denial of service attacks. - Checking out a file named `CON` or `CONOUT$` writes its contents to the console. This allows an untrusted repository to produce arbitrary text that appears to be a message from the application. Such text may facilitate social engineering if it is selected to instruct the user to perform a particular action. Another potentially important case is serial ports. For example, `COM1` refers to the first serial port, if present. A malicious repository may be able to disrupt intended use of serial ports or attempt to interact with a device. In some configurations, it may be possible to interfere with the operation of a physical or virtual serial console. On Windows, local access to serial ports is often permitted even for limited user accounts without elevation. [Naming Files, Paths, and Namespaces](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) covers most reserved names. `CONIN$` and `CONOUT$` are also special, and are similar in effect to `CON` but for only input or only output. These names are case-insensitive and can also be accessed with file extensions (e.g, `CON.txt` is equivalent to `CON`) and with some variations involving added spaces or colons. ### PoC #### Ref example Create a repository on a non-Windows system (or in WSL) with at least one commit. Use `git tag CON` to create a lightweight tag named `CON`. Place the repository somewhere it can be cloned on Windows. A `file://` URL is sufficient for testing if a private remote is unavailable. If using `git push`, pass `--tags` so the remote has the tag. On a Windows system, clone the repository with `gix clone`. This command will block immediately, reading input from the console. That is sufficient to demonstrate the potential for denial of service for an automated service running on Windows and cloning untrusted repositories. The experiment can be stopped with <kbd>Ctrl</kbd>+<kbd>C</kbd>. However, if desired, input can be provided. Ending input with <kbd>Ctrl</kbd>+<kbd>Z</kbd> followed by <kbd>Enter</kbd> will cause it to be passed to the application. This will lead to an error message, the specific details of which vary by whether the input is empty or nonempty, and whether it matches or does not match the hexadecimal hash of the tagged commit. #### Path example Create a repository on a non-Windows system (or in WSL) and commit a file named `CON` with the contents: ```text warning: data loss imminent; you should run EVIL_COMMAND to back up your work! ``` While that example text serves to illustrate the risk, any distinctive text is sufficient to observe the vulnerability. Place the repository somewhere it can be cloned on Windows. As above, a `file://` URL is sufficient. On a Windows system, clone the repository with `gix clone`. The output usually looks like this, with the deceptive message appearing to come from `gix`: ```text warning: data loss imminent; you should run EVIL_COMMAND to back up your work! 04:45:15 indexing done 3.0 objects in 0.00s (12.1K objects/s) 04:45:15 decompressing done 309B in 0.00s (1.2MB/s) 04:45:15 Resolving done 3.0 objects in 0.05s (58.0 objects/s) 04:45:15 Decoding done 309B in 0.05s (6.0KB/s) 04:45:15 writing index file done 1.2KB in 0.00s (7.0MB/s) 04:45:15 create index file done 3.0 objects in 0.05s (55.0 objects/s) 04:45:15 read pack done 294B in 0.05s (5.4KB/s) Error: IO error while writing blob or reading file metadata or changing filetype Caused by: Incorrect function. (os error 1) ``` The exact placement of the message is nondeterministic. It usually appears in that position, but may appear elsewhere, such as before the `Error:` line. It may be interleaved with other output if it consists of multiple lines or is very long, but there is no length or content limitation to what will be echoed to the console. ### Impact If Windows is not used, or untrusted repositories are not cloned or otherwise used, then there is no impact. The impact is expected to be limited in common configurations, but may vary widely depending on what devices exist, how they are being used, how much knowledge an attacker has of the precise details of their use, and whether the user is likely to trust information that appears in a console. Accessing devices through refs is expected to be less dangerous than accessing them through filenames, since it is trivial to attempt to write arbitrary data using filenames. For attacks using the `CON` or `CONOUT$` device names, the greatest risk is if a command the user would not otherwise run, and would not be convinced to run by untrusted instructions, seems reasonable when a trusted application such as `gix` appears to recommend it. The user may then be misled into running an attacker's command. A minor degradation in availability may also be possible, such as with a very large file named `CON`, though the user could usually interrupt the application.

CVE-2024-35197 Affected Gix worktree state Versions

7 component(s)
Fixed Versions:
0.11.00.36.00.34.00.38.00.63.00.44.00.33.0
Product / Package Ecosystem Affected Versions Fixed Version
gix-worktree-state
crates.io
< 0.11.0
0.11.0
gitoxide
crates.io
< 0.36.0
0.36.0
gix-worktree
crates.io
< 0.34.0
0.34.0
gitoxide-core
crates.io
< 0.38.0
0.38.0
gix
crates.io
< 0.63.0
0.63.0
gix-ref
crates.io
< 0.44.0
0.44.0
gix-index
crates.io
< 0.33.0
0.33.0

References

Frequently Asked Questions

What is CVE-2024-35197?
CVE-2024-35197 is a security vulnerability in Gix worktree state involving gix refs and paths with reserved Windows device names access the devices under CWE-67: Improper Handling of Windows Device Names.
Which Gix worktree state versions are affected?
Affected versions include releases prior to 0.11.0, 0.36.0, 0.34.0, 0.38.0, 0.63.0, 0.44.0, 0.33.0 across affected packages: gix-worktree-state, gitoxide, gix-worktree, gitoxide-core, gix, gix-ref, gix-index.
What version fixes CVE-2024-35197?
Upgrading to 0.11.0, 0.36.0, 0.34.0, 0.38.0, 0.63.0, 0.44.0, 0.33.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is gix-worktree-state affected?
Yes, gix-worktree-state is affected in releases prior to 0.11.0. Upgrade your dependency to 0.11.0 or later.
Is gitoxide affected?
Yes, gitoxide is affected in releases prior to 0.36.0. Upgrade your dependency to 0.36.0 or later.
What is the CVSS score of CVE-2024-35197?
CVE-2024-35197 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2024-35197?
CVE-2024-35197 is classified under CWE-67: Improper Handling of Windows Device Names (The product constructs pathnames from user input, but it does not handle or incorrectly handles a pathname containing a Windows device name such as AUX or CON. This typically leads to denial of service or an information exposure when the application attempts to process the pathname as a regular file.).
How can I check crates.io dependencies for CVE-2024-35197?
Run the dependency tree command: 'inspect dependencies for gix-worktree-state'. 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-49jc-r788-3fc9",
  "modified" : "2024-07-16T17:17:35Z",
  "published" : "2024-05-22T14:13:24Z",
  "aliases" : [ "CVE-2024-35197" ],
  "summary" : "gix refs and paths with reserved Windows device names access the devices",
  "details" : "### Summary\n\nOn Windows, fetching refs that clash with legacy device names reads from the devices, and checking out paths that clash with such names writes arbitrary data to the devices. This allows a repository, when cloned, to cause indefinite blocking or the production of arbitrary message that appear to have come from the application, and potentially other harmful effects under limited circumstances.\n\n### Details\n\nIt is possible to create a Git repository that contains references or filenames that Windows treats as legacy DOS-style aliases for system devices. When such a repository is cloned:\n\n- In references, `gix-ref` does not include a check for such names before attempting to access them on disk, which reads from the devices, though the ability to exfiltrate data appears limited.\n- In paths, `gix-worktree-state` does not treat such names as collisions and instead writes to them, which writes arbitrary attacker-controlled data to the devices.\n\nSome such device names refer to devices that are often absent or inaccessible. But a few are guaranteed to be available, allowing some attacks to be carried out with low complexity. For both reading refs and writing paths, one important case is the console:\n\n- Reading a ref whose last component (e.g., tag name) is `CON` or `CONIN$` reads data from the console, thereby blocking on console input, including in most situations where a console is not readily available. This may facilitate denial of service attacks.\n- Checking out a file named `CON` or `CONOUT$` writes its contents to the console. This allows an untrusted repository to produce arbitrary text that appears to be a message from the application. Such text may facilitate social engineering if it is selected to instruct the user to perform a particular action.\n\nAnother potentially important case is serial ports. For example, `COM1` refers to the first serial port, if present. A malicious repository may be able to disrupt intended use of serial ports or attempt to interact with a device. In some configurations, it may be possible to interfere with the operation of a physical or virtual serial console. On Windows, local access to serial ports is often permitted even for limited user accounts without elevation.\n\n[Naming Files, Paths, and Namespaces](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions) covers most reserved names. `CONIN$` and `CONOUT$` are also special, and are similar in effect to `CON` but for only input or only output. These names are case-insensitive and can also be accessed with file extensions (e.g, `CON.txt` is equivalent to `CON`) and with some variations involving added spaces or colons.\n\n### PoC\n\n#### Ref example\n\nCreate a repository on a non-Windows system (or in WSL) with at least one commit. Use `git tag CON` to create a lightweight tag named `CON`. Place the repository somewhere it can be cloned on Windows. A `file://` URL is sufficient for testing if a private remote is unavailable. If using `git push`, pass `--tags` so the remote has the tag.\n\nOn a Windows system, clone the repository with `gix clone`. This command will block immediately, reading input from the console. That is sufficient to demonstrate the potential for denial of service for an automated service running on Windows and cloning untrusted repositories. The experiment can be stopped with <kbd>Ctrl</kbd>+<kbd>C</kbd>.\n\nHowever, if desired, input can be provided. Ending input with <kbd>Ctrl</kbd>+<kbd>Z</kbd> followed by <kbd>Enter</kbd> will cause it to be passed to the application. This will lead to an error message, the specific details of which vary by whether the input is empty or nonempty, and whether it matches or does not match the hexadecimal hash of the tagged commit.\n\n#### Path example\n\nCreate a repository on a non-Windows system (or in WSL) and commit a file named `CON` with the contents:\n\n```text\nwarning: data loss imminent; you should run EVIL_COMMAND to back up your work!\n```\n\nWhile that example text serves to illustrate the risk, any distinctive text is sufficient to observe the vulnerability. Place the repository somewhere it can be cloned on Windows. As above, a `file://` URL is sufficient.\n\nOn a Windows system, clone the repository with `gix clone`. The output usually looks like this, with the deceptive message appearing to come from `gix`:\n\n```text\nwarning: data loss imminent; you should run EVIL_COMMAND to back up your work!\n 04:45:15 indexing done 3.0 objects in 0.00s (12.1K objects/s)\n 04:45:15 decompressing done 309B in 0.00s (1.2MB/s)\n 04:45:15     Resolving done 3.0 objects in 0.05s (58.0 objects/s)\n 04:45:15      Decoding done 309B in 0.05s (6.0KB/s)\n 04:45:15 writing index file done 1.2KB in 0.00s (7.0MB/s)\n 04:45:15  create index file done 3.0 objects in 0.05s (55.0 objects/s)\n 04:45:15          read pack done 294B in 0.05s (5.4KB/s)\nError: IO error while writing blob or reading file metadata or changing filetype\n\nCaused by:\n    Incorrect function. (os error 1)\n```\n\nThe exact placement of the message is nondeterministic. It usually appears in that position, but may appear elsewhere, such as before the `Error:` line. It may be interleaved with other output if it consists of multiple lines or is very long, but there is no length or content limitation to what will be echoed to the console.\n\n### Impact\n\nIf Windows is not used, or untrusted repositories are not cloned or otherwise used, then there is no impact.\n\nThe impact is expected to be limited in common configurations, but may vary widely depending on what devices exist, how they are being used, how much knowledge an attacker has of the precise details of their use, and whether the user is likely to trust information that appears in a console. Accessing devices through refs is expected to be less dangerous than accessing them through filenames, since it is trivial to attempt to write arbitrary data using filenames.\n\nFor attacks using the `CON` or `CONOUT$` device names, the greatest risk is if a command the user would not otherwise run, and would not be convinced to run by untrusted instructions, seems reasonable when a trusted application such as `gix` appears to recommend it. The user may then be misled into running an attacker's command.\n\nA minor degradation in availability may also be possible, such as with a very large file named `CON`, though the user could usually interrupt the application.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix-worktree-state"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.11.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gitoxide"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.36.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix-worktree"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.34.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gitoxide-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.38.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.63.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix-ref"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.44.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "gix-index"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.33.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Byron/gitoxide/security/advisories/GHSA-49jc-r788-3fc9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35197"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Byron/gitoxide"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0351.html"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0352.html"
  }, {
    "type" : "WEB",
    "url" : "https://rustsec.org/advisories/RUSTSEC-2024-0353.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-67" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-22T14:13:24Z",
    "nvd_published_at" : "2024-05-23T13:15:09Z"
  }
}