From: Eli Zaretskii <eliz@gnu.org>
To: lux <lx@shellcodes.org>
Cc: 60295-done@debbugs.gnu.org
Subject: bug#60295: [PATCH] Fix htmlfontify.el command injection vulnerability
Date: Tue, 27 Dec 2022 16:11:21 +0200 [thread overview]
Message-ID: <83k02d0wdy.fsf@gnu.org> (raw)
In-Reply-To: <tencent_F604EB715ACE18D754D6B8DDFDC9E785370A@qq.com> (message from lux on Sat, 24 Dec 2022 17:03:09 +0800)
> Date: Sat, 24 Dec 2022 17:03:09 +0800
> From: lux <lx@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.
prev parent reply other threads:[~2022-12-27 14:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-24 9:03 bug#60295: [PATCH] Fix htmlfontify.el command injection vulnerability lux
2022-12-26 19:03 ` Stefan Kangas
2022-12-27 14:11 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83k02d0wdy.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=60295-done@debbugs.gnu.org \
--cc=lx@shellcodes.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.