CVE-2022-41903
Integer overflow in `git archive`, `git log --format` leading to RCE in git
Reported by github_m · Published January 17, 2023
Git is distributed revision control system. `git log` can display commits in an arbitrary format using its `--format` specifiers. This functionality is also exposed to `git archive` via the `export-subst` gitattribute. When processing the padding operators, there is a integer overflow in `pretty.c::format_and_pad_commit()` where a `size_t` is stored improperly as an `int`, and then added as an offset to a `memcpy()`. This overflow can be triggered directly by a user running a command which invokes the commit formatting machinery (e.g., `git log --format=...`). It may also be triggered indirectly through git archive via the export-subst mechanism, which expands format specifiers inside of files within the repository during a git archive. This integer overflow can result in arbitrary heap writes, which may result in arbitrary 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. Users who are unable to upgrade should disable `git archive` in untrusted repositories. If you expose git archive via `git daemon`, disable it by running `git config --global daemon.uploadArch false`.
Fixed versions
Upgrade to a fixed version or later. Language registries are listed first, then Linux distributions, then vendor products.
| Package | Ecosystem | Fixed in |
|---|---|---|
| git-p4 | Amazon Linux | 2.39.1-1.amzn2.0.1 |
| git | Alpine | 2.39.1-r0, 2.38.3-r0, 2.36.4-r0, 2.34.6-r0, 2.32.5-r0 |
| git-core-doc | Amazon Linux | 2.39.1-1.amzn2.0.1 |
| git-svn | Amazon Linux | 2.39.1-1.amzn2023.0.2, 2.39.1-1.amzn2.0.1 |
| git-email | Amazon Linux | 2.39.1-1.amzn2.0.1 |
| git | Wolfi | 2.39.1-r0 |
Risk scores
Affected products
| Vendor | Product | Versions |
|---|---|---|
| git | git | < 2.30.7, >= 2.31.0, < 2.31.6, >= 2.32.0, < 2.32.5 |
| amazon:2 | git-p4 | 0 |
| alpine | git | 0, 0, 0 |
| amazon:2 | git-core-doc | 0 |
| amazon:2023 | git-svn | 0 |
| amazon:2 | git-email | 0 |
| amazon:2 | git-svn | 0 |
| wolfi | git | 0 |
| git | git | 0, 2.39.0, 2.34.0 |
| amazon:2023 | perl-Git | 0 |
| chainguard | git | 0 |
| amazon:2023 | perl-Git-SVN | 0 |
| amazon:2023 | gitweb | 0 |
| amazon:2023 | git-subtree | 0 |
| amazon:2 | perl-Git-SVN | 0 |
| amazon:2 | git-credential-libsecret | 0 |
| amazon:2023 | git-core-doc | 0 |
| amazon:2 | git-gui | 0 |
| amazon:2 | git-cvs | 0 |
| amazon:2023 | git-p4 | 0 |
…and 20 more
Timeline
- Jan 17, 2023 CVE Published
- Jan 18, 2023 EPSS Score (30 in total, the first dated here)
- Mar 10, 2025 CVE Updated
- Mar 17, 2026 Security Advisory (35 in total, the first dated here)
- Jun 15, 2026 Coalition ESS Score
- Aug 11, 2026 Distribution Patch (33 in total, the first dated here)
Query this with the API
The same record, from the CLI:
vulnetix vdb vuln CVE-2022-41903
vulnetix vdb fixes CVE-2022-41903
Or with curl, using the org id and key from your account page:
curl -s -H "Authorization: ApiKey ${VULNETIX_ORG_ID}:${VULNETIX_API_KEY}" \
"https://api.vdb.vulnetix.com/v2/vuln/CVE-2022-41903/fixes/registry"
The Community plan is free and allows 50 queries a day. Get a free API key · API quickstart
References
- https://github.com/git/git/security/advisories/GHSA-475x-2q3q-hvwq x_refsource_CONFIRM
- https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76 x_refsource_MISC
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_export_subst x_refsource_MISC
- https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emltltNgttruncltruncmtruncem x_refsource_MISC