Skip to content

Commit 664701e

Browse files
committed
patch 9.2.0272: [security]: 'tabpanel' can be set in a modeline
Problem: 'tabpanel' can be set in a modeline Solution: Set the P_MLE flag for the 'tabpanel' option, disable autocmd_add()/autocomd_delete() functions in restricted/secure mode. Github Advisory: GHSA-2gmj-rpqf-pxvh Signed-off-by: Christian Brabandt <[email protected]>
1 parent 3c0f800 commit 664701e

5 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/autocmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,9 @@ autocmd_add_or_delete(typval_T *argvars, typval_T *rettv, int delete)
30613061
rettv->v_type = VAR_BOOL;
30623062
rettv->vval.v_number = VVAL_FALSE;
30633063

3064+
if (check_restricted() || check_secure())
3065+
return;
3066+
30643067
if (check_for_list_arg(argvars, 0) == FAIL)
30653068
return;
30663069

src/optiondefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ static struct vimoption options[] =
25782578
(char_u *)&p_tpm, PV_NONE, NULL, NULL,
25792579
{(char_u *)10L, (char_u *)0L} SCTX_INIT},
25802580
#if defined(FEAT_TABPANEL)
2581-
{"tabpanel", "tpl", P_STRING|P_VI_DEF|P_RALL,
2581+
{"tabpanel", "tpl", P_STRING|P_VI_DEF|P_RALL|P_MLE,
25822582
(char_u *)&p_tpl, PV_NONE, NULL, NULL,
25832583
{(char_u *)"", (char_u *)0L} SCTX_INIT},
25842584
{"tabpanelopt","tplo", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_COLON

src/testdir/test_autocmd.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5962,4 +5962,9 @@ func Test_SwapExists_b_nwindows()
59625962
%bw!
59635963
endfunc
59645964

5965+
func Test_autocmd_add_secure()
5966+
call assert_fails('sandbox call autocmd_add([{"event": "BufRead", "cmd": "let x = 1"}])', 'E48:')
5967+
call assert_fails('sandbox call autocmd_delete([{"event": "BufRead"}])', 'E48:')
5968+
endfunc
5969+
59655970
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_tabpanel.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,4 +872,19 @@ function Test_tabpanel_showtabpanel_via_cmd_arg()
872872
set showtabpanel& noruler&
873873
endfunc
874874

875+
func Test_tabpanel_no_modeline()
876+
let _tpl = &tabpanel
877+
let _mls = &modelineexpr
878+
879+
set nomodelineexpr
880+
setlocal modeline
881+
new
882+
call writefile(['/* vim: set tabpanel=test: */'], 'Xtabpanel.txt', 'D')
883+
call assert_fails(':e Xtabpanel.txt', 'E992:')
884+
885+
let &tabpanel = _tpl
886+
let &modelineexpr = _mls
887+
bw!
888+
endfunc
889+
875890
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
272,
737739
/**/
738740
271,
739741
/**/

0 commit comments

Comments
 (0)