Dor Azouri wrote: > 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,
In my opinion, if a user can use "sudo" he can do anything. He could also edit /root/.bashrc for example, and put any command there. I don't know what you mean with "non-elevated mode", sudo always results in an elevated mode with more permissions. And you can also do "sudo -i" or "sudo bash". I don't see how this is related to Vim. -- Your mouse has moved. Windows must be restarted for the change to take effect. Reboot now? /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- 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.
