From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#45198: 28.0.50; Sandbox mode Date: Sun, 13 Dec 2020 13:43:23 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16930"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Bastien , 45198@debbugs.gnu.org, =?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 Sun Dec 13 19:44:10 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 1koWLq-0004IG-8y for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 19:44:10 +0100 Original-Received: from localhost ([::1]:52838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koWLp-0000Rf-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 13:44:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koWLi-0000Pa-HO for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:44:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koWLi-0004bU-AW for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koWLi-0004LI-8t for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Dec 2020 18:44: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.160788501416564 (code B ref 45198); Sun, 13 Dec 2020 18:44:02 +0000 Original-Received: (at 45198) by debbugs.gnu.org; 13 Dec 2020 18:43:34 +0000 Original-Received: from localhost ([127.0.0.1]:50224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koWLF-0004Ix-Tc for submit@debbugs.gnu.org; Sun, 13 Dec 2020 13:43:34 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koWLE-0004IP-8H for 45198@debbugs.gnu.org; Sun, 13 Dec 2020 13:43:32 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D6D641002B8; Sun, 13 Dec 2020 13:43:26 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6947C10022E; Sun, 13 Dec 2020 13:43:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1607885005; bh=xma7jsPMN6c+gzRTJjPnZi/Z+lobwPlxFNDfwpnAYIE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=AoHI0YtnbrZE+Y8lAPturHtvCCKTwq4w2e/wQyxpDSliGKUPyIQ/boigPNs7B+ZY6 02XEuID8/7PT3n+kqOHVh8WvYYxbqdQiKiRUgNsAmtmhbhIrUPyTi3tWeMtlQTngAl C4ztmqX4hVnvo5iDWLJIYxQp7NxA9Z4h1t2joFbYCat8n2UDPPvODY1qjrhWXDRYru AKUU/S58N8MTk+LeUaF17pGuiRW0llAaTx9Ouu9/EMfI2nXMjmY7rPmfLo/9P6NHOe zdsGzJs/d6Is/JMyGKZtIoNY/1sMdY1YGK7RG2nnNl2W54czUXH68eAbmnkoGdT6fi F8Ass7hTXyuCA== Original-Received: from alfajor (69-165-136-52.dsl.teksavvy.com [69.165.136.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 261321201B2; Sun, 13 Dec 2020 13:43:25 -0500 (EST) In-Reply-To: (Philipp Stephani's message of "Sun, 13 Dec 2020 19:13:35 +0100") 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:195993 Archived-At: > The sandboxing technologies I'm aware of are process-based (because > Linux namespaces and kernel syscall filters are per-process), so a > "start sandbox from here" function likely can't be implemented. The > interface should rather be something like > > (defun run-in-sandbox (form) > (eql 0 (call-process "bwrap" ... "emacs" "--quick" "--batch" (format > "--eval=%S" form)))) > > (Maybe with some async variant and the opportunity to return some > result, like emacs-async.) Thanks. We definitely want some output, otherwise there's no point in running `form`, right? Also, I think the async option is the most important one. How 'bout: (sandbox-start FUNCTION) Lunch a sandboxed Emacs subprocess running FUNCTION. Returns a process object. FUNCTION is called with no arguments and it can use `sandbox-read` to read the data sent to the process object via `process-send-string`, and `sandbox-reply` to send back a reply to the parent process (which will receive it via its `process-filter`). The sandboxed process has read access to all the local files but no write access to them, nor any access to the network or the display. WDYT? >> - I suspect we'll still want to use the extra "manual" checks I put in >> my code (so as to get clean ELisp errors when bumping against the >> walls of the sandbox, and because of the added in-depth security). > That's reasonable, though I'm worried that it will give users a false > sense of security. That would only be the case if we don't additionally use process-level isolation, right? >> - This will need someone else doing the implementation. > Looks like we already have a volunteer for macOS. > For Linux, this shouldn't be that difficult either. The sandbox needs > to install a mount namespace that only allows read access to Emacs's > installation directory plus any input file and write access to known > output files, and enable syscall filters that forbid everything except > a list of known-safe syscalls (especially exec). I can take a stab at > that, but I can't promise anything ;-) Looking forward to it. Stefan