{"id":"CVE-2022-41903","published":"2023-01-17T22:17:16Z","modified":"2025-03-10T21:21:50Z","title":"Integer overflow in `git archive`, `git log --format` leading to RCE in git","vendor":"git","product":"git","tier":"tail","description":{"text":"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`.","provenance":"source","from":"CVE.org"},"cvss":{"score":9.8,"severity":"CRITICAL","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.44268,"percentile":0.98788,"provenance":"source"},"cwes":[{"id":"CWE-190","name":"Integer Overflow or Wraparound"}],"references":[{"url":"https://github.com/git/git/security/advisories/GHSA-475x-2q3q-hvwq","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76","tags":["x_refsource_MISC"]},{"url":"https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_export_subst","tags":["x_refsource_MISC"]},{"url":"https://git-scm.com/docs/pretty-formats#Documentation/pretty-formats.txt-emltltNgttruncltruncmtruncem","tags":["x_refsource_MISC"]},{"url":"https://security.gentoo.org/glsa/202312-15","tags":[]}],"priority":{"score":31.6,"factors":[{"name":"EPSS percentile","points":19.76},{"name":"Public exploit code","points":5.0},{"name":"CVSS severity","points":6.86}]},"exploitSources":{"pocGithub":{"count":1,"skipped":0,"earliest":"2023-01-26","earliestUrl":"https://github.com/sondermc/git-cveissues","repos":[{"name":"sondermc/git-cveissues","url":"https://github.com/sondermc/git-cveissues","stars":0,"created":"2023-01-26"}]},"first":{"date":"2023-01-26","source":"PoC-in-GitHub","url":"https://github.com/sondermc/git-cveissues"},"provenance":"source"},"vendorSlug":"git","affectedVersions":[{"vendor":"git","product":"git","versions":["< 2.30.7",">= 2.31.0, < 2.31.6",">= 2.32.0, < 2.32.5",">= 2.33.0, < 2.33.6",">= 2.34.0, < 2.34.6",">= 2.35.0, < 2.35.6",">= 2.36.0, < 2.36.4",">= 2.37.0, < 2.37.5",">= 2.38.0, < 2.38.3","= 2.39.0"]}],"ssvc":{"exploitation":"none","automatable":"yes","technicalImpact":"total","timestamp":"2025-03-10T20:59:12.527761Z","from":"CISA ADP","provenance":"source"},"summary":{"text":"An integer overflow in git's commit formatting code, in pretty.c's format_and_pad_commit() function, stores a size_t as an int and uses it as a memcpy() offset, affecting the git product's git log --format and git archive export-subst handling. An attacker who can get a user to run a commit-formatting command, such as git log --format=..., or to run git archive on a repository containing crafted export-subst content, can trigger arbitrary heap writes that may lead to arbitrary code execution, with no authentication required for the network-reachable case.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T06:29:59Z"},"euvd":{"id":"EUVD-2022-45041","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-git-cve-2018-17456","parents":[{"from":"CVE-2018-17456","to":"CVE-2022-41903","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["fsck.c"],"commits":["https://github.com/git/git/commit/1a7fd1fb2998002da6e9ff2ee46e1bdd25ee8404","https://github.com/git/git/commit/a124133e1e6ab5c7a9fef6d0e6bcb084e3455b46","https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76"],"basis":"shared function","functions":["fsck_gitmodules_fn"]}]},{"from":"CVE-2021-21300","to":"CVE-2022-41903","relation":"related","confidence":"medium","kind":"lineage","evidence":[{"kind":"same-code","provenance":"machine","files":["git-compat-util.h"],"commits":["https://github.com/git/git/commit/684dd4c2b414bcf648505e74498a608f28de4592","https://github.com/git/git/commit/508386c6c5857b4faa2c3e491f422c98cc69ae76"],"basis":"rarely changed file"}]}]}}