CVE-2026-28422 Overview
CVE-2026-28422 is a stack buffer overflow vulnerability in Vim, the open source command line text editor. The vulnerability exists in the build_stl_str_hl() function, which is responsible for rendering the statusline. When a statusline is configured with a multi-byte fill character and displayed on a very wide terminal, a stack buffer overflow can occur. The issue has been addressed in Vim version 9.2.0078.
Critical Impact
Local attackers with limited privileges could potentially exploit this vulnerability to cause memory corruption when specific statusline configurations are used on wide terminals, potentially leading to integrity violations.
Affected Products
- Vim versions prior to 9.2.0078
- All platforms running vulnerable Vim versions
Discovery Timeline
- 2026-02-27 - CVE-2026-28422 published to NVD
- 2026-03-04 - Last updated in NVD database
Technical Details for CVE-2026-28422
Vulnerability Analysis
This vulnerability is classified as CWE-121 (Stack-based Buffer Overflow). The flaw resides in the build_stl_str_hl() function within Vim's buffer handling code. When rendering a statusline with a multi-byte fill character on an exceptionally wide terminal, the code fails to properly account for the byte length of multi-byte characters when calculating the required buffer space.
The vulnerable code path is triggered during statusline rendering operations, where the buffer allocation calculation uses a single-byte assumption for the fill character width. When a multi-byte fill character is used (such as Unicode characters that require multiple bytes to represent), the buffer allocated may be insufficient to hold the expanded output, resulting in a stack buffer overflow.
Root Cause
The root cause stems from an incorrect buffer size calculation in the conditional check within build_stl_str_hl(). The original code calculated the required space using a direct width difference without accounting for multi-byte character encoding. Specifically, when computing whether there is sufficient space in the output buffer, the code failed to multiply the fill width by MB_CHAR2LEN(fillchar) to properly determine the actual byte count needed for multi-byte fill characters.
Attack Vector
Exploitation requires local access to the system with the ability to configure Vim's statusline settings and control the terminal width. An attacker would need to:
- Configure a Vim statusline that uses a multi-byte fill character
- Launch Vim in a terminal configured with an exceptionally wide display
- Trigger the statusline rendering to cause the overflow
The attack complexity is high as it requires specific environmental conditions and user interaction. The vulnerability requires low privileges and user interaction to exploit.
The following patch from the GitHub Commit shows how the vulnerability was fixed:
}
width = maxwidth;
}
- else if (width < maxwidth && outputlen + maxwidth - width + 1 < outlen)
+ else if (width < maxwidth &&
+ outputlen + (maxwidth - width) * MB_CHAR2LEN(fillchar) + 1 < outlen)
{
// Find how many separators there are, which we will use when
// figuring out how many groups there are.
Source: GitHub Commit
The fix multiplies the fill width by MB_CHAR2LEN(fillchar) to correctly calculate the byte count needed for multi-byte characters.
Detection Methods for CVE-2026-28422
Indicators of Compromise
- Unexpected Vim crashes or segmentation faults during statusline rendering
- Abnormal memory access patterns when using Vim with wide terminals
- Core dumps or crash logs indicating stack corruption in build_stl_str_hl()
Detection Strategies
- Monitor for Vim process crashes with stack corruption signatures
- Implement file integrity monitoring to detect unauthorized Vim binary modifications
- Audit Vim configurations for unusual statusline settings with multi-byte characters
- Deploy endpoint detection to identify anomalous memory access patterns
Monitoring Recommendations
- Enable crash reporting and analyze core dumps for affected Vim processes
- Monitor system logs for repeated Vim crashes under specific terminal conditions
- Track Vim version inventory across systems to identify vulnerable installations
How to Mitigate CVE-2026-28422
Immediate Actions Required
- Update Vim to version 9.2.0078 or later immediately
- Review and audit statusline configurations in Vim setup files
- Avoid using multi-byte fill characters in statuslines until patched
- Consider restricting terminal width if immediate patching is not possible
Patch Information
Vim has released version 9.2.0078 that addresses this vulnerability. The patch modifies the buffer size calculation in build_stl_str_hl() to properly account for multi-byte fill characters.
Patch resources:
Workarounds
- Remove or replace multi-byte fill characters in statusline configurations with single-byte ASCII characters
- Limit terminal width to prevent triggering the overflow condition
- Use alternative text editors until patching is complete for sensitive operations
# Check current Vim version
vim --version | head -1
# Update Vim on Debian/Ubuntu systems
sudo apt-get update && sudo apt-get install vim
# Update Vim on RHEL/CentOS systems
sudo yum update vim
# Verify updated version
vim --version | head -1
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


