On Di, 03 Okt 2017, Ben Fritz wrote:

> On Wednesday, September 27, 2017 at 8:59:18 AM UTC-5,
> [email protected] 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, Dor Azouri
> 
> This is exactly one of the reasons why one should use "sudoedit" and
> not "sudo vim" to change system files.
> 
> Using "sudoedit" instead of "sudo vim" lets you run Vim as a
> non-elevated user to write a temp file, and when Vim exits the temp
> file will be written over the file you were editing.
> 
> To use you need to set the EDITOR environment variable appropriately.
> I'm not sure whether VISUAL will also work.

While this is true, I wonder if Vim can't do better. It could skip 
loading plugins whose owner is different from the current process owner. 
And at the same time also disable modelines.

Christian
-- 
Wer sagt: hier herrscht Freiheit, der lügt, denn Freiheit herrscht
nicht.
                -- Erich Fried

-- 
-- 
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.

Raspunde prin e-mail lui