From: Ulrich Mueller <ulm@gentoo.org>
To: Ulrich Mueller <ulm@gentoo.org>
Cc: Robert Pluim <rpluim@gmail.com>, Po Lu <luangruo@yahoo.com>,
emacs-devel@gnu.org
Subject: Re: emacs-29 3c1693d08b0: Fix Elisp code injection vulnerability in emacsclient-mail.desktop
Date: Wed, 08 Mar 2023 12:29:13 +0100 [thread overview]
Message-ID: <uedpzqy5y@gentoo.org> (raw)
In-Reply-To: <ulek7qz45@gentoo.org> (Ulrich Mueller's message of "Wed, 08 Mar 2023 12:08:42 +0100")
>>>>> On Wed, 08 Mar 2023, Ulrich Mueller wrote:
> Sure, something like this (not yet tested):
> -Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u
> +Exec=sh -c "u=\\$\\(echo \\"\\$1\\" | sed \\'s/[\\\\\\"]/\\\\\\\\\\&/g\\'\\); exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
> Sorry, but it doesn't get less ugly. :) Also, it will now call _two_
> external programs. Is this acceptable, and is it guaranteed that sed
> will be available on users' systems?
In fact, only '"', '$', and '\' need to be backslash-escaped.
Patch included below, works fine here.
----- 8< -----
From 1e1f128c5ca0c888dae4651bcb3d556737e3a207 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <ulm@gentoo.org>
Date: Wed, 8 Mar 2023 12:23:58 +0100
Subject: [PATCH] Avoid using bash in the emacsclient desktop file
* etc/emacsclient-mail.desktop (Exec): Use sh and sed instead
of bash, because the latter may not be available everywhere.
---
etc/emacsclient-mail.desktop | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop
index 49c6f99f317..0a2420ddead 100644
--- a/etc/emacsclient-mail.desktop
+++ b/etc/emacsclient-mail.desktop
@@ -2,9 +2,9 @@
Categories=Network;Email;
Comment=GNU Emacs is an extensible, customizable text editor - and more
# We want to pass the following commands to the shell wrapper:
-# u=${1//\\/\\\\}; u=${u//\"/\\\"}; exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")"
+# u=$(echo "$1" | sed 's/[\"]/\\&/g'); exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")"
# Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'.
-Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u
+Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
Icon=emacs
Name=Emacs (Mail, Client)
MimeType=x-scheme-handler/mailto;
@@ -16,7 +16,7 @@ Actions=new-window;new-instance;
[Desktop Action new-window]
Name=New Window
-Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u
+Exec=sh -c "u=\\$(echo \\"\\$1\\" | sed 's/[\\\\\\"]/\\\\\\\\&/g'); exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" sh %u
[Desktop Action new-instance]
Name=New Instance
--
2.39.2
next prev parent reply other threads:[~2023-03-08 11:29 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <167821009581.14664.5608674978571454819@vcs2.savannah.gnu.org>
[not found] ` <20230307172816.2D56BC13915@vcs2.savannah.gnu.org>
2023-03-08 0:27 ` emacs-29 3c1693d08b0: Fix Elisp code injection vulnerability in emacsclient-mail.desktop Po Lu
2023-03-08 2:14 ` Ulrich Mueller
2023-03-08 2:24 ` Po Lu
2023-03-08 7:15 ` Ulrich Mueller
2023-03-08 8:09 ` Po Lu
2023-03-08 8:32 ` Ulrich Mueller
2023-03-08 10:29 ` Po Lu
2023-03-08 10:39 ` Ulrich Mueller
2023-03-08 10:44 ` Robert Pluim
2023-03-08 11:08 ` Ulrich Mueller
2023-03-08 11:29 ` Ulrich Mueller [this message]
2023-03-08 11:47 ` Robert Pluim
2023-03-08 14:17 ` Eli Zaretskii
2023-03-08 15:47 ` Robert Pluim
2023-03-08 17:03 ` Jim Porter
2023-03-08 17:20 ` Robert Pluim
2023-03-08 17:41 ` Eli Zaretskii
2023-03-08 18:54 ` Jim Porter
2023-03-09 9:30 ` Robert Pluim
2023-03-09 10:22 ` Po Lu
2023-03-09 10:50 ` Robert Pluim
2023-03-09 18:36 ` Jim Porter
2023-03-08 11:44 ` Po Lu
2023-03-08 14:14 ` Eli Zaretskii
2023-03-09 0:50 ` Po Lu
2023-03-09 7:19 ` Eli Zaretskii
2023-03-09 7:25 ` Po Lu
2023-03-09 7:49 ` Manuel Giraud via Emacs development discussions.
2023-03-09 8:20 ` tomas
2023-03-08 10:58 ` Po Lu
2023-03-08 11:44 ` Ulrich Mueller
2023-03-08 14:13 ` Eli Zaretskii
2023-03-08 14:05 ` Eli Zaretskii
2023-03-08 10:37 ` Robert Pluim
2023-03-08 12:14 ` Ulrich Mueller
2023-03-08 15:49 ` Robert Pluim
2023-03-08 14:04 ` Eli Zaretskii
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uedpzqy5y@gentoo.org \
--to=ulm@gentoo.org \
--cc=emacs-devel@gnu.org \
--cc=luangruo@yahoo.com \
--cc=rpluim@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).