From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70440: [PATCH] Use -P switch when calling 'python-interpreter' Date: Fri, 19 Apr 2024 18:40:49 +0300 Message-ID: <8634rhbbsu.fsf@gnu.org> References: <87h6fzj1b1.fsf@gmail.com> <861q73hkeq.fsf@gnu.org> <87jzkthok4.fsf@gmail.com> <861q71dds5.fsf@gnu.org> <87frvhgyyb.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18504"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70440@debbugs.gnu.org, kobarity@gmail.com To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 19 17:42:07 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rxqNK-0004at-Tt for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Apr 2024 17:42:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxqN6-0005gO-3T; Fri, 19 Apr 2024 11:41:52 -0400 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 1rxqN4-0005fv-OA for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:41:50 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxqN4-0006FM-GC for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:41:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxqNI-0008CA-9X for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:42:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Apr 2024 15:42:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70440 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70440-submit@debbugs.gnu.org id=B70440.171354127731188 (code B ref 70440); Fri, 19 Apr 2024 15:42:04 +0000 Original-Received: (at 70440) by debbugs.gnu.org; 19 Apr 2024 15:41:17 +0000 Original-Received: from localhost ([127.0.0.1]:58826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxqMW-00086y-EM for submit@debbugs.gnu.org; Fri, 19 Apr 2024 11:41:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxqMS-00085k-ME for 70440@debbugs.gnu.org; Fri, 19 Apr 2024 11:41:14 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxqM9-0006By-2J; Fri, 19 Apr 2024 11:40:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=BECfY5nR3tJOo2A8kJ2V7mY+wJbQSNlS1zVgZjN85sI=; b=On1Mg0vcnW4P iMpQ0GgIaL4zINI5R4+DMaBTUYJ6FxMrMySaoeEd5AHM3sxS2PYLNuOo76jaQqvETm8Nq/J6OMInJ Q44CE5FqydH3LKJHrAXNrjCBKwiIlIE9vuCe5y5+kV7hEVJRa1PZ6V/NdCKMBnSYeoPZgiuT1atm7 qcJ09JV6zlbmQ2DNFKVxH7EruD+1FBsYVt8+pImT9jopEwFLDzSDrWSbJ5x/EQ4D8aSH9kNPGAOmh iMeirnRKtMMPnF67Fng5HgiaUb2S+ertD/3ki5MsmTWTz2jBEevTtJh/aYaeqYSICd/cn1gNpimEr LOlaB03s6SHZkFtMoZJilA==; In-Reply-To: <87frvhgyyb.fsf@gmail.com> (message from Augusto Stoffel on Fri, 19 Apr 2024 17:21:48 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283687 Archived-At: > From: Augusto Stoffel > Cc: kobarity@gmail.com, 70440@debbugs.gnu.org > Date: Fri, 19 Apr 2024 17:21:48 +0200 > > On Fri, 19 Apr 2024 at 10:15, Eli Zaretskii wrote: > > >> From: Augusto Stoffel > >> Cc: Eli Zaretskii , 70440@debbugs.gnu.org > >> Date: Fri, 19 Apr 2024 08:08:43 +0200 > >> > >> On Fri, 19 Apr 2024 at 00:25, kobarity wrote: > >> > >> > The -P switch is new, introduced in CPython 3.11, so I don't think it > >> > can be added unconditionally. Furthermore, `python-interpreter' may > >> > not be CPython. Isn't it enough to customize > >> > `python-interpreter-args'? > >> > >> After sleeping on this, I recommend using -P anyway and simply failing > >> if the installed Python is too old. > >> > >> The reason is that this has a security implication, similar to the > >> recent Org mode Latex preview situation. Without -P the user is tacitly > >> trusting the contents of the current directory. By tricking an user > >> into downloading a malicious file with an intentional name clash (say > >> via git pull), arbitrary code could in principle be executed on the > >> user's machine. > >> > >> The -P switch completely removes this possibility, and conversely, > >> without -P there seems to be no reasonable way to make Python safe. > >> > >> I've attached a new patch that informs the user why the commands failed > >> when Python is too old, which is good enough in my opinion. Note also > >> that this change only affects the Python import management commands, > >> which is a very handy but by no means essential feature. > > > > Doing it this way would be an annoyance. Users could have > > less-than-the-latest Python (or non-CPython version) installed for any > > number of reasons, and it is not our business to annoy them because of > > this. Security of using Python is not our concern, it is the user's > > concern. > > > > So I'd prefer that the change probed the support for the -P switch > > when the relevant Emacs commands/functions are first invoked, and used > > that if -P is supported, without any annoying messages. Do you see > > any problems with such an approach? > > > > Thanks. > > Okay, you are the maintainer, but I hope I explained well that this is a > security hole. I'm not sure I understand: if the user doesn't have a version of Python which supports this option, what else can we do? Refuse to use such a Python? That doesn't seem to be an option we can use. Yes, this is a security hole, but it's the user's security hole, not ours, if the user doesn't install the safer Python.