I would like to report a possible abuse one can perform on Vim's extensibility mechanism, that may lead to privilege escalation.
In short, a malicious actor that can execute code as one of the sudoers (in
non-elevated mode), can write a plugin file to the plugins directory. Then he
needs to wait for that user to invoke the editor in elevated mode - and the
plugin that was written before, will be loaded with the root permissions.
The root cause that enables this abuse is basically incomplete separation
between regular and elevated execution modes of the editor (using "sudo"). I
can suggest possible solutions to this issue, e.g.: applying better permissions
to the plugins directories.
Reproduction steps:
===================
(This example shows how one can execute an external py script, though any other
pure vim script can prove the same)
===================
The following steps can be performed in a non-elevated mode:
1) Write a py script to the plugins directory. Attached is a sample script
that tries to write a stub file to a root protected dir.
2) Place it in ~/.vim/plugin/
If a directory is missing, create it along the directory tree
3) Create a vim script in the same folder (see attached script for example)
Now, each time you open vim, the python script will be executed. If you run it
elevated using sudo, the stub file will be created with root as owner.
I will be happy to provide more information as needed,
Dor Azouri
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
write_root_file.vim
Description: Binary data
try:
f = open("/stub.file", "wb")
f.close()
except IOError as e:
pass
