all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Emma Turner <em.turner@tutanota.com>,
	57909@debbugs.gnu.org, 57910@debbugs.gnu.org
Subject: [bug#57909] Add link to 'pre-inst-env' from 'installing from git' docs
Date: Sun, 18 Sep 2022 20:53:23 +0200	[thread overview]
Message-ID: <975274c2-e4da-e310-8a88-731e7c429828@telenet.be> (raw)
In-Reply-To: <966568a4-17f7-c0f0-25a4-6f6e2928b0e7@telenet.be>


[-- Attachment #1.1.1: Type: text/plain, Size: 513 bytes --]



On 18-09-2022 19:26, Maxime Devos wrote:
> [...]
> 
> As such, I propose that:
> 
>    * you adjust the patch to note that authenticating the checkout is
>      impossible if you don't already have Guix installed (instead of
>      recommending the insecure "make authenticate")
> 
>    * I write a patch removing "make authenticate" and adjusting old uses
>      of "make authenticate" to "guix git authenticate ...".


I have attached a patch for the latter.

Greetings,
Maxime.

[-- Attachment #1.1.2: 0001-WIP-Only-use-make-authenticate-for-etc-git-pre-push.patch --]
[-- Type: text/x-patch, Size: 4859 bytes --]

From a00ac3d016131f05c977e727f8ac15ea437aec7e Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Sun, 18 Sep 2022 19:52:16 +0200
Subject: [PATCH] WIP Only use "make authenticate" for etc/git/pre-push.

As mentioned in <https://issues.guix.gnu.org/57909>, "make authenticate"
cannot be used for authentication, as it makes use of a Makefile.am
(and configure.ac) that might be provided by the attacker.

As such, only use this is the etc/git/pre-push hook, where it can be
reasonably assumed the current commit is 'safe' and it only needs
to check that the safety is properly conveyed to other people (by
having the commits be signed correctly).

To aid with the transition from "make authenticate" to "guix git
authenticate", print an error message from "make authenticate",
directing the user to use the safe "guix git authenticate" instead.

TODO missing: other uses of "make authenticate" in the documentation.

* Makefile.am (authenticate): Rename to ...
(authenticate-self-check): ... this, and add a new target
(authenticate): that depends on authenticate-self-check and additionally
prints the error message.
* doc/contributing.texi (Commit Access): Adjust for target rename.
* etc/git/pre-push: Adjust for target rename.
---
 Makefile.am           | 20 ++++++++++++++------
 doc/contributing.texi |  2 +-
 etc/git/pre-push      |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 22dcc43f99..bfabf0bf2e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@
 # Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
 # Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
 # Copyright © 2021 Andrew Tropin <andrew@trop.in>
+# Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
 #
 # This file is part of GNU Guix.
 #
@@ -804,12 +805,19 @@ channel_intro_signer = BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA
 
 # Authenticate the current Git checkout by checking signatures on every commit.
 GUIX_GIT_KEYRING = origin/keyring
-authenticate:
+authentication_command = guix git authenticate '--keyring=$(GUIX_GIT_KEYRING)' --cache-key=channels/guix --stats '$(channel_intro_commit)' '$(channel_intro_signer)'
+authenticate-self-check:
 	$(AM_V_at)echo "Authenticating Git checkout..." ;	\
-	guix git authenticate					\
-	    --keyring=$(GUIX_GIT_KEYRING)			\
-	    --cache-key=channels/guix --stats			\
-	    "$(channel_intro_commit)" "$(channel_intro_signer)"
+	$(authentication_command)
+authenticate: authenticate-self-check
+	$(AM_V_at)echo "\"make authenticate\" is insecure, you need to run"
+	$(AM_V_at)echo "$(authentication_command)"
+	$(AM_V_at)echo "instead.  Do **not** do that inside a ./pre-inst-env,"
+	$(AM_V_at)echo "that would be insecure because of a TOCTTOU problem."
+	$(AM_V_at)echo "Because of the TOCTTOU problem, you likely cannot trust"
+	$(AM_V_at)echo "these instructions unless you have already"
+	$(AM_V_at)echo "authenticated the repository by other means."
+	$(AM_V_at)exit 1
 
 # Assuming Guix is already installed and the daemon is up and running, this
 # rule builds from $(srcdir), creating and building derivations.
@@ -1076,7 +1084,7 @@ cuirass-jobs: $(GOBJECTS)
 .PHONY: gen-ChangeLog gen-AUTHORS gen-tarball-version
 .PHONY: assert-no-store-file-names assert-binaries-available
 .PHONY: assert-final-inputs-self-contained check-channel-news
-.PHONY: clean-go make-go as-derivation authenticate
+.PHONY: clean-go make-go as-derivation authenticate authenticate-self-check
 .PHONY: update-guix-package update-NEWS cuirass-jobs release
 
 # Downloading up-to-date PO files.
diff --git a/doc/contributing.texi b/doc/contributing.texi
index de1d34cc03..353cb71caf 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -1740,7 +1740,7 @@ git config user.signingkey CABBA6EA1DC0FF33
 To check that commits are signed with correct key, use:
 
 @example
-make authenticate
+make authenticate-self-check
 @end example
 
 You can prevent yourself from accidentally pushing unsigned or signed
diff --git a/etc/git/pre-push b/etc/git/pre-push
index 59671b0d58..7fdc533d09 100755
--- a/etc/git/pre-push
+++ b/etc/git/pre-push
@@ -32,7 +32,7 @@ do
 		# Only use the hook when pushing to Savannah.
 		case "$2" in
 		    *.gnu.org*)
-			exec make authenticate check-channel-news
+			exec make authenticate-self-check check-channel-news
 			exit 127
 			;;
 		    *)

base-commit: 31a56967e2869c916b7a5e8ee570e8e10f0210a5
prerequisite-patch-id: 2712efb97bf33985fd0658e4dd8e936dc08be5fe
prerequisite-patch-id: 9d2409b480a8bff0fef029b4b095922d4957e06f
prerequisite-patch-id: 51a32abca3efec1ba67ead59b8694c5ea3129ad3
prerequisite-patch-id: 9092927761a340c07a99f5f3ed314a6add04cdee
prerequisite-patch-id: d0af09fbd5ee0ef60bdee53b87d729e46c1db2ca
prerequisite-patch-id: 4fee177b2d8c9478c6a7b8ce1ca9072942f39863
-- 
2.37.3


[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2022-09-18 18:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 11:47 [bug#57909] Add link to 'pre-inst-env' from 'installing from git' docs Emma Turner via Guix-patches via
2022-09-18 12:41 ` [bug#57910] [PATCH] " Emma Turner via Guix-patches via
2022-09-19  9:37   ` Emma Turner via Guix-patches via
2022-09-18 14:59 ` bug#57909: Sorry - accidentally opened duplicate issues Emma Turner via Guix-patches via
2022-09-19 13:01   ` [bug#57909] " Maxime Devos
2022-09-18 17:26 ` [bug#57910] [bug#57909] Add link to 'pre-inst-env' from 'installing from git' docs Maxime Devos
2022-09-18 18:53   ` Maxime Devos [this message]
2022-09-19  6:12     ` Emma Turner via Guix-patches via
2022-09-19 13:27       ` Maxime Devos
2022-09-24 15:58   ` [bug#57909] bug#57910: [PATCH] " Ludovic Courtès
2022-09-24 16:23     ` Maxime Devos
2022-09-25 20:05       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=975274c2-e4da-e310-8a88-731e7c429828@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=57909@debbugs.gnu.org \
    --cc=57910@debbugs.gnu.org \
    --cc=em.turner@tutanota.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.