aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/gzip.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-09-01 11:38:31 +0800
committerGitHub <noreply@github.com>2023-09-01 11:38:31 +0800
commit7bf0963d48ec76b1cdeee55edc8f2053eca87367 (patch)
treee16dac490ac04d20663aa8d6dca1e75967b63d56 /runtime/autoload/gzip.vim
parent592a8f1e90d5abaa695280bf6d41a547b3631d0d (diff)
downloadrneovim-7bf0963d48ec76b1cdeee55edc8f2053eca87367.tar.gz
rneovim-7bf0963d48ec76b1cdeee55edc8f2053eca87367.tar.bz2
rneovim-7bf0963d48ec76b1cdeee55edc8f2053eca87367.zip
vim-patch:9.0.1833: [security] runtime file fixes (#24969)
Problem: runtime files may execute code in current dir Solution: only execute, if not run from current directory The perl, zig and ruby filetype plugins and the zip and gzip autoload plugins may try to load malicious executable files from the current working directory. This is especially a problem on windows, where the current directory is implicitly in your $PATH and windows may even run a file with the extension `.bat` because of $PATHEXT. So make sure that we are not trying to execute a file from the current directory. If this would be the case, error out (for the zip and gzip) plugins or silently do not run those commands (for the ftplugins). This assumes, that only the current working directory is bad. For all other directories, it is assumed that those directories were intentionally set to the $PATH by the user. https://github.com/vim/vim/commit/816fbcc262687b81fc46f82f7bbeb1453addfe0c Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/autoload/gzip.vim')
-rw-r--r--runtime/autoload/gzip.vim7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/autoload/gzip.vim b/runtime/autoload/gzip.vim
index 95dd906794..ac9e37bf85 100644
--- a/runtime/autoload/gzip.vim
+++ b/runtime/autoload/gzip.vim
@@ -10,12 +10,17 @@
fun s:check(cmd)
let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
if !exists("s:have_" . name)
+ " safety check, don't execute anything from the current directory
+ let f = fnamemodify(exepath(name), ":p:h") !=# getcwd()
+ if !f
+ echoerr "Warning: NOT executing " .. name .. " from current directory!"
+ endif
let e = executable(name)
if e < 0
let r = system(name . " --version")
let e = (r !~ "not found" && r != "")
endif
- exe "let s:have_" . name . "=" . e
+ exe "let s:have_" . name . "=" . (e && f)
endif
exe "return s:have_" . name
endfun