aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Müller2023-03-07 18:25:37 +0100
committerUlrich Müller2023-03-07 18:25:37 +0100
commit3c1693d08b0a71d40a77e7b40c0ebc42dca2d2cc (patch)
treef4d2798e2e502999a8c06062bdda0f8498fa6afa
parentab417c8a6eeb7df7ccce3e5f8416f48544a5174e (diff)
downloademacs-3c1693d08b0a71d40a77e7b40c0ebc42dca2d2cc.tar.gz
emacs-3c1693d08b0a71d40a77e7b40c0ebc42dca2d2cc.zip
Fix Elisp code injection vulnerability in emacsclient-mail.desktop
A crafted mailto URI could contain unescaped double-quote characters, allowing injection of Elisp code. Therefore, any '\' and '"' characters are replaced by '\\' and '\"', using Bash pattern substitution (which is not available in the POSIX shell). We want to pass literal 'u=${1//\\/\\\\}; u=${u//\"/\\\"};' in the bash -c command, but in the desktop entry '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\', respectively (backslashes are expanded twice, see the Desktop Entry Specification). Reported by Gabriel Corona <gabriel.corona@free.fr>. * etc/emacsclient-mail.desktop (Exec): Escape backslash and double-quote characters.
-rw-r--r--etc/emacsclient-mail.desktop7
1 files changed, 5 insertions, 2 deletions
diff --git a/etc/emacsclient-mail.desktop b/etc/emacsclient-mail.desktop
index 91df122c594..49c6f99f317 100644
--- a/etc/emacsclient-mail.desktop
+++ b/etc/emacsclient-mail.desktop
@@ -1,7 +1,10 @@
1[Desktop Entry] 1[Desktop Entry]
2Categories=Network;Email; 2Categories=Network;Email;
3Comment=GNU Emacs is an extensible, customizable text editor - and more 3Comment=GNU Emacs is an extensible, customizable text editor - and more
4Exec=sh -c "exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$1\\\\\\")\\"" sh %u 4# We want to pass the following commands to the shell wrapper:
5# u=${1//\\/\\\\}; u=${u//\"/\\\"}; exec emacsclient --alternate-editor= --display="$DISPLAY" --eval "(message-mailto \"$u\")"
6# Special chars '"', '$', and '\' must be escaped as '\\"', '\\$', and '\\\\'.
7Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --display=\\"\\$DISPLAY\\" --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u
5Icon=emacs 8Icon=emacs
6Name=Emacs (Mail, Client) 9Name=Emacs (Mail, Client)
7MimeType=x-scheme-handler/mailto; 10MimeType=x-scheme-handler/mailto;
@@ -13,7 +16,7 @@ Actions=new-window;new-instance;
13 16
14[Desktop Action new-window] 17[Desktop Action new-window]
15Name=New Window 18Name=New Window
16Exec=sh -c "exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$1\\\\\\")\\"" sh %u 19Exec=bash -c "u=\\${1//\\\\\\\\/\\\\\\\\\\\\\\\\}; u=\\${u//\\\\\\"/\\\\\\\\\\\\\\"}; exec emacsclient --alternate-editor= --create-frame --eval \\"(message-mailto \\\\\\"\\$u\\\\\\")\\"" bash %u
17 20
18[Desktop Action new-instance] 21[Desktop Action new-instance]
19Name=New Instance 22Name=New Instance