From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#45198: 28.0.50; Sandbox mode Date: Sun, 13 Dec 2020 19:13:35 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8739"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Bastien , 45198@debbugs.gnu.org, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 13 19:14:11 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 1koVso-0002Bt-MG for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 19:14:10 +0100 Original-Received: from localhost ([::1]:57692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1koVsn-0005SD-Mv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Dec 2020 13:14:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1koVsg-0005Pn-7b for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:14:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1koVsg-0007fD-0U for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1koVsf-0002qj-Ru for bug-gnu-emacs@gnu.org; Sun, 13 Dec 2020 13:14:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Dec 2020 18:14:01 +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.160788323510931 (code B ref 45198); Sun, 13 Dec 2020 18:14:01 +0000 Original-Received: (at 45198) by debbugs.gnu.org; 13 Dec 2020 18:13:55 +0000 Original-Received: from localhost ([127.0.0.1]:50089 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koVsY-0002qF-Pq for submit@debbugs.gnu.org; Sun, 13 Dec 2020 13:13:55 -0500 Original-Received: from mail-oi1-f169.google.com ([209.85.167.169]:36982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1koVsW-0002py-Oe for 45198@debbugs.gnu.org; Sun, 13 Dec 2020 13:13:53 -0500 Original-Received: by mail-oi1-f169.google.com with SMTP id l207so16639372oib.4 for <45198@debbugs.gnu.org>; Sun, 13 Dec 2020 10:13:52 -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=3Cg8XRaYwrmO/GiGsv6IskmDMoQI/lXKAvuiN1wSDmY=; b=P8X4NW5GW9x0CQKsfjDy6upTde9B4yIgaZj8PuDsgQhF2jM/HwGy/ymqjWBLRpy9lK tNMhLv9RyCi/7nOVmlyGAn2lZGeBBeiQ8Q5QvHokp/8YfrcLARN0Wser1dyyHepgqO8h L7s2byBmAc3sbi16XICTogP9452/dDfmdXO0fxz/z/JzUpxUmsrLN9D+t3irPXndMs02 VkJI24I9EnBWxaZK/B7smGNXfsZy9WVh9Ui5iPTcMcdAo73hJfbhCQqbnsoVDEwbJ9/l bOFaRq3rcD9L7TOKSCOozSQ+jarTFjETP+4qIQgf7dYaYw5Ikgcv+ErAr2ghRGR6zOAG T6wg== 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=3Cg8XRaYwrmO/GiGsv6IskmDMoQI/lXKAvuiN1wSDmY=; b=RdE4MEjDg2gTjx7mdwjv4eKFYRfFq4GQCJtXcjLsFTo9pufQhlVPICfxL7sO4Fd4CC 9ZD6dSSX6B0yBe4Mmpy3yQzNsHS/r2dd38/ucZ8HyGolmZ9xM7RPYAFQod/PgtHZkbqc GzSZlhIMQJ1swW+nZc2v/csw4wS45eN9f97UtFCI3qIsJVg5MzyVNdVSIWGaMyY26qBt c5rSBgH1waStghmKFuCMlYetUcO3aZj+3tgoDwt0YkCcsLM1e59qngbtJoiEj9c5IelI 4KDGpRtDWlZUGX4zfkhvktTu53XqYWJJ4g8vOkQ01+l3fSCfIxC3gUPxQefSFbaEur8K scYw== X-Gm-Message-State: AOAM5337ZCVwOIax9pVyO75fhK4o6xTMyWYUx7FjCT1pkar2KtSQXJyI 11cXHr8rmnmBqiT/DlTAMrkCasHk6ORoRY6jp3Q= X-Google-Smtp-Source: ABdhPJy0g4gyq9R9Sc9NCObwJEbqU2dd/xeHPuu1dV4eqM5aMEZYgTCzjfrUTMUwyDOgRmmVMJOATLnzRpnEFU6DwrA= X-Received: by 2002:a54:4881:: with SMTP id r1mr15576450oic.9.1607883227036; Sun, 13 Dec 2020 10:13:47 -0800 (PST) In-Reply-To: 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:195989 Archived-At: Am So., 13. Dez. 2020 um 18:57 Uhr schrieb Stefan Monnier : > > > I don't think such an approach can work. It assumes perfect knowledge > > about anything that might be problematic, and also assumes that all > > future changes to Emacs take the sandbox question into account. > > Especially the latter point seems unrealistic, and this looks like a > > security incident waiting to happen. > > That's true for the implementation side. > How 'bout the ELisp API side? > > > Sandboxing is good, but it should happen using an allowlist and > > established technology, such as firejail/bubblewrap/Google sandboxed > > API/... 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.) > > I'm all for it, *but*: > - 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. > - 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 ;-) > - The ELisp-level API should not depend on the specific implementation > too much, since none of those established technologies sound like > things that'll still be maintained 10 years from now. Yes, I'd imagine the API to be something like ;; Returns an opaque "sandbox" object. (cl-defun start-sandbox (form &key input-files output-files) ...) (defun wait-for-sandbox (sandbox) ...) That would allow for some extensibility and also asynchronicity. The API should fail if it can't establish a sandbox (e.g. if none of the sandbox technologies are installed). > - We need to have this in Emacs-28 if we want to enable flymake-mode in > ELisp by default in Emacs-28 (which I sure would like to do). I guess having it in Emacs 28 is realistic, unless that is going to be feature-frozen soon.