Sign up ×
Information Security Stack Exchange is a question and answer site for information security professionals. It's 100% free, no registration required.

I use vim and have a use case for modelines. A modeline means that vim will parse a textfile for lines like:

# vim: set someoption=somevalue

and will then set those options. This is awesome if I'm the person writing the modelines, but it also might break down the assumption that I can open untrusted text files with my text editor with no harm.

Assume that I'm running an updated version of vim. Assume that I don't mind if someone can set annoying options that make things look bad (eg, messing with the tabwidth). What could a malicious text file do?


share|improve this question

2 Answers 2

up vote 2 down vote accepted

Ideally not a lot, but in practice it's not as ideal as the ideal would suggest.

Just search for vim modeline vulnerability for a few examples of how this has gone wrong in the past. This is part of why modeline support is by default disabled if you're running vim as root.

share|improve this answer
-1. I found this answer via a Google search for "vim modeline vulnerability", and it simply recommends a Google search for the same term. Stack Exchange answers should be answers, and not just recommendations of searches someone could easily do. – Scott Severance Apr 5 at 23:41

Vim modelines have in the past had arbitrary code execution bugs.
So they could do a lot of harm in the past.

First noticed in 6.3, fixed, some similar vulns found later.

Since the risk is inherent, (mixing data and code), modelines are generally disabled for root.

The way I understand it, previous bugs were fixed, so except for unpublished issues, using modern Vim it is safe to open un-trusted files with modelines on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.