CVE-2026-47162 in netrw

A directory name that runs code in your editor, one session later

CVSS 8.8 High (NVD) Confirmed on Neovim v0.12.5 and the VS Code Neovim extension

Protect yourself on Neovim v0.12.5

The fix is on Neovim's release-0.12 branch but not in a release yet. Until it ships, install the fixed netrw file yourself.

  1. Download the patched netrw.vim into your config. Neovim loads it in place of the bundled copy.

    mkdir -p ~/.config/nvim/autoload && curl -fsSL https://raw.githubusercontent.com/neovim/neovim/release-0.12/runtime/pack/dist/opt/netrw/autoload/netrw.vim -o ~/.config/nvim/autoload/netrw.vim
  2. Delete your netrw history, which may already hold a planted payload.

    rm -f ~/.local/state/nvim/netrw/.netrwhist

Tested against stock v0.12.5: the chain no longer fires and netrw works normally. Remove ~/.config/nvim/autoload/netrw.vim once you upgrade to a fixed release.

1Browse in and nothing happens; the next nvim . runs the payload
2Vulnerable vs. patched (vim 9.2.0495)
3Also works in VS Code (vscode-neovim)

The bug

Attack chainAttacker repo, git clone, session 1 browse, netrw writes .netrwhist, then in a later session netrw sources it and runs call system as the victim.1 Attacker repocrafted directory name2 git clonevictim clones it3 Session 1: nvim .browse into the directory4 netrw writes .netrwhistunescaped path saved to disk5 Session 2: open a directorynetrw sources .netrwhist6 call system(...)runs as the victimlater, new sessionpersistence point Attack chain1 Attacker repocrafted directory name2 git clonevictim clones it3 Session 1: nvim .browse into the directory4 netrw writes .netrwhistunescaped path saved to disk5 Session 2: open a directorynetrw sources .netrwhist6 call system(...)runs as the victimlater, new sessionpersistence point

The same chain fires through vscode-neovim.

The crafted directory name

assets'|call system('id>PWNED.txt')|let x='

What netrw writes to .netrwhist, with the injected part highlighted

let g:netrw_dirhist_1='/home/victim/totally-normal-project/assets'|call system('id>PWNED.txt')|let x=''

The vulnerable line and the fix in s:NetrwBookHistSave()

- call setline(lastline,'let g:netrw_dirhist_'.cnt."='".g:netrw_dirhist_{cnt}."'")+ call setline(lastline,'let g:netrw_dirhist_'.cnt."=".string(g:netrw_dirhist_{cnt}))

Fixed in vim 9.2.0495, still in Neovim v0.12.5. It needs two directory-browse actions.