From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-devel-bounces+larch=yhetil.org@gnu.org>
Received: from mp1 ([2001:41d0:2:c151::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms11 with LMTPS
	id wNx2D0NxM2D0UgAA0tVLHw
	(envelope-from <guix-devel-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 22 Feb 2021 08:54:27 +0000
Received: from aspmx2.migadu.com ([2001:41d0:2:c151::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1 with LMTPS
	id UOE2C0NxM2ASDwAAbx9fmQ
	(envelope-from <guix-devel-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Mon, 22 Feb 2021 08:54:27 +0000
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx2.migadu.com (Postfix) with ESMTPS id E7576279B6
	for <larch@yhetil.org>; Mon, 22 Feb 2021 09:54:26 +0100 (CET)
Received: from localhost ([::1]:57580 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-devel-bounces+larch=yhetil.org@gnu.org>)
	id 1lE6z3-00087v-Rs
	for larch@yhetil.org; Mon, 22 Feb 2021 03:54:25 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:57528)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@gnu.org>) id 1lE6yw-00087n-5u
 for guix-devel@gnu.org; Mon, 22 Feb 2021 03:54:18 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50637)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@gnu.org>)
 id 1lE6yu-0002Dq-9m; Mon, 22 Feb 2021 03:54:16 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42000 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@gnu.org>)
 id 1lE6yt-0005mC-FC; Mon, 22 Feb 2021 03:54:15 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@gnu.org>
To: Maxime Devos <maximedevos@telenet.be>
Subject: Re: TOCTTOU race
References: <YBMybeFOP0VfW6G7@jasmine.lan> <87k0rrls0z.fsf@gnu.org>
 <08F0CD76-DDCF-4CFA-AE8D-5FB165A62B25@lepiller.eu>
 <c7e82df3921fb0eaefb9db798d634f63f6eb0142.camel@telenet.be>
 <87o8h2ehy7.fsf@gnu.org>
 <69968b3a01d872cabdf55a94b6c82d5057e010c9.camel@telenet.be>
 <87v9b66dm1.fsf@gnu.org>
 <56adb5efa894304c27beba99b07e2f8cfd8ee7cb.camel@telenet.be>
 <87zh0gzy52.fsf@gnu.org>
 <53c60ce40d68cfc93a9ea2c4a8f865026e12c889.camel@telenet.be>
 <87h7m9p8hd.fsf@gnu.org>
 <ef430e273b9199014038403d4deeaf9dbcb85e49.camel@telenet.be>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 4 =?utf-8?Q?Vent=C3=B4se?= an 229 de la =?utf-8?Q?R?=
 =?utf-8?Q?=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 22 Feb 2021 09:54:13 +0100
In-Reply-To: <ef430e273b9199014038403d4deeaf9dbcb85e49.camel@telenet.be>
 (Maxime Devos's message of "Fri, 19 Feb 2021 19:01:11 +0100")
Message-ID: <87r1l8eb4a.fsf@gnu.org>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-BeenThere: guix-devel@gnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: "Development of GNU Guix and the GNU System distribution."
 <guix-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-devel>,
 <mailto:guix-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guix-devel>
List-Post: <mailto:guix-devel@gnu.org>
List-Help: <mailto:guix-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-devel>,
 <mailto:guix-devel-request@gnu.org?subject=subscribe>
Cc: guix-devel@gnu.org
Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org
Sender: "Guix-devel" <guix-devel-bounces+larch=yhetil.org@gnu.org>
X-Migadu-Flow: FLOW_IN
X-Migadu-Spam-Score: -2.87
Authentication-Results: aspmx2.migadu.com;
	dkim=none;
	dmarc=pass (policy=none) header.from=gnu.org;
	spf=pass (aspmx2.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org
X-Migadu-Queue-Id: E7576279B6
X-Spam-Score: -2.87
X-Migadu-Scanner: scn1.migadu.com
X-TUID: vy2m8LjMEMmp

Hi Maxime,

Maxime Devos <maximedevos@telenet.be> skribis:

> On Thu, 2021-02-18 at 18:54 +0100, Ludovic Court=C3=A8s wrote:

[...]

>> Note that, if that happens at boot time, the system will fail to boot (I
>> think you=E2=80=99d get a REPL rather than a kernel panic, but it=E2=80=
=99d be good to
>> check in a VM.)
>
> If that happens, that's too bad.  Just ignoring the error seems bad from
> a security perspective.  I verified in a VM you'd get a REPL.
> From the REPL, a sysadmin could investigate and choose to delete the offe=
nding
> symlink & reboot (and presumably fix the security bug and upgrade the ser=
vice),
> or decide Guix System needs to be reinstalled.

OK, sounds reasonable.

> Please take note that I didn't correct all potentially insecure activatio=
n gexps.
> These should ideally be done by someone who knows how to use the particul=
ar service
> and have a system to test it on.  (My changes to nscld-service-type and k=
not-activation
> are untested.)

I agree this is how it should happen ideally=E2=80=A6 let=E2=80=99s see if =
things happen
=E2=80=9Cideally=E2=80=9D.  :-)

> From 2c3968f658ada27d2062a960d229f3db9cfe208c Mon Sep 17 00:00:00 2001
> From: Maxime Devos <maximedevos@telenet.be>
> Date: Sun, 14 Feb 2021 12:57:32 +0100
> Subject: [PATCH] services: prevent following symlinks during activation
                             ^
Nitpick: we usually capitalize here and in the commit log.

Perhaps add a couple of lines explaining that this fixes a potential
security issue, with a link to this thread.

> Currently, there's a TOCTTOU race.  This can be addressed
> once guile has bindings for fstatat, openat and friends.

I=E2=80=99d move that comment next to the =E2=80=98mkdir-p/perms=E2=80=99 d=
efinition.

> * guix/build/service-utils.scm: new module
>   with new procedure 'mkdir-p/perms'.

I think you can remove these lines.

> * Makefile.am (MODULES): compile new module.
> * gnu/services/authentication.scm
>   (%nslcd-activation, nslcd-service-type): use new procedure.
> * gnu/services/cups.scm (%cups-activation): likewise.
> * gnu/services/dbus.scm (dbus-activation): likewise.
> * gnu/services/dns.scm (knot-activation): likewise.

LGTM for master, thanks!

Ludo=E2=80=99.