GNU bug report logs -
#60295
[PATCH] Fix htmlfontify.el command injection vulnerability
Previous Next
Reported by: lux <lx <at> shellcodes.org>
Date: Sat, 24 Dec 2022 09:04:01 UTC
Severity: normal
Tags: patch, security
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#60295: [PATCH] Fix htmlfontify.el command injection vulnerability
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 60295 <at> debbugs.gnu.org.
--
60295: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60295
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> Date: Sat, 24 Dec 2022 17:03:09 +0800
> From: lux <lx <at> shellcodes.org>
>
> Test information:
> Emacs version: GNU Emacs 29.0.60
> OS: Fedora Linux 37
>
> htmlfontify.el has a command injection vulnerability:
>
> (defcustom hfy-istext-command "file %s | sed -e 's@^[^:]*:[ \t]*@@'"
> :tag "istext-command"
> :type '(string))
>
> (defun hfy-text-p (srcdir file)
> (let* ((cmd (format hfy-istext-command (expand-file-name file
> srcdir))) (rsp (shell-command-to-string cmd)))
> ...))
>
> Parameter 'file' and parameter 'srcdir' come from external input, and
> parameters are not escape. So, if file name or directory name contains
> shell characters and will be executed.
>
> For example:
>
> $ mkdir vul_test
> $ cd vul_test
> $ echo hello > ";uname>hack.txt#"
> $ ls
> ;uname>hack.txt#
>
> In Emacs, type M-x htmlfontify-copy-and-link-dir, and inputing vul_test
> path, at this time, hack.txt is added to the vul_test directory:
>
> $ ls
> ;uname>hack.txt# hack.txt#
> $ cat hack.txt\#
> Linux
>
> The attachment is the patch file, thanks.
Thanks, installed on the emacs-29 branch, and closing the bug.
[Message part 3 (message/rfc822, inline)]
[Message part 4 (text/plain, inline)]
Test information:
Emacs version: GNU Emacs 29.0.60
OS: Fedora Linux 37
htmlfontify.el has a command injection vulnerability:
(defcustom hfy-istext-command "file %s | sed -e 's@^[^:]*:[ \t]*@@'"
:tag "istext-command"
:type '(string))
(defun hfy-text-p (srcdir file)
(let* ((cmd (format hfy-istext-command (expand-file-name file
srcdir))) (rsp (shell-command-to-string cmd)))
...))
Parameter 'file' and parameter 'srcdir' come from external input, and
parameters are not escape. So, if file name or directory name contains
shell characters and will be executed.
For example:
$ mkdir vul_test
$ cd vul_test
$ echo hello > ";uname>hack.txt#"
$ ls
;uname>hack.txt#
In Emacs, type M-x htmlfontify-copy-and-link-dir, and inputing vul_test
path, at this time, hack.txt is added to the vul_test directory:
$ ls
;uname>hack.txt# hack.txt#
$ cat hack.txt\#
Linux
The attachment is the patch file, thanks.
[0001-Fix-htmlfontify.el-command-injection-vulnerability.patch (text/x-patch, attachment)]
This bug report was last modified 2 years and 207 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.