From 5bd19740251e996dfdbfa62e316041d57fb8b63b Mon Sep 17 00:00:00 2001 From: Jacek Migacz Date: Sat, 1 Apr 2023 23:50:33 +0200 Subject: [PATCH] Fix ob-latex.el command injection vulnerability Resolves: #2180590 --- ...atex-command-injection-vulnerability.patch | 43 +++++++++++++++++++ emacs.spec | 2 + 2 files changed, 45 insertions(+) create mode 100644 emacs-ob-latex-command-injection-vulnerability.patch diff --git a/emacs-ob-latex-command-injection-vulnerability.patch b/emacs-ob-latex-command-injection-vulnerability.patch new file mode 100644 index 0000000..275ada9 --- /dev/null +++ b/emacs-ob-latex-command-injection-vulnerability.patch @@ -0,0 +1,43 @@ +From a8006ea580ed74f27f974d60b598143b04ad1741 Mon Sep 17 00:00:00 2001 +From: Xi Lu +Date: Sat, 11 Mar 2023 18:53:37 +0800 +Subject: * lisp/org/ob-latex.el: Fix command injection vulnerability + +(org-babel-execute:latex): +Replaced the `(shell-command "mv BAR NEWBAR")' with `rename-file'. + +TINYCHANGE +--- + lisp/org/ob-latex.el | 13 +++++-------- + 1 file changed, 5 insertions(+), 8 deletions(-) + +diff --git a/lisp/org/ob-latex.el b/lisp/org/ob-latex.el +index a2c24b3..ce39628 100644 +--- a/lisp/org/ob-latex.el ++++ b/lisp/org/ob-latex.el +@@ -218,17 +218,14 @@ This function is called by `org-babel-execute-src-block'." + (if (string-suffix-p ".svg" out-file) + (progn + (shell-command "pwd") +- (shell-command (format "mv %s %s" +- (concat (file-name-sans-extension tex-file) "-1.svg") +- out-file))) ++ (rename-file (concat (file-name-sans-extension tex-file) "-1.svg") ++ out-file t)) + (error "SVG file produced but HTML file requested"))) + ((file-exists-p (concat (file-name-sans-extension tex-file) ".html")) + (if (string-suffix-p ".html" out-file) +- (shell-command "mv %s %s" +- (concat (file-name-sans-extension tex-file) +- ".html") +- out-file) +- (error "HTML file produced but SVG file requested"))))) ++ (rename-file (concat (file-name-sans-extension tex-file) ".html") ++ out-file t) ++ (error "HTML file produced but SVG file requested"))))) + ((or (string= "pdf" extension) imagemagick) + (with-temp-file tex-file + (require 'ox-latex) +-- +cgit v1.1 + diff --git a/emacs.spec b/emacs.spec index 7076b7d..f7e4d37 100644 --- a/emacs.spec +++ b/emacs.spec @@ -32,6 +32,7 @@ Patch5: emacs-64KB-page-size-for-pdump.patch Patch6: emacs-etags-local-command-injection-vulnerability.patch Patch7: emacs-htmlfontify-command-injection-vulnerability.patch Patch8: emacs-ruby-mode-local-command-injection-vulnerability.patch +Patch9: emacs-ob-latex-command-injection-vulnerability.patch BuildRequires: gcc BuildRequires: atk-devel BuildRequires: cairo-devel @@ -199,6 +200,7 @@ Development header files for Emacs. %patch6 -p1 -b .etags-local-command-injection-vulnerability %patch7 -p1 -b .htmlfontify-command-injection-vulnerability %patch8 -p1 -b .ruby-mode-local-command-injection-vulnerability +%patch9 -p1 -b .ob-latex-command-injection-vulnerability autoconf # We prefer our emacs.desktop file