vim-patch:9.2.0845: [security]: arbitrary Ex command execution during C omni-completion

Problem:  [security]: arbitrary Ex command execution during C
          omni-completion (Threonine)
Solution: Match tags typeref literally to block Ex command injection
          (Yasuhiro Matsumoto).

Escaping only "/" and "\" left the typeref able to break out of the
:vimgrep pattern without a "/": an unclosed "[" makes vimgrep's pattern
skipping fail, and the parser then treats a following "|" as a command
separator, so the tag value runs as Ex commands during C omni-completion.
Match the field literally with \V so no regex metacharacter can affect
pattern parsing.

Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-cx73-phcg-3j5g

https://github.com/vim/vim/commit/2f628d8104958fa7421664f792ca6d4f7a39a10f

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
This commit is contained in:
zeertzjqandYasuhiro Matsumoto committed 2026-07-25 06:23:13 +08:00
1 parent a99d0c6810
commit 72b2c713ea
2 files changed
+30 -1

No files matched your search

+4 -1
View File
@@ -555,8 +555,11 @@ func s:StructMembers(typename, items, all)
if complete_check()
return []
endif
" Match "typename" literally (\V): escaping alone is not enough, as e.g.
" an unclosed "[" makes vimgrep's pattern skipping fail and the rest of
" the tag value is then parsed as Ex commands.
exe 'silent! keepj noautocmd '
\ .. n .. 'vimgrep /\t' .. escape(typename, '/\') .. '\(\t\|$\)/j '
\ .. n .. 'vimgrep /\t\V' .. escape(typename, '/\') .. '\m\(\t\|$\)/j '
\ .. fnames
let qflist = getqflist()