Bug 144187

Summary: CAN-2004-1138 vim arbitrary command execution vulnerability
Product: Red Hat Enterprise Linux 4 Reporter: Josh Bressers <bressers>
Component: vimAssignee: Karsten Hopp <karsten>
Status: CLOSED ERRATA QA Contact: David Lawrence <dkl>
Severity: low Docs Contact:
Priority: medium    
Version: 4.0CC: security-response-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=low,embargo=20041215:14
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-02-15 09:36:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 142822    

Description Josh Bressers 2005-01-04 22:28:19 UTC
*** This bug has been split off bug 142444 ***

------- Original comment by Josh Bressers (Security Response Team) on 2004.12.09
14:10 -------

This was reported by gentoo to vendor-sec

Ciaran McCreesh, our Gentoo vim maintainer, found and reported upstream
several modeline-related vulnerabilities in vim :

------------------------------------------------------------
It's possible to do some pretty nasty stuff via vim modelines despite
the existing security code.

For example, by passing evil values for a fileformat setting in a
modeline, it's possible to make vim source arbitrary scripts upon
startup. This would hurt on a multiuser system. Here's one way:

User 'fred' creates a file in /home/fred/evil.vim containing lots of
nastiness (for example, "system('echo alias vim=emacs >> ~/.bashrc') |
quit"). He then creates a file in some shared location with a modeline
which does something like"set ft=../../../*fred/evil". User 'joe', who
has ftplugins and modelines enabled, edits this file. This results in a
call of ":runtime!../../../*fred/evil" , which (assuming ~/.vim is in
runtimepath) expands to ~/.vim/../../../*fred/evil which matches
/home/fred/evil.vim.
------------------------------------------------------------

Bram Moolenaar provided the following vim patch, that fixes the reported
vulnerabilities and adds more conservative modeline rights :

------------------------------------------------------------
Patch 6.3.045
Problem:   Unusual characters in an option value may cause unexpected
           behavior, especially for a modeline. (Ciaran McCreesh)
Solution:  Don't allow setting termcap options or 'printdevice' or
           'titleold' in a modeline.  Don't list options for "termcap"
           and "all" in a modeline.  Don't allow unusual characters in
           'filetype', 'syntax', 'backupext', 'keymap', 'patchmode' and
           'langmenu'.
Files:     src/option.c, runtime/doc/options.txt



This issue also affects RHEL2.1

I'll include patches when I have them.

Comment 1 Karsten Hopp 2005-01-10 15:11:14 UTC
vim-6.3.046-0.40E.1 has been built in RHEL4-errata-candidate, see 
RHSA-2005:036-02 

Comment 2 Mark J. Cox 2005-02-15 09:36:18 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2005-036.html