unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Robert Pluim <rpluim@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>,
	ulm@gentoo.org, luangruo@yahoo.com, emacs-devel@gnu.org
Subject: Re: emacs-29 3c1693d08b0: Fix Elisp code injection vulnerability in emacsclient-mail.desktop
Date: Wed, 8 Mar 2023 10:54:08 -0800	[thread overview]
Message-ID: <560b874e-f67e-0b45-d489-8a45c4d8312d@gmail.com> (raw)
In-Reply-To: <87wn3rnos1.fsf@gmail.com>

On 3/8/2023 9:20 AM, Robert Pluim wrote:
>>>>>> On Wed, 8 Mar 2023 09:03:30 -0800, Jim Porter <jporterbugs@gmail.com> said:
>      Jim> In bug#57752, we'd discussed adding --apply to emacs and emacsclient,
>      Jim> which might work better for this case, as well as to make other
>      Jim> similar cases easier: Org mode uses some pretty extensive hacks in
>      Jim> order to get org-protocol:// URLs working in emacsclient, and
>      Jim> eliminating that would be very nice.
> 
> Thanks for the reference. Iʼve re-read the report, and the
> sort-of-consensus was that we needed '--apply' and a `set-arg'
> function.  Eli, would that be acceptable? (my patch called `apply'
> anyway, so itʼs not too big a change :-) )

'set-arg' is probably simple enough that we could expect users to write 
it themselves. '--apply' is a bit tricky (for emacsclient at least), 
since we'd need to properly escape strings. I guess the complexity of 
doing this would depend on how we did the escaping though.

For reference for this thread, the conclusion we came to in bug#57752 
was an interface like this:

   emacs --apply func1 arg1 arg2 -- --apply func2 arg3 arg4

(Ditto for emacsclient.)

----------------------------------------

For Org mode, the problem is that it wants to support "org-protocol": 
this is a special URL protocol that lets you capture bits of text (or 
whatever, really) into an Org file[1]. In order to avoid the escaping 
issues mentioned in this thread, Org has to jump through a lot of hoops, 
advising several functions in server.el (see org-protocol.el and this 
thread[2]). Note: This also uses .desktop files on systems using XDG 
(sorry, Eli), but that's just how you register URL protocols on those 
systems; not much we can do about that.

That said, the '--apply' argument would (debatably) be useful in other 
places too: for example, if I wanted a shell command to open a link in 
EWW, I could define an alias like:

   alias eww="emacs --apply eww"
   # or
   alias eww="emacsclient --apply eww"

Or you could use it with 'view-file' to make an alias to open a file in 
Emacs just for viewing. (And you could do similar things any time you 
want to pass an arbitrary string to Emacs from a script.)

Currently, you can do all this with the main emacs binary by writing 
your own function that calls '(pop command-line-args-left)' (see 
'message-mailto'), but as the commit from this thread suggests, that's 
not possible with emacsclient currently. It also means that even for the 
main emacs binary, you need to specially-write your function to use 
'command-line-args-left' instead of being able to call existing 
functions directly.

[1] https://orgmode.org/worg/org-contrib/org-protocol.html

[2] https://lists.gnu.org/archive/html/emacs-orgmode/2022-02/msg00056.html



  parent reply	other threads:[~2023-03-08 18:54 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
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 [this message]
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=560b874e-f67e-0b45-d489-8a45c4d8312d@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=rpluim@gmail.com \
    --cc=ulm@gentoo.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 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).