VYPR
Unrated severityNVD Advisory· Published Aug 17, 2022· Updated Aug 3, 2024

Improper Validation of Specified Quantity in Input in vim/vim

CVE-2022-2845

Description

Vim before 9.0.0218 fails to validate a column number in display_dollar, leading to a read before the start of a line.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Vim before 9.0.0218 fails to validate a column number in display_dollar, leading to a read before the start of a line.

Vulnerability

The vulnerability resides in the display_dollar function in edit.c of Vim prior to version 9.0.0218. The function accepts a col parameter of type colnr_T and uses it directly to access the current line, without first checking whether the value is negative. This missing validation means that if a caller passes a negative column number, the function can read memory before the start of the line buffer. The issue was introduced through an incomplete refactor or coding error [1].

Exploitation

An attacker who can supply crafted input that triggers display_dollar with a negative column value can exploit this flaw. According to the reference, the test case Test_cmdwin_virtual_edit triggers the condition by setting 'virtualedit' to all and using a command-line window operation (normal q/s), which causes the negative column to be passed. No special privileges beyond normal Vim editing capabilities are required, but the attacker must be able to open a file and execute commands that lead to the vulnerable code path [1].

Impact

Successful exploitation results in an out-of-bounds read from memory preceding the start of the line buffer. This can lead to information disclosure (reading adjacent or unrelated memory) or a crash (denial of service). In some configurations, this may be leveraged for further exploitation, though the primary impact is a denial of service or leak of sensitive data [1].

Mitigation

A fix was introduced in Vim version 9.0.0218, released on 2022-08-17. The patch in commit e98c88c44c308edaea5994b8ad4363e65030968c adds a bounds check: col = col_arg < 0 ? 0 : col_arg; to ensure the column number is non-negative. Users should upgrade to Vim 9.0.0218 or later. For users of Gentoo Linux, the advisory GLSA 202305-16 (referenced in [4]) provides updates to versions 9.0.1157 for Vim, gVim, and vim-core. No workaround is available for unpatched versions [1][4].

AI Insight generated on May 27, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

39

Patches

0

No patches discovered yet.

Vulnerability mechanics

Root cause

"Missing validation of a negative column argument in `display_dollar` allows reading before the start of the line buffer."

Attack vector

An attacker can trigger this vulnerability by crafting input that causes Vim to call `display_dollar` with a negative column value. The proof-of-concept test in the patch uses `set ve=all cpo+=$` followed by `silent normal q/s` to reproduce the issue [ref_id=1]. This causes reading before the start of the line, which may lead to information disclosure or a crash.

Affected code

The vulnerability is in the `display_dollar` function in Vim's source code. The function accepts a `colnr_T col` parameter that can be negative, and it uses this value directly without validation, leading to out-of-bounds memory access. The patch renames the parameter to `col_arg` and adds a guard: `colnr_T col = col_arg

What the fix does

The patch adds a bounds check at the start of `display_dollar`: if the column argument is negative, it is clamped to 0. This prevents the function from reading memory before the beginning of the line buffer. The patch also renames the parameter from `col` to `col_arg` to avoid shadowing the local variable `col` that now holds the clamped value [ref_id=1].

Preconditions

  • inputThe user must open a file or input that triggers the vulnerable code path in Vim
  • configThe 'virtualedit' option must be set to 'all' and 'cpoptions' must include '$'

Reproduction

Run the following in Vim: `:enew!`, `:set ve=all cpo+=$`, `:silent normal q/s`. This triggers the out-of-bounds read in `display_dollar` [ref_id=1].

Generated on May 28, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.