CVE-2022-23521: gitattributes parsing integer overflow in git

Published Jan 17, 2023
·
Updated

A flaw was found in Git, a distributed revision control system. When parsing gitattributes, a mechanism to allow defining attributes for paths, multiple integer overflows can occur when there is a huge number of path patterns, attributes for a single pattern, or declared attribute names. These overflows can be triggered via a crafted .gitattributes file that may be part of the commit history. Git silently splits lines longer than 2KB when parsing gitattributes from a file, but not when parsing them from the index. Consequentially, the failure mode depends on whether the file exists in the working tree, the index, or both. This integer overflow can result in arbitrary heap reads and writes, which may allow remote code execution.

Other sources

Git is distributed revision control system. gitattributes are a mechanism to allow defining attributes for paths. These attributes can be defined by adding a .gitattributes file to the repository, which contains a set of file patterns and the attributes that should be set for paths matching this pattern. When parsing gitattributes, multiple integer overflows can occur when there is a huge number of path patterns, a huge number of attributes for a single pattern, or when the declared attribute names are huge. These overflows can be triggered via a crafted .gitattributes file that may be part of the commit history. Git silently splits lines longer than 2KB when parsing gitattributes from a file, but not when parsing them from the index. Consequentially, the failure mode depends on whether the file exists in the working tree, the index or both. This integer overflow can result in arbitrary heap reads and writes, which may result in remote code execution. The problem has been patched in the versions published on 2023-01-17, going back to v2.30.7. Users are advised to upgrade. There are no known workarounds for this issue.

gitattributes are a mechanism to allow defining attributes for paths. These attributes can be defined by adding a .gitattributes file to the repository, which contains a set of file patterns and the attributes that should be set for paths matching this pattern.

GitLab

Affected Software

19 affected componentsFixes available
redhat/git<0:1.8.3.1-24.el7_9
0:1.8.3.1-24.el7_9
redhat/git<0:2.31.1-3.el8_7
0:2.31.1-3.el8_7
redhat/git<0:2.18.4-2.el8_1
0:2.18.4-2.el8_1
redhat/git<0:2.18.4-3.el8_2
0:2.18.4-3.el8_2
redhat/git<0:2.27.0-3.el8_4
0:2.27.0-3.el8_4
redhat/git<0:2.31.1-3.el8_6
0:2.31.1-3.el8_6
redhat/git<0:2.31.1-3.el9_1
0:2.31.1-3.el9_1
redhat/git<0:2.31.1-3.el9_0
0:2.31.1-3.el9_0
redhat/rh-git227-git<0:2.27.0-4.el7
0:2.27.0-4.el7
git-scm Git<=2.30.6
git-scm Git>=2.31.0<=2.31.5
git-scm Git>=2.32.0<=2.32.4
git-scm Git>=2.33.0<=2.33.5
git-scm Git>=2.34.0<=2.34.5
git-scm Git>=2.35.0<=2.35.5
git-scm Git>=2.36.0<=2.36.3
git-scm Git>=2.37.0<=2.37.4
git-scm Git>=2.38.0<=2.38.2
git-scm Git=2.39.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:1.8.3.1-24.el7_9
  2. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.31.1-3.el8_7
  3. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.18.4-2.el8_1
  4. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.18.4-3.el8_2
  5. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.27.0-3.el8_4
  6. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.31.1-3.el8_6
  7. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.31.1-3.el9_1
  8. Upgrade

    Upgrade redhat/git to a version that resolves this vulnerability.

    Fixed in 0:2.31.1-3.el9_0
  9. Upgrade

    Upgrade redhat/rh-git227-git to a version that resolves this vulnerability.

    Fixed in 0:2.27.0-4.el7
  10. Upgrade

    Upgrade git/git to a version that resolves this vulnerability.

    Fixed in 2.30.7
  11. Upgrade

    Upgrade git/git to a version that resolves this vulnerability.

    Fixed in 2.30.7Patch GHSA-c738-c5qq-xg89
  12. Upgrade

    Upgrade git/git to a version that resolves this vulnerability.

    Fixed in 2.30.7Patch 508386c6c5857b4faa2c3e491f422c98cc69ae76
  13. Upgrade

    Upgrade gitlab/gitlab to a version that resolves this vulnerability.

    Fixed in 15.5.9
  14. Upgrade

    Upgrade gitlab/gitlab to a version that resolves this vulnerability.

    Fixed in 15.6.6
  15. Upgrade

    Upgrade gitlab/gitlab to a version that resolves this vulnerability.

    Fixed in 15.7.5

Event History

Jan 17, 2023
CVE Published
12:00 AM
Data Sourced
via GitLab·12:00 AM
Description
CVE Published
via MITRE·10:17 PM
Data Sourced
via MITRE·10:17 PM
DescriptionSeverityWeakness
Jan 18, 2023
Data Sourced
via Red Hat·05:01 PM
DescriptionSeverityAffected Software

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

What is Git?

Git is a distributed revision control system.

2

What are gitattributes?

gitattributes are a mechanism to allow defining attributes for paths in Git repositories.

3

What is the vulnerability ID?

The vulnerability ID is CVE-2022-23521.

4

What is the severity of CVE-2022-23521?

The severity of CVE-2022-23521 is critical with a CVSS score of 9.8.

5

How can I fix the vulnerability CVE-2022-23521?

To fix the vulnerability, update Git to version 2.39.0 or apply the appropriate patches provided by your vendor.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203