From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: emacs-29 3c1693d08b0: Fix Elisp code injection vulnerability in emacsclient-mail.desktop Date: Wed, 8 Mar 2023 10:54:08 -0800 Message-ID: <560b874e-f67e-0b45-d489-8a45c4d8312d@gmail.com> References: <167821009581.14664.5608674978571454819@vcs2.savannah.gnu.org> <20230307172816.2D56BC13915@vcs2.savannah.gnu.org> <877cvsozn5.fsf@yahoo.com> <87zg8onfob.fsf@yahoo.com> <87r0tzoeam.fsf@yahoo.com> <87a60no7su.fsf@yahoo.com> <87edpzplom.fsf@gmail.com> <87a60npirc.fsf@gmail.com> <83mt4n49az.fsf@gnu.org> <87wn3rnos1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4664"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , ulm@gentoo.org, luangruo@yahoo.com, emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 08 19:54:50 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZyw5-0000yz-NB for ged-emacs-devel@m.gmane-mx.org; Wed, 08 Mar 2023 19:54:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZyvU-0007qT-Sx; Wed, 08 Mar 2023 13:54:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZyvT-0007qD-NS for emacs-devel@gnu.org; Wed, 08 Mar 2023 13:54:11 -0500 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZyvR-0003EE-Si; Wed, 08 Mar 2023 13:54:11 -0500 Original-Received: by mail-pj1-x102c.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so3435183pjb.3; Wed, 08 Mar 2023 10:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678301648; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=SaXf+RuKFWBpB/p1TYUPRT7OahNIRdLKrU0AOk+bxsA=; b=N9tzUOWRoyOl2isSsPdlXZsNV0KEJ9B0eAFJQeQgybsFVxSF2OiSGpghO8YEoJZ85I UiCCS2zStWyXfV5lVV15G9ZGjJ4TrYKAp3gSarSmnzH+Cmbpsk9QrWCHqX7Gh+O9EDB7 m4NXXxsJwoCTNUmlKGs5LmiNNKYmSPpZ3xnDb0r4ZmkkgEdf6Bf8F6tOV7wElIBvDkVa SG/QeqBFks3e23huRxxURalFFwGNN+cN6i1YXXK4YghlIc93l9t7zzzzp3yA+E0pUvlJ YYgH7BgR/+MIcYhXp94dCEBoFvaFMrnknG4O4OD1nywtNdwN7F6p1JId4815s8wUcvh8 V2Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678301648; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SaXf+RuKFWBpB/p1TYUPRT7OahNIRdLKrU0AOk+bxsA=; b=sAoiuijUh6ZfUdJseyFUj+cGwpKe1CI03kSKp8lAHcwga/+ONfJEAA3xoU4x3FpuWs Z+jmyUJ3I+GZdwr/JmnvTFczVIv0FC8TFNhCxvRpgfn7CMjU9wkBQGHeztjdZVS5M9Yv gKwzPQvE/+AF1R9LxQXDhmoNlKofbBiWtO9UE7DZFoffOt8yBDKv53xA0KTEwBd4EBY3 qp2itNgoMepqkozYp78yuSZRzvwfFov17YpJodRt8YKGZGgQRIhMX36zxwM3J0nEc1AP F3RPM8Ed9NeYiL0ut1hlai36sCZyvJ19V8G7cm2iP9i7cLTkNh/xkCpg6ENiRSpEqFhl fvkA== X-Gm-Message-State: AO0yUKUXNdH/TC5TkP9aEEMcdfBWq2JNYZ+GHrvAccbqJXTsokCvYc3E 6KNBD4epLWDxZgrxH8MtQDQ= X-Google-Smtp-Source: AK7set+NgIbw19qnWRvMPpCc1zJ6zkzzRMQSSIHNTF+fD6z0TWwe3CdgG63wAEbrMED7fV7MhXQoVQ== X-Received: by 2002:a17:902:ba83:b0:19c:d6fe:39cb with SMTP id k3-20020a170902ba8300b0019cd6fe39cbmr16326025pls.7.1678301648047; Wed, 08 Mar 2023 10:54:08 -0800 (PST) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id p3-20020a170902bd0300b0019a96a6543esm10107457pls.184.2023.03.08.10.54.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Mar 2023 10:54:07 -0800 (PST) Content-Language: en-US In-Reply-To: <87wn3rnos1.fsf@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304150 Archived-At: On 3/8/2023 9:20 AM, Robert Pluim wrote: >>>>>> On Wed, 8 Mar 2023 09:03:30 -0800, Jim Porter 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