From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#45198: 28.0.50; Sandbox mode Date: Mon, 14 Dec 2020 16:59:28 +0100 Message-ID: References: <0917E396-F78C-45BF-8A1F-5C23CA722D9A@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3240"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Bastien , 45198@debbugs.gnu.org, Stefan Monnier , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 14 17:12:17 2020 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 1koqSO-0000l8-Sx for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 17:12:16 +0100 Original-Received: from localhost ([::1]:51082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koqSN-00015D-Tg for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Dec 2020 11:12:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koqGY-0002F7-Ll for bug-gnu-emacs@gnu.org; Mon, 14 Dec 2020 11:00:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koqGY-0001eB-AL for bug-gnu-emacs@gnu.org; Mon, 14 Dec 2020 11:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koqGY-0005w0-6x for bug-gnu-emacs@gnu.org; Mon, 14 Dec 2020 11:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Dec 2020 16:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45198 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45198-submit@debbugs.gnu.org id=B45198.160796159022762 (code B ref 45198); Mon, 14 Dec 2020 16:00:02 +0000 Original-Received: (at 45198) by debbugs.gnu.org; 14 Dec 2020 15:59:50 +0000 Original-Received: from localhost ([127.0.0.1]:53902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koqGM-0005v4-BI for submit@debbugs.gnu.org; Mon, 14 Dec 2020 10:59:50 -0500 Original-Received: from mail1467c50.megamailservers.eu ([91.136.14.67]:46476 helo=mail268c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koqGJ-0005up-KE for 45198@debbugs.gnu.org; Mon, 14 Dec 2020 10:59:48 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1607961581; bh=Oj5Q//4lDswoLErmbEEJih8a143ppiuA1udskDE/56Y=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=C7kiHxyTmuF3FvD39bAgm07RjFCo2wDULZFBBssWq1WJKs6/MI/U/A7uSqtJ8AyK/ dkGvZBdNm5G2YstApeBLgznZ7qBVVt+KIhBqJlz0zRFAmLmVAoTC9D/536RnGFvkUm Yb25MejvoCa+lLD0l6bGBdIlcQnVuhcbBSzhDQ2c= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail268c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0BEFxS6R018925; Mon, 14 Dec 2020 15:59:36 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F29.5FD78BEC.004F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=J+PUEzvS c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=pGLkceISAAAA:8 a=ktOLASWPuep7Hyu_2dEA:9 a=CjuIK1q_8ugA:10 X-Origin-Country: SE 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" Xref: news.gmane.io gmane.emacs.bugs:196063 Archived-At: 14 dec. 2020 kl. 14.44 skrev Philipp Stephani : > Yes, it's not strictly required (as in, seccomp and unshare nominally > work at any point), though I think enabling sandboxing while user code > has already run can have confusing/unanticipated consequences. For > example, other threads might already be running in parallel, and they > would then suddenly be blocked from making some syscalls, potentially > in the middle of a critical section or similar. There shouldn't be many threads running in non-interactive mode, and = those that are must be expected to work with the added restrictions = because why should they be exempt and what are they doing that we want = to forbid anyway? It seems a bit far-fetched and probably not an = immediate concern. That said, it is very much an implementation matter -- the = run-function-in-sandbox Lisp interface seems better than the original = enter-sandbox because we get more ways to write the code. Thanks for = proposing it! > For example, to achieve some amount of capability-based > security, you'd open files before sandboxing and then forbid the open > syscall, but that's not really possible with the current Emacs API > (which doesn't provide any access to open files). Well, almost -- elisp processes serve some of the purposes of open file = descriptors, at least for pipes and sockets. Is it really is practical to restrict file-system visibility? A spawned = byte-compiler will need to read almost arbitrary elisp files (autoload, = 'require' calls) whose exact names are only known at runtime. Were you = planning to build a name-space from a skeleton populated by load-path = mounts? My initial thought was simply inhibit pretty much everything except = reading files and writing to already open descriptors (or just = stdout/stderr), on the grounds that while it would enable an adversary = to read anything, exfiltration would be difficult. (Some side-channels may be worth thinking about: if the machine cannot = trust its file servers, it is possible to exfiltrate data to an already = compromised server merely by reading. But then there are probably more = direct approaches.) > Even on Unix, a fork that's not immediately followed by an exec or > exit tends to not work any more. Lots of libraries nowadays assume > that the "weird in-between state" after a fork doesn't exist > permanently, and only a small number of async-signal-safe syscalls are > guaranteed to work between fork and exec. Yes, and I'm aware of the difficulties but wouldn't dismiss it out of = hand since the gains are attractive. The main trouble stems from fork = only bringing the calling thread into the new process, which may cause = deadlock if those threads were holding locks which the forked process = goes on to acquire later on. (pthread_atfork is supposed to be used by = threaded libraries but typically isn't.) It does work given some care (and I have done so in the past to good = effect); it's mainly a matter of not touching anything that you don't = want to use anyway such as GUI frameworks. In Emacs, this would be done = in some sort of become_noninteractive function which ensures that future = program flow will not involve any GUI code whatsoever. Let's see what latency we get from spawning a typically overloaded Emacs = configuration first.