Git CVE-2026-105437: An attribute from .gitattributes overflows Gitaly's merge buffer
When Git merges two versions of a file, it first works out how large the result will be, allocates exactly that much memory and then writes the result into it. That total used to live in a signed 32-bit integer, and one of its addends comes straight from the repository: the length of the conflict markers that a committed .gitattributes sets through conflict-marker-size. A few conflicts with huge markers push the total past four gibibytes, it wraps to a small value, and Git writes attacker data far beyond the end of a buffer that is too small. This turns dangerous wherever a server checks on its own, for every merge request, whether two branches can be merged. Gitaly does exactly that inside GitLab, which is why GitLab rates CVE-2026-105437 as critical.
TL;DR — 90 seconds
- What: Git's three-way merge code (xdiff) computed the size of the merge result in a 32-bit
int. Because theconflict-marker-sizeattribute accepts any positive number and enters that total several times per conflict, the total overflows and Git writes past the end of a heap buffer that is too small. - Severity: GitLab as CNA assigns CVSS 7.5 (
AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H), and rates the flaw as critical for its own platform. It is not in the CISA KEV catalog. A public proof of concept that crashes Git has been circulating since 11 November, but it does not demonstrate code execution. - Who is affected: Mainly Git servers that check merges server-side and read attributes from the repository while doing so. Gitaly sets
attr.tree=HEADfor this, and GitLab is affected from version 16.2. Locally, anyone who merges, rebases or cherry-picks foreign content is affected. - What to do: Upgrade GitLab to 19.5.4, 19.4.6 or 19.3.8, and Git to 2.56.1 or one of the maintenance releases 2.55.1, 2.54.1, 2.53.1, 2.52.1, 2.51.3 and 2.50.2. Gitaly ships its own Git, so updating the host package changes nothing there.
- What would have protected you beforehand: a global server hook that rejects pushes with oversized conflict markers, an instance where strangers cannot create their own projects, and Gitaly nodes with tightly limited network paths. The advisory's workaround via
info/attributesdoes not hold in GitLab, because Gitaly deletes that file during housekeeping.
A 32-bit total and an attribute without an upper bound
In a three-way merge Git compares two versions of a file with their common ancestor. Where both sides changed the same spot differently, a conflict arises, and Git writes both versions into the result between marker lines: <<<<<<< before our side, ======= as separator and >>>>>>> after their side, plus ||||||| before the ancestor in diff3 style. By default these markers are seven characters long. The conflict-marker-size attribute changes the length per path, so that files which contain such sequences themselves get unambiguous markers. The documentation only says that a positive integer has a meaningful effect and gives 32 as an example. In the code, ll_merge_marker_size() in merge-ll.c parses the value as an int and falls back to seven only for zero, negative or invalid values. There is no upper bound.
The result buffer is filled by xdl_fill_merge_buffer() in xdiff/xmerge.c, in two passes. In the first call the destination is NULL and the function only counts how many bytes will be produced. Then xdl_do_merge() allocates exactly that much memory, and in the second call the same logic writes the result piece by piece to the position dest + size. For every conflict, fill_conflict_hunk() adds the marker length plus line ending and the name of the respective side three or four times. All of these intermediate values were int, so only 32 bits wide even on 64-bit systems. According to the fix's commit message the total can overflow for two reasons: because a value from .gitattributes enters it several times per conflict, and because diff3 output of large files can exceed INT_MAX anyway.
This is where the bug lived. The developers describe both ways the total can wrap. If it ends up negative, malloc() sees a huge number after conversion to size_t and fails, which only causes a spurious error. If it wraps back to a small positive value, malloc() returns a buffer that is far too small. Because each single addend is below 231, the running write position passes through negative values on its way there during the second pass. The writes therefore first run past the end of the buffer and then land before its start. What gets written is marker characters and the lines of the conflicting files, so largely content the attacker chooses. The advisory also stresses that the pushed data stays small, because the oversized output only appears during the merge. Push size limits therefore do not help.
That leaves the question of where Git takes the attribute from. In a working tree it reads .gitattributes from the checked-out state, so anyone who merges a foreign branch locally inherits that state's attributes. A bare repository on a server has no working tree and reads no committed attributes by default. The exception is Git 2.43.0 to 2.45.2, which read attributes from HEAD in bare repositories by default until commit 51441e6 reverted that in 2.45.3 and 2.46.0 because of performance problems. Forges set the source explicitly. According to its source code in internal/git/gitcmd/command_factory.go, Gitaly adds attr.tree=HEAD to the commands diff, merge, merge-tree, check-attr, archive, log, format-patch and worktree. In GitLab, the .gitattributes on a project's default branch therefore decides the marker length for every merge check in that project.
What the fix changes
The fix consists of two commits by Kaartic Sivaraam based on a patch by Jeff King, 288266c and b131387, plus a helper macro st_add5() in git-compat-util.h. The first commit switches xdl_recs_copy_0(), fill_conflict_hunk() and xdl_fill_merge_buffer() from int to size_t. The running total can no longer go negative and on 64-bit systems can practically no longer wrap. In addition, xdl_do_merge() now checks whether the result fits into a long, because the size is subsequently stored in a structure with that type. On Windows long is only 32 bits wide, and there the merge now fails with an error instead of silently truncating the result.
The second commit closes two holes the first one left open. The addends of a marker, for example marker_size + 1 + needs_cr + marker1_size, were still summed as int before being added to the total, and with values close to INT_MAX they could turn negative and shrink the total. On 32-bit platforms size_t itself can also wrap. Git now adds each addend separately with st_add() and its variants, which abort with size_t overflow on overflow. This check sits only in the first, counting pass, because the second pass replays the same arithmetic and relies on its result.
What this reveals about the root cause is instructive. Even after the fix the attribute accepts any positive number, and the developers did not introduce an upper bound. The arithmetic is fixed, not the input. The actual flaw lay in the two-pass design, where counting and writing must match exactly and the counting pass used a type narrower than the values it had to represent. The new tests in t/t4300-merge-tree.sh call git merge-tree --write-tree, also with --name-only. So even a caller that only wants the names of conflicting files goes through the buffer calculation. Git closed the same class of bug in the same release with CVE-2026-111760, where it was a path length in a 32-bit index field.
From your own project to the Git process in Gitaly
An attack needs two things: a textual three-way merge on a path with the attribute, and an attribute source the attacker controls. Locally this is quickly met when you merge, rebase or cherry-pick a foreign branch with conflicts into your working tree, because the attributes of the state you are processing apply. That is the user interaction the CVSS vector refers to. A self-hosted Git server with bare repositories and Git 2.45.3 or later cannot be reached through committed attributes by default, as long as nobody sets attr.tree, --attr-source or the environment variable GIT_ATTR_SOURCE. Servers running Git 2.43.0 to 2.45.2, on the other hand, read attributes from HEAD by default.
GitLab is a different story. As soon as a merge request is opened or updated, GitLab checks whether it can be merged without conflicts, and for this Gitaly starts git merge-tree with attr.tree=HEAD. According to the advisory, anyone who can push branches and request their merge can trigger the overflow without anyone else doing anything. From the Gitaly code I derive who that is in practice: the attributes come from the default branch of the project in which the check runs, and anyone allowed to create their own project controls its default branch. On an instance with open registration, a freshly created account is enough. On an internal instance, any account with the right to create projects is enough, including a hijacked one. How quickly stolen developer accounts are abused at scale was shown in mid-November by the wfx-loot campaign on GitHub.
GitLab describes what is possible after the overflow only briefly: under certain conditions arbitrary commands can be executed within the Gitaly environment. The public entry in GitLab's Git tracker confirms that the flaw was extended to code execution through the Git process Gitaly starts for the mergeability check, but gives no details. The damage follows from Gitaly's role. The service holds all repositories of its storage node and runs as a system user that can read and write them. In my assessment, whoever executes code there reaches the source code of every project on that node and can alter commits or tags in other people's repositories. A heap overflow thus becomes a supply chain problem for every project on the same instance.
You are really affected if you run GitLab 16.2 or later yourself and are not yet on a fixed version, and most of all if external or barely vetted accounts may create their own projects there. Other Git servers that check merges server-side using attributes from the repository are affected as well, as are developers who merge third-party contributions locally. Only seemingly affected are users of GitLab.com and GitLab Dedicated, which GitLab says are already patched, and CI runners and Argo CD as long as they only clone and check out repositories, because no merge happens there. For them the update belongs in the regular maintenance window.
| CVE | Affected | Fix | Precondition | CVSS |
|---|---|---|---|---|
| CVE-2026-105437 (GHSA-m7r7-8v36-j77r) | Git before 2.50.2, 2.51.3, 2.52.1, 2.53.1, 2.54.1, 2.55.1, 2.56.1; GitLab CE/EE from 16.2 before 19.3.8, 19.4 before 19.4.6, 19.5 before 19.5.4 | Git 2.56.1 and maintenance releases; GitLab 19.5.4, 19.4.6, 19.3.8 | Textual three-way merge with conflict-marker-size from a source the attacker controls | 7.5 (high), critical at GitLab |
As of 23 November the flaw is not in the CISA KEV catalog, and there are no reports of attacks. NVD lists a CISA SSVC assessment from 16 November that rates exploitation as “poc”. In fact, a public proof of concept has been circulating since 11 November. It shows a crash of git merge-tree --write-tree as a hosting server runs it and demonstrates the write via AddressSanitizer, but it does not demonstrate code execution. FIRST reports an EPSS score of 0.0053 for 22 November, roughly the 46th percentile. According to GitLab, the flaw was reported by the researcher taise through GitLab's HackerOne program. Together with the new tests in the patch, which show fairly precisely which marker length crosses the limit, the path to a crash is public. Whether someone rebuilds the step to code execution is a question of effort, not knowledge.
GitLab 19.5.4, Git 2.56.1 and the Git inside Gitaly
The Git project released Git 2.56.1 on 10 November and backported the fix to 2.55.1, 2.54.1, 2.53.1, 2.52.1, 2.51.3 and 2.50.2. Older branches get no upstream fix. According to its blog, GitHub has already patched GitHub.com and GitHub Enterprise Cloud and lists versions 3.19.15, 3.20.11, 3.21.9 and 3.22.4 for GitHub Enterprise Server, without explicitly tying them to this flaw in the text.
GitLab shipped versions 19.5.4, 19.4.6 and 19.3.8 as a critical patch release on the same day. All versions from 16.2 are affected, and GitLab.com and Dedicated already run patched code. This is the most important pitfall: Gitaly usually does not use the operating system's Git but its own Git binaries, which according to the Gitaly documentation are embedded into its binary via go:embed at compile time. Updating the distribution package on the Gitaly node changes nothing. According to GitLab, the official Linux packages and container images already contain the patched Git. If you compile GitLab yourself, GitLab says you must update Gitaly and also rebuild the Git that git.bin_path in config/gitlab.yml points to. If that Git comes from your distribution, it needs to be 2.56.1 or a version your distribution has patched for CVE-2026-105437.
For distributions, the status on 23 November is as follows: Amazon Linux fixed git on 12 November for Amazon Linux 2 with ALAS2-2026-4109 and for Amazon Linux 2023 with ALAS2023-2026-3445. Wolfi ships git 2.56.1, so a rebuild of the images is enough. The Debian tracker still lists bookworm, trixie, forky and sid as vulnerable, and there is no DSA yet. On developer machines with Debian's Git, the local override from the next section helps until then.
In everyday use you will not notice the fix. A merge whose result would break the new limits now aborts with size_t overflow or an error instead of corrupting memory. On Windows, merges with results larger than two gibibytes, which used to be silently truncated, now fail. If you install the other fixes of the same release along with this one, check migration scripts that use git fast-import, because some of its features now require --allow-unsafe-features.
Hardening that would have worked before the patch
First it is worth sorting out which measures can work against this mechanism at all. The attack turns an attribute value from the repository into a wrong memory calculation inside a process that runs perfectly normally on the server. Three approaches are therefore effective. The first keeps attacker-controlled attribute values out of the merge. The second limits who can trigger a server-side merge with their own attributes in the first place. The third limits what a hijacked Git process can reach. Classic container hardening only belongs to the third approach, and it does not prevent the memory bug.
A global server hook against oversized conflict markers
Because Gitaly reads attributes from the default branch, the dangerous .gitattributes first has to get into a repository. GitLab Self-Managed supports global server hooks that apply to all repositories. In the Linux package you set the directory via gitaly['configuration'][:hooks][:custom_hooks_dir], and the documentation suggests /var/opt/gitlab/gitaly/custom_hooks; for self-compiled installations it lives in the [hooks] section of the Gitaly configuration. A script in pre-receive.d sees the pushed objects before GitLab updates the references and can reject the push with a non-zero exit code. A simple rule is enough for this case: every new or changed .gitattributes that sets conflict-marker-size to a value above a small limit gets rejected. The documentation shows 32 as a legitimate example, and in my assessment a limit of around 100 costs you nothing.
For the rule to hold, it has to check every line in which the attribute name appears. Git allows macro attributes starting with [attr] in the top-level .gitattributes, and they can bundle the attribute under another name. A hook that only looks at path lines misses this form. The limits of the measure lie elsewhere. It only acts on new pushes, so you have to search existing repositories once, as described in the detection section. Global hooks must be present on every Gitaly node, Geo does not replicate them to secondaries according to the documentation, and any interpreter the script needs has to be installed there. Commits from the Web IDE and via the API pass through the hook as well. According to the Gitaly source code, UserCommitFiles updates the reference through the same hook-aware path, which runs the pre-receive hook including the global scripts from pre-receive.d before every change. GitLab.com does not offer this option, but it does not need it either.
Who may create their own projects on your instance
The attacker needs a project whose default branch they control. The fewer accounts have this ability, the smaller the circle of possible attackers. On instances with partners or customers, the setting “Make new users external by default” under Admin area, Settings, General, “Account and limit” is therefore worth it. According to the documentation, external users cannot create projects, groups or snippets in their personal namespace, though they can in groups where they are members. Open registration without admin approval is hard to justify for an instance with confidential code anyway. The limit of this measure is clear: it shrinks the circle, but does not exclude insiders and hijacked accounts with project rights.
The override in info/attributes and why it disappears in GitLab
The advisory names the line * conflict-marker-size=7 in every repository's info/attributes as a workaround, because according to the gitattributes documentation this file has the highest precedence. It therefore also overrides a committed .gitattributes that Git reads via attr.tree. You can verify the override with git check-attr conflict-marker-size -- <path>, which must then return 7. For a self-hosted Git server with bare repositories and for developer machines it is therefore an effective stopgap. Locally you put the same line into .git/info/attributes before merging a foreign branch. If your server runs Git 2.43.0 to 2.45.2, which reads attributes from HEAD by default, the commit message of 51441e6 names a second route: set attr.tree to the empty tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904, and Git no longer reads committed attributes.
In GitLab the workaround does not hold. Gitaly contains the cleanup function RemoveInfoAttributes in internal/git/housekeeping/clean_stale_data.go, which deletes every info/attributes during repository housekeeping. The code comment explains that since Git 2.43 Gitaly reads from HEAD:.gitattributes and the old file would otherwise take precedence. That very precedence would be the protection here. If you set the override anyway, you lose it at the next housekeeping run at the latest, without anyone noticing. In GitLab, only the update remains.
Separating and fencing in Gitaly
If foreign code does run in the Git process, Gitaly's environment determines the damage. Gitaly belongs on dedicated nodes that run neither Rails nor runners, so that an attacker finds no further secrets of the instance there. Inbound, Rails, Workhorse, GitLab Shell and Praefect if present need access to Gitaly; outbound, as I understand it, the service mainly needs the callbacks to the GitLab API and, if you use repository mirroring or imports, the sources of those mirrors. An egress rule can block everything else, which makes data exfiltration and reverse connections harder. In Kubernetes you implement this with a NetworkPolicy for the Gitaly pods; you will find more on egress rules in the series TYPO3 on Kubernetes under IT-Grundschutz.
A second lever is splitting by trust. GitLab can run several repository storages and picks the location of new projects via weights between 0 and 100. If you put projects of external accounts on their own Gitaly storage, a hijacked Git process there only sees external projects and not the source code of your own platform. The operational effort is real, because moving projects between storages follows the same process as a migration to Gitaly Cluster according to the documentation. Neither helps against the memory bug itself, but both limit how far it reaches.
What does not help here
Gitaly's cgroups limit memory and CPU of the Git processes in order to tame noisy neighbors, as the documentation puts it. They do not apply here, because the attack does not allocate a lot of memory but overwrites a buffer that is too small. A global core.attributesFile or a system-wide attributes file has the lowest precedence and loses against any committed .gitattributes. Push size limits miss, because the data is small. seccomp, dropped capabilities and readOnlyRootFilesystem remain the right call, but are ineffective against the bug, because the overflow happens in the memory of a process that only uses ordinary system calls.
Be careful with image scanners. They usually detect vulnerable packages via package databases and, for Go programs, via the embedded module information. A Git that sits as a file inside the Gitaly binary via go:embed is neither an installed package nor a Go module. In my assessment such a scanner therefore does not see it. A CVE gate may flag a vulnerable GitLab version if it knows GitLab itself, but it will not necessarily find the embedded Git. For Gitaly, rely on the GitLab version and not on the scanner.
Detection and verification
Whether you are affected is first shown by the GitLab version, which you find under /help or in the Admin area. Everything from 16.2 and below 19.3.8, 19.4.6 and 19.5.4 is vulnerable. For self-compiled installations, also check which Git Gitaly actually starts, the bundled one or the one that git.bin_path in config/gitlab.yml points to. On your own Git servers, besides git --version, what matters is whether attr.tree is set, which git config --show-origin --get-all attr.tree shows, and whether Git 2.43.0 to 2.45.2 runs there. On developer machines and in CI images, git --version is enough.
Whether someone has exploited the flaw is harder to say, and neither the advisory nor GitLab names indicators. From the mechanism I derive two hints. The first lies in the repositories: an unusually large value for conflict-marker-size in a .gitattributes on the default branch has no reason to exist in an ordinary project. In a bare repository you find such lines with git grep -n conflict-marker-size HEAD -- '*.gitattributes'. The path pattern also matches .gitattributes files in subdirectories, and because the search looks for the attribute name, it finds macro definitions as well. For an instance, repeat this across all repositories on the Gitaly nodes. Values with more than three digits deserve a close look.
The second hint is in the Gitaly logs. According to its source code, Gitaly logs a failed merge-tree call as an internal error including the exit status. Before the update, a crash of the Git process during a merge check is a warning sign; after the update Git aborts with size_t overflow in this case, which never happens in a normal project. If you suspect an attack, treat the affected Gitaly node as compromised. Preserve the logs, isolate the node, check the repositories of that storage against a backup for unexpected references and commits, rotate the secrets stored on the node, and remove the crafted .gitattributes along with its project.
Recommendation for operators
Act now if you run GitLab 16.2 or later yourself and the instance is not yet on 19.5.4, 19.4.6 or 19.3.8. This applies especially if strangers can register there, partners create their own projects or many accounts exist without a second factor. Install the patch release today and then search the default branches for conspicuous conflict markers. If you run your own Git server with attr.tree or a Git version between 2.43.0 and 2.45.2, set the override in info/attributes right away and schedule the update.
Monitoring is enough if you use GitLab.com or Dedicated, if your own Git servers read no committed attributes by default, or if only your own branches are merged on your machines. The Git update still belongs in the next maintenance window, because the same release closes five further flaws.
Regardless of the individual case, what I say about every flaw applies: patches and updates belong automated. GitLab publishes patch releases regularly, and a critical flaw in Gitaly is exactly the case where an instance should not wait for the next free slot. If Renovate or Dependabot propose new GitLab images, the Helm chart or the package version as a merge request on their own, and the pipeline tests the update against a staging instance, a release like 19.5.4 is a matter of hours instead of weeks. A cooldown period for routine updates protects against compromised releases, and you exempt security updates from it. And if an update requires a mandatory stop on the upgrade path or breaks a migration script, that shows up on the staging instance and not in production. If you update by hand, the holiday season quickly leaves you weeks without a patch, followed by a large batch update across several versions where every error is hard to trace.
Frequently asked questions about CVE-2026-105437
Am I affected if I use GitLab.com?+
No. According to GitLab, GitLab.com and GitLab Dedicated already run patched versions. You should still update your local Git if you merge foreign branches.
Is updating the Git package on the server enough?+
Not for GitLab. Gitaly starts its own embedded Git binaries, which are only patched with GitLab 19.5.4, 19.4.6 or 19.3.8. Only self-compiled installations that use the distribution's Git need 2.56.1 there.
Why doesn't info/attributes help in GitLab?+
Gitaly deletes this file during repository housekeeping, because it reads attributes from HEAD. The override silently disappears. In GitLab, only the update helps.
Does an attacker need to push large amounts of data?+
No. According to the advisory, the pushed data stays small, because the oversized result only appears during the merge. Push size limits therefore do not help.
Conclusion
CVE-2026-105437 is an arithmetic error with a large impact. Git counted the size of a merge result in a type narrower than the values, and one of those values came unchecked from the repository. The most instructive part is where the bug became dangerous. Locally it needs a user who merges foreign branches. On a forge the server does that itself, for anyone who can open a merge request, and with the rights of a service that holds all repositories. The lesson reaches beyond Git: every convenience feature a server runs on its users' data on their behalf turns a local bug into a remote one. If you operate such services, you should know which values from user data flow into memory calculations, and fence the service in as if it would one day execute foreign code.
Sources
- GitHub Advisory GHSA-m7r7-8v36-j77r (CVE-2026-105437)
- NVD: CVE-2026-105437 (incl. CISA SSVC assessment)
- GitLab Git tracker: work item 814
- GitLab Critical Patch Release 19.5.4, 19.4.6, 19.3.8
- Git commit 288266c: xdiff: use size_t for merge buffer size computations
- Git commit b131387: xdiff: check for overflow when computing merge buffer size
- Git commit 51441e6: stop using HEAD for attributes in bare repository by default
- GitHub Blog: Git security vulnerabilities announced
- Gitaly: internal/git/gitcmd/command_factory.go (AttrTreeConfig)
- Gitaly: internal/git/housekeeping/clean_stale_data.go (RemoveInfoAttributes)
- Gitaly: internal/gitaly/hook/updateref/update_with_hooks.go (hooks for operations such as UserCommitFiles)
- Gitaly docs: Git execution environments (bundled Git via go:embed)
- FIRST EPSS: CVE-2026-105437
- Amazon Linux Security Center: CVE-2026-105437
- Debian Security Tracker: CVE-2026-105437
- Wolfi: git.yaml
- Git docs: gitattributes (conflict-marker-size, macro attributes, precedence)
- Git docs: git-config, attr.tree
- GitLab docs: Server hooks
- GitLab docs: External users
- GitLab docs: Repository storage
- GitLab docs: Gitaly cgroups
I check your GitLab instance for vulnerable Git paths, set up server hooks and a clean separation of Gitaly, and automate patch releases all the way to production.
GitLab updates tested on a staging instance, global server hooks against dangerous attributes, Gitaly storages split by trust and network rules for Gitaly nodes.
Platform operations instead of consulting on paper: I continuously check, patch and harden your infrastructure.
About the author

Kai Ole Hartwig
Programming since 2002 – self-taught, set up my own business with KO-Web in 2012. Over 100 projects, with a focus on security, performance, automation and quality. Today freelance: DevSecOps consulting, training and software development.
Newsletter
The week, in one email.
The new advisories and posts, once a week and briefly put in context. You will get a confirmation email first, and opens and clicks are only counted anonymously.
Almost there – please confirm your subscription via the link in the email I have just sent you.
