【新人报道】vim 1-click RCE 的简单分析

2026-04-11 13:111阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

关键连接:

github.com/califio/publications

MADBugs/vim-vs-emacs-vs-claude/vim.md

main

# Vim tabpanel modeline RCE affects Vim < 9.2.0272 ## Summary A two-bug chain in Vim allows arbitrary command execution when a user opens a crafted file. The `tabpanel` option can be set from a modeline without requiring `modelineexpr`, and its expression is later evaluated in the sandbox. That sandbox can be escaped because `autocmd_add()` does not check whether it is running in a secure context, allowing deferred execution outside the sandbox. --- ## Technical Details The issue depends on two flaws: 1. **`tabpanel` is missing `P_MLE`** Unlike `statusline` and `tabline`, `tabpanel` is not marked with the `P_MLE` flag. This allows a modeline to inject `%{...}` expressions even when `modelineexpr` is disabled. 2. **`autocmd_add()` lacks `check_secure()`** Vim evaluates insecure `tabpanel` expressions in the sandbox, but `autocmd_add()` can still register autocommands there. Those autocommands execute later, after the sandbox exits. A modeline can therefore: - force the tab panel visible with `showtabpanel=2` 此文件已被截断。 显示原始文件

CVE编号:CVE-2026-34714

复现构建

git clone <https://github.com/vim/vim.git> git checkout 664701eb7^ ./configure make

值得注意的是直接编译出来的vim如果在src目录运行会因为无夹找到运行时目录进入保护模式,导致复现失败 所以复现需要加上VIMRUNTIME=$(pwd)/runtime ./src/vim运行

效果:

image2439×230 68.6 KB

git show分析

1. autocmd的沙箱/受限模式绕过

image2080×453 54.1 KB

主要补丁是在autocmd.c中添加了两个检查和optiondefs.h中的tabpanel添加了P_MLE标志

image858×440 21.5 KB

image903×765 41.4 KB

跟踪这两个补丁的函数可以看到 他们分别是用来判断当前是否是“受限模式(rvim)”和当前是否处在sandbox

查阅手册后不难知道autocmd本身的作用大概是一个事件管理器,其本身就有命令执行的权限,但却不受到check_secure()和check_restricted()监管,这就导致了第一个漏洞 沙箱逃逸

更加详细的关于autocmd的信息 可以查看

vimcn.github.io

VIM: autocmd

2. tabpanel的P_MLE标签缺失

image2079×381 77.5 KB

在vim中有非常多的这类标签,他们都可以在optiondefs.h中被找到,其中关于P_MLE他所指代的是“能进行表达式求值”的标签,这类标签是可以通过求值表达式%{}来执行代码的

例如

tabpanel=%{GetMyGitBranch()}

这类标签都受到modelineexpr的影响,简单来说 他的作用就是是否允许在模式行 (modeline)中调用有P_MLE 标志的设置

而回头看 tabpanel 他本身是一个能进行表达式求值的函数却没有P_MLE 标志这就导致了modelineexpr这层安全层被击穿

详见:

vimhelp.org

Vim: options.txt

Vim help pages, always up-to-date

3. 入口点 Modeline

Vim的模式行功能,他允许在文件的开头结尾包含配置命令,他正常的用法应该是这样的

/* vim: set tabstop=4 shiftwidth=4 expandtab: */

这个的作用是强制要求四个空格替代tab键

更加详细的用法可以看这个

yyq123.blogspot.com

VIM学习笔记 模式行(Modeline)

程序员对于制表符常常有不同的偏好,有的使用8个空格,而有的则使用4个空格。可以想见,如果使用不同设置的用户操作相同的文件,必将对文本格式造成影响。 如果希望针对特定文件应用特定的设置,那么修改全局性的vimrc配置文件就显得小题大做了;而使用模式行(modeline),则可...

在这里我们只需要知道他为入口点调用

4. 触发

两个漏洞配合起来 就可以看懂文章给出的payload

vim: set showtabpanel=2 tabpanel=%{%autocmd_add([{'event':'SafeStateAgain','pattern':'*','cmd':'!id>/tmp/calif-vim-rce-poc','once':1}])%}:

通过Modeline功能引入有问题的tabpanel,在通过求值表达式+autocmd_add去注册一个SafeStateAgain事件,在通过showtabpanel=2控制标签行强制显示使得存放于tabpanel的表达式被解析 相当精巧 令人赞叹)


大家好)新人来报道了,原本我以为l站的申请可能要费上一些波折,但没想到通过的相当快,特别感谢审核),这篇文章是我昨天研究vim最新rce笔记的整理,想着与其发一个单纯的报道贴不如就用这个作为我在l站的第一个帖子)

也希望各位大佬在今后多多指导,不吝赐教)

网友解答:
--【壹】--:

关键连接:

github.com/califio/publications

MADBugs/vim-vs-emacs-vs-claude/vim.md

main

# Vim tabpanel modeline RCE affects Vim < 9.2.0272 ## Summary A two-bug chain in Vim allows arbitrary command execution when a user opens a crafted file. The `tabpanel` option can be set from a modeline without requiring `modelineexpr`, and its expression is later evaluated in the sandbox. That sandbox can be escaped because `autocmd_add()` does not check whether it is running in a secure context, allowing deferred execution outside the sandbox. --- ## Technical Details The issue depends on two flaws: 1. **`tabpanel` is missing `P_MLE`** Unlike `statusline` and `tabline`, `tabpanel` is not marked with the `P_MLE` flag. This allows a modeline to inject `%{...}` expressions even when `modelineexpr` is disabled. 2. **`autocmd_add()` lacks `check_secure()`** Vim evaluates insecure `tabpanel` expressions in the sandbox, but `autocmd_add()` can still register autocommands there. Those autocommands execute later, after the sandbox exits. A modeline can therefore: - force the tab panel visible with `showtabpanel=2` 此文件已被截断。 显示原始文件

CVE编号:CVE-2026-34714

复现构建

git clone <https://github.com/vim/vim.git> git checkout 664701eb7^ ./configure make

值得注意的是直接编译出来的vim如果在src目录运行会因为无夹找到运行时目录进入保护模式,导致复现失败 所以复现需要加上VIMRUNTIME=$(pwd)/runtime ./src/vim运行

效果:

image2439×230 68.6 KB

git show分析

1. autocmd的沙箱/受限模式绕过

image2080×453 54.1 KB

主要补丁是在autocmd.c中添加了两个检查和optiondefs.h中的tabpanel添加了P_MLE标志

image858×440 21.5 KB

image903×765 41.4 KB

跟踪这两个补丁的函数可以看到 他们分别是用来判断当前是否是“受限模式(rvim)”和当前是否处在sandbox

查阅手册后不难知道autocmd本身的作用大概是一个事件管理器,其本身就有命令执行的权限,但却不受到check_secure()和check_restricted()监管,这就导致了第一个漏洞 沙箱逃逸

更加详细的关于autocmd的信息 可以查看

vimcn.github.io

VIM: autocmd

2. tabpanel的P_MLE标签缺失

image2079×381 77.5 KB

在vim中有非常多的这类标签,他们都可以在optiondefs.h中被找到,其中关于P_MLE他所指代的是“能进行表达式求值”的标签,这类标签是可以通过求值表达式%{}来执行代码的

例如

tabpanel=%{GetMyGitBranch()}

这类标签都受到modelineexpr的影响,简单来说 他的作用就是是否允许在模式行 (modeline)中调用有P_MLE 标志的设置

而回头看 tabpanel 他本身是一个能进行表达式求值的函数却没有P_MLE 标志这就导致了modelineexpr这层安全层被击穿

详见:

vimhelp.org

Vim: options.txt

Vim help pages, always up-to-date

3. 入口点 Modeline

Vim的模式行功能,他允许在文件的开头结尾包含配置命令,他正常的用法应该是这样的

/* vim: set tabstop=4 shiftwidth=4 expandtab: */

这个的作用是强制要求四个空格替代tab键

更加详细的用法可以看这个

yyq123.blogspot.com

VIM学习笔记 模式行(Modeline)

程序员对于制表符常常有不同的偏好,有的使用8个空格,而有的则使用4个空格。可以想见,如果使用不同设置的用户操作相同的文件,必将对文本格式造成影响。 如果希望针对特定文件应用特定的设置,那么修改全局性的vimrc配置文件就显得小题大做了;而使用模式行(modeline),则可...

在这里我们只需要知道他为入口点调用

4. 触发

两个漏洞配合起来 就可以看懂文章给出的payload

vim: set showtabpanel=2 tabpanel=%{%autocmd_add([{'event':'SafeStateAgain','pattern':'*','cmd':'!id>/tmp/calif-vim-rce-poc','once':1}])%}:

通过Modeline功能引入有问题的tabpanel,在通过求值表达式+autocmd_add去注册一个SafeStateAgain事件,在通过showtabpanel=2控制标签行强制显示使得存放于tabpanel的表达式被解析 相当精巧 令人赞叹)


大家好)新人来报道了,原本我以为l站的申请可能要费上一些波折,但没想到通过的相当快,特别感谢审核),这篇文章是我昨天研究vim最新rce笔记的整理,想着与其发一个单纯的报道贴不如就用这个作为我在l站的第一个帖子)

也希望各位大佬在今后多多指导,不吝赐教)