Subject: Re: [PATCH] doc: Add a security keys section to the cookbook.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 25 Nov 2022 10:37:04 -0500

Hi John,

John Kehayias <[email-masked]> writes:

> Hi Maxim,
>
> Thanks for this addition, I think it will definitely be useful to many
> people. Overall it looks good, a few minor notes on the text after I
> add some of my confusion to the udev rules question.

Thanks!

> For the udev rules, I tried without the plugdev group and it seemed
> like everything worked for me (though note I also use the pcscd
> service). In the past, I've had the plugdev group for the udev rules
> but not my user. I'm not sure why that is, perhaps the "uaccess" part
> of the rules? (I don't know much about this at all.) However, I did
> get system log messages "udevd[258]: specified group 'plugdev'
> unknown" which I'm guessing is due to me leaving that out of the udev
> rules service.

[...]

I think it may well be required for some use cases; if you grep the
libfido2 package for "plugdev", you'll find plenty references in
the 70-u2f.rules file like:

--8<---------------cut here---------------start------------->8---
/gnu/store/vy2pry1q2b1hhibsq4qchnr0v2xyah0r-libfido2-1.12.0/lib/udev/rules.d/70-u2f.rules:226:KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="311f", ATTRS{idProduct}=="a6e9", TAG+="uaccess", GROUP="plugdev", MODE="0660"
--8<---------------cut here---------------end--------------->8---

> A few minor notes on the text now:
>
>> +The use of security keys can improve your security by providing a second
>> +authentication source that cannot be easily stolen or copied (similar to
>> +the protection provided by mechanical keys for the door of your home or
>> +apartment), which reduces the risk of impersonation.
>> +
>
> Not to get into the weeds here, but maybe we can use the "standard"
> this is the "something you have" part of multi-factor authentication
> (the "one you know" being a password, of course).

I removed the door keys/locks example and rephrased it like:

--8<---------------cut here---------------start------------->8---
The use of security keys can improve your security by providing a second
authentication source that cannot be easily stolen or copied, at least
for a remote adversary (something that you have), to the main secret (a
passphrase -- something that you know), reducing the risk of
impersonation.
--8<---------------cut here---------------end--------------->8---

I hope that's a bit better.

> Also, should we use the keyword Universal 2nd Factor (U2F) standard
> somewhere? I believe this is the setup we need for that, but don't
> quote me on that.

I plugged that in the context indices: @cindex U2F, Universal 2nd Factor

>> +The example configuration detailed below showcases what minimal
>> +configuration needs to be made on your Guix System to allow the use of a
>> +Yubico security key.  We hope the configuration can be useful for other
>> +security keys as well, with minor adjustments.
>> +
>
> Super minor: do we use the "we" form much in the manual, at least in the system reference parts?

I think we try to refrain from doing so indeed, although the cookbook
feels a lot less formal to me than the reference manual.  I've adjusted
to use 'It is hoped [...]'.

>> +@subsection Configuration for use as a two-factor authenticator (2FA)
>> +
>> +Two be usable, the udev rules of the system should be extended with
>> +key-specific rules.  The following show how to extend your udev rules
>> +with the @file{lib/udev/rules.d/70-u2f.rules} udev rule file provided by
>> +the @code{libfido2} package from the @code{(gnu packages
>> +security-token)} module and add your user to the @samp{"plugdev"} group
>> +it uses:
>> +
>
> Minor typos: "Two" -> "To", "show" -> "shows"; comment above for "you" here.

Oof, thanks for catching these.  I think it's fine to address the reader
as "you".

>> +@lisp
>> +(use-package-modules ... security-token ...)
>> +...
>> +(operating-system
>> + ...
>> + (users (cons* (user-account
>> +               (name "your-user")
>> +               (group "users")
>> +               (supplementary-groups
>> +		'("wheel" "netdev" "audio" "video"
>> +                  "plugdev"))           ;<- added system group
>> +               (home-directory "/home/your-user"))
>> +              %base-user-accounts))
>> + ...
>> + (services
>> +  (cons*
>> +   ...
>> +   (udev-rules-service 'fido2 libfido2 #:groups '("plugdev")))))
>> +@end lisp
>> +
>> +After re-configuring your system and re-login to your graphical session,
>> +you can verify that your key is usable by launching:
>> +
>
> Minor: "re-login" probably should be "re-logging in" maybe?

I think so :-).

> I'm guessing logging in again is needed due to the group change?
> (Otherwise we have the nice change you made so that udev rules get
> picked up automatically, right?)

Yes.  I clarified this a bit.

>> +@example
>> +guix shell ungoogled-chromium -- chromium chrome://settings/securityKeys
>> +@end example
>> +
>
> Perhaps a simple website for testing u2f that works in other browsers?
> Sorry, don't have any off the top of my head, just wondering (as I
> don't normally use chromium).

Problems with websites is that they typically use nonfree JavaScript.  I
don't know of a smaller local tool to demo security keys unfortunately;
it'd be nice to have one!

>> +and validating that the security key can be reset via the ``Reset your
>> +security key'' menu.  If it works, congratulations, your security key is
>> +ready to be used with applications supporting two-factors authentication
>> +(2FA).
>
> Not familiar with the chromium settings here, is there something less
> potentially drastic to check? I didn't dare touch that as my security
> key is already set up (private keys backed up of course, but still).

I'm not sure.  I feel the resetting of the key should only affect the
operation of Chromium rather than like erase your secrets off your key,
but don't take my word for it, it's just a guest.

> Sorry for some of the more nitpick-y text things, probably reading and
> grading too many papers recently :) Overall will be a nice addition,
> thanks!

Thanks a lot for going through it!  It sure came out better.

Now pushed!

-- 
Thanks,
Maxim