From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#70440: [PATCH] Use -P switch when calling 'python-interpreter' Date: Fri, 19 Apr 2024 17:21:48 +0200 Message-ID: <87frvhgyyb.fsf@gmail.com> References: <87h6fzj1b1.fsf@gmail.com> <861q73hkeq.fsf@gnu.org> <87jzkthok4.fsf@gmail.com> <861q71dds5.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34400"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70440@debbugs.gnu.org, kobarity@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 19 17:23:20 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 1rxq58-0008fA-PN for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Apr 2024 17:23:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxq4i-0007b7-Ci; Fri, 19 Apr 2024 11:22: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 1rxq4f-0007YH-PP for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:22:49 -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 1rxq4f-0002lY-Gr for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:22:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxq4t-000618-DE for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 11:23:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Apr 2024 15:23:03 +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.171354013722856 (code B ref 70440); Fri, 19 Apr 2024 15:23:03 +0000 Original-Received: (at 70440) by debbugs.gnu.org; 19 Apr 2024 15:22:17 +0000 Original-Received: from localhost ([127.0.0.1]:58735 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxq47-0005wY-VT for submit@debbugs.gnu.org; Fri, 19 Apr 2024 11:22:17 -0400 Original-Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxq43-0005v2-4S for 70440@debbugs.gnu.org; Fri, 19 Apr 2024 11:22:13 -0400 Original-Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-419c8236b34so3495205e9.0 for <70440@debbugs.gnu.org>; Fri, 19 Apr 2024 08:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713540111; x=1714144911; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=VaIUtOcCaN6tYTsZy+DimrSjgAvDVHA6bxBaEQt4auk=; b=Z2PCVmM0Zq4az9rL2euQpmDgH3jH0TMc2wOlQm/dJfYZoEgUC7yCSTd7msOmDxl/Ez e4P8CEyo3M65+XTQ89xqpcXq+KHe3TN/qTeoR5JTtgst4jgmlbRG6xdXYE03NhV3sWWB sUOvxnmPR3qrDR3lyfRIDYvAw5yHq7ZPR0fa+0Y+g1JbbDAbJQmfzb/S7crLMEZ6Jp2z BCDciH4fpbaRgvJVwhSYEhtTUuFfWFM2D+dKeyiSstA5/wNHvRELjTBBT70YhlvxUKNK Iue6i8i+orZkRgNeEk4jBO1pQX428ttaDkDBL4Vjs1dp8+lC8VsYJtm+96ZPzFtpT9zm uVEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713540111; x=1714144911; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VaIUtOcCaN6tYTsZy+DimrSjgAvDVHA6bxBaEQt4auk=; b=AVO609GOtI1SMXSMisXSHekRdjmfRZxZpuoTw8m7dU/xXkICqcdQGATiruVXK4F7DU MHjz2NktmIWzN9keCTSxEb4T06MgtlfgJYDc3WSnIMXRqgiP5R5xnlwmpGkJBEs4e0pp ynA9eOEDyzkkJN6osCWSSumJPnc/mW5w25O13Y33qFcMRCMtGqhQl7C+zaB2L+jmcYp4 VBxjlRkPhQ43XUqvf6OgU1jUPP4ilH52FnCf8lP5ckGXUEuz08Ry1JK2N8rRJKfdiMzR xX1V75VNZ9VUjDMYIOPjtH8y1IlBSx8OXZhzqg1+jFkByMqRR+hsLex1zoj0uHAxAPXj OtNw== X-Forwarded-Encrypted: i=1; AJvYcCUV+Vtq6PYMnUo3rcek/Ntop06DQQypVL9exooaiaUWZzaxaXoL15wFSAUcxPrINbxKhuXkzhfv6s2E6pyTbb9lNqV0k98= X-Gm-Message-State: AOJu0Yz0aUC+uoiwTqj8mnndCCRJ6+t5xYiT+6AZnPtjTCjkk71id/Bt mhdckorB/aJMiqJWmz1H5+oisyt/EyPdmcwNzUTIM6mkNcmlHfocj8CI+A== X-Google-Smtp-Source: AGHT+IETAyupFPFe9rYE4gj8rJJCsW5VW5dL35teCBXTBnpuTpJVlfzd2/qVdvX2mSBc5HRr1ICLSQ== X-Received: by 2002:a05:6000:b8a:b0:347:d045:1fd8 with SMTP id dl10-20020a0560000b8a00b00347d0451fd8mr1961496wrb.38.1713540110412; Fri, 19 Apr 2024 08:21:50 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8a87:ff00::6223]) by smtp.gmail.com with ESMTPSA id h25-20020a1709070b1900b00a558f01499asm345477ejl.154.2024.04.19.08.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 08:21:49 -0700 (PDT) In-Reply-To: <861q71dds5.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 19 Apr 2024 10:15:06 +0300") 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:283686 Archived-At: 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. (Apart from the security aspect, without -P the tool will just mysteriously stop working if a file with a name such as csv.py is added to the project; that's what happened to me. Perhaps outright not working and explaining why is not as bad as working fine until it doesn't anymore.)