From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] scratch/allow-custom-load-paths-in-elisp-flymake 4ef9711: Allow custom load paths in elisp's byte-compilation Flymake Date: Wed, 5 Dec 2018 20:40:07 +0000 Message-ID: References: <20181204233600.7907.75252@vcs0.savannah.gnu.org> <20181204233601.273DD209DC@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000366e7d057c4cd40b" X-Trace: blaine.gmane.org 1544044188 13462 195.159.176.226 (5 Dec 2018 21:09:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Dec 2018 21:09:48 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 05 22:09:43 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUeQR-0003Nx-HM for ged-emacs-devel@m.gmane.org; Wed, 05 Dec 2018 22:09:43 +0100 Original-Received: from localhost ([::1]:36888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUeSY-0002na-7N for ged-emacs-devel@m.gmane.org; Wed, 05 Dec 2018 16:11:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUeSR-0002iV-0t for emacs-devel@gnu.org; Wed, 05 Dec 2018 16:11:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUeSP-0002ns-DP for emacs-devel@gnu.org; Wed, 05 Dec 2018 16:11:46 -0500 Original-Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:33547) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUeSO-0002lL-2c; Wed, 05 Dec 2018 16:11:44 -0500 Original-Received: by mail-qk1-x72b.google.com with SMTP id o89so12798735qko.0; Wed, 05 Dec 2018 13:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DNo3hLAbHP9JSA8xVqLw3NpYogpSRdEHqFT6eyvZcbU=; b=j+LQfkUDXxFr4Wfnma7jjxFW9k0Ijlc7ERdB0zFuDo7qQt7RsCobcDKqycVqZgJe/F kKsumcpklsgH0YDrjlf6sfgptOEKn0PZhw+Pe0LqhW0N6whEYAd0zAex/MggExwvLhOd iWGut9oM305E1ruHdWAApN3yFqPGf8EfXF0DBH3vcpuWYxpSBpZP80srII+2MSKhtaxi 4EIMlVUpis/H+oQdmnWIAkKGast95NBOWzODErdcpZqdQV/mmQnYXRxOtjotFbeYE5lJ +wBBk0tHBlSEjvZiRXA8ytZJBsR0xG6MGyEl1XlE+Q4Ry0POKZg+chTho9ypHEGmG+7X ch2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DNo3hLAbHP9JSA8xVqLw3NpYogpSRdEHqFT6eyvZcbU=; b=j2Cl5nRCTh9L6OaKdhq6wzcA0kBZX2htBABx0oKCTZd5MjVA9v70z83ZydI/c1iHkH H6PpPo9I8HPkK7c5iBslgrwNPHpiboPd0wGZpHsEQb9oV/7hL4I6U+9ytrlzCfL+rAtU Jr5cIZYpUH4bhFL+U+IcplIa7esAtqOKk7zDvz922U39k/3zTHV9uoix/y2qskSp9Isv ML+FTucrtWNcfGQcZrFW2Alm/dvi0COxfSua0xboLHmN+XMgajjE/elz7P/dDjnUMob0 bZvNKwRh9hHz+uBqNVW9hWTnz0oxUgSJ4ayQGYKCb2xXMPSbZzs12J1KKJBSwPg5/B2Q Jueg== X-Gm-Message-State: AA+aEWYNoyfmvpuBaOIisBPEggc4ZEExYjaaSV+sy7lQMxQaudm1ZhpB Oy8B/8CYwiskEg810xczo5Sacm/MzUyD9CG2hVdIzQ== X-Google-Smtp-Source: AFSGD/Wm3zhyn50YMUcSBpUNVIAIdLrhBxEppChvsywpwM2ZjJuTQg5P15nEn2zRSmC5c6FaQmuZKtYbWDjGWzwKXXA= X-Received: by 2002:a37:f706:: with SMTP id q6mr22982644qkj.96.1544044303247; Wed, 05 Dec 2018 13:11:43 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::72b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:231656 Archived-At: --000000000000366e7d057c4cd40b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 5, 2018, 20:00 Glenn Morris > >> +(put 'elisp-flymake-byte-compile-load-path 'safe-local-variable > >> + (lambda (x) (and (listp x) (catch 'tag > >> + (dolist (path x t) (unless (stringp > path) > >> + (throw 'tag > nil))))))) > > AFAICS the above tests whether the value is valid, not whether it is safe= . > This should probably be a risky-local-variable, like load-path is. > The default "." seems actively dangerous, in much the same way as having > "." in a shell's PATH is. > Glenn, I'm aware of the difference between valid and safe. One of us is missing something: 1. The new variable I introduce only has any effect when flymake-mode is enabled in elisp buffers. 2. Currently, flymake-mode is pretty unsafe since it byte-compiles the file which can run arbitrary compile-time code in that file. 3. It doesn't make sense for an attacker to use the new variable as a file-local var since it's much easier to add some eval-when-compile instead to the file itself. 4. The only attack I could envision is to set the var in dir-locals.el, assuming the attacker had access to that file and not the other .el files that live in that directory. As i tried to explain, I added the validity spec to the variable, precisely because I thought 4 was pretty far-fetched, and couldn't find any other plausible scenario. Can you? Jo=C3=A3o > --000000000000366e7d057c4cd40b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, = Dec 5, 2018, 20:00 Glenn Morris <rgm@gnu.= org wrote:

>> +(put 'elisp-flymake-byte-compile-load-path 'safe-local-va= riable
>> +=C2=A0 =C2=A0 =C2=A0(lambda (x) (and (listp x) (catch 'tag >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (dolist (path x t) = (unless (stringp path)
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(throw 'tag = nil)))))))

AFAICS the above tests whether the value is valid, not whether it is safe.<= br> This should probably be a risky-local-variable, like load-path is.
The default "." seems actively dangerous, in much the same way as= having
"." in a shell's PATH is.

Glenn,

I'm aware of the difference between valid and saf= e. One of us is missing something:

1. The new variable I introduce only has any effect when flymake= -mode is enabled in elisp buffers.
2. Currently, fly= make-mode is pretty unsafe since it byte-compiles the file which can run ar= bitrary compile-time code in that file.
3. It doesn&= #39;t make sense for an attacker to use the new variable as a file-local va= r since it's much easier to add some eval-when-compile instead to the f= ile itself.=C2=A0
4. The only attack I could envisio= n is to set the var in=C2=A0
dir-locals.el, assuming= the attacker had access to that file and not the other .el files that live= in that directory.

As i= tried to explain,=C2=A0I added the = validity spec to the variable, precisely because=C2=A0I thought 4 wa= s pretty far-fetched, and couldn't find any other plausible scenario. C= an you?

Jo=C3=A3o
<= div dir=3D"auto">
--000000000000366e7d057c4cd40b--