Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OEM-> User transfer of devices ownership wizard, triggered by the presence of an empty /boot/oem file #507

Conversation

tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Jan 8, 2019

UPDATE: see QubesOS OEM to user transfer of ownership below for current state.

Advanced menu addition:
GPG card: factory reset, set key-attr to 4096bits, set passwords, generate keys, remove old keys from rom and insert public and trustdb back, and flash it.
Cryptsetup-reencrypt: reencrypt device and change recovery disk passphrase.

Please review. This is first draft. Everything works but it could be more beautiful and menus should probably be seperated.

@kyle: I was thinking of a oem file being present under /boot to engage a wizard or something.

druimalban and others added 19 commits January 5, 2018 21:09
…lly work, tools and libs updated to latest versions
…ty is used to enter passphrase. Else, gpg complaints of not being able to open /dev/tty, even though GPG_TTY environmenent variable is forced in init
…lled; trying to get console tty from the tty returns "no console". NEEDs BETTER FIX.
echo -e "\n"
cryptsetup-reencrypt -B 32 --use-directio $luks_container
else
echo "You have to reown the TPM, sign configurations with your GPG smartcard first and select a new default boot option!"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylerankin : Not ideal. Suggestions?

@tlaurion tlaurion force-pushed the x230_FBWhiptail_GPG2_clean_LibremKey-empty_keyring_detection-reown_hardware branch from f8b0665 to f3a44d2 Compare January 12, 2019 23:54
@tlaurion tlaurion closed this Jan 13, 2019
@tlaurion tlaurion reopened this Jan 13, 2019
@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 13, 2019

@kylerankin @flammit : please comment and suggest improvements in the functional code.

TODO:
For the OEM GPG part, I was thinking about asking input all at once to the user and store the results of input under /tmp/secret/ files:

  • gpg_card_user_password
  • gpg_card_admin_password
  • gpg_card_full_name
  • gpg_card_email
  • gpg_card_comment

And create subfunctions to create only one task, taking input from those /tmp/secret files if present, else ask for the information from the console for each of the actions ( Set user and admin passphrases and generate keys).

And then create different Whiptail menus for:

  • factory reset and set-attr
  • generate keys and import public and otrust
  • metamenu to call encompass them

For the drive reencryption code, I was thinking into splitting actual code into two submenus:

  • LUKS container reencryption (uses current Recovery passphrase and reencrypts everything)
  • LUKS Recovery key passphrase change
    And then create a meta menu that can do both manually, while oem code calls the functions directly.

@tlaurion tlaurion changed the title Whiptail advanced options: GPG card factory reset and reownership, key insertion to rom. cryptsetup-reencrypt of luks container OEM reownership wizard triggered by the presence of an empty /boot/oem file Jan 18, 2019
@tlaurion tlaurion changed the title OEM reownership wizard triggered by the presence of an empty /boot/oem file OEM-> User reownership wizard triggered by the presence of an empty /boot/oem file Jan 18, 2019
…o adding key and otrust output after GPG card key generation.
/initrd/bin/gui-init:
-inclusion of cryptsetup-reencrypt code
-WiP: Onboarding menu enforced by /boot/oem file being present
--State of onboarding progress is appended in that file.
-tpm ownership added into ownership process
-cryptsetup forced to change password on slot0. Learned my lesson: not specifying it makes cryptsetup writes the new password into slot 1, leaving slot 0 empty. As a result, the luksKillslot done by setting a new default wiped out the recovery password, making the Luks container without any key to unlock it.
Removing cryptsetup Whital yessno menu for a textbox. Was misleading to the user.
We want the user to not have any choice but continue the onboarding process until it's done.

TODO: move gpg2 code from /etc/functions to gui-init.
… non empty.

check_onboarding_progress inserts "onboarding" when it first checks checks that file.
Afterward, the C (Continue Ownership) is triggered when the /boot/oem file is found unempty.

check_onboarding_progress checks for status updates being inserted in /boot/oem and selects the proper menu until all unboarding is done.
In successive stages, the user is invited to:
Rencrypt LUKS container with a new key and Recovery passphrase
Factory reset it's GPG card, own it, genrate keys and insert public and trusdb export into reflashed rom.
TPM/HOTP reownership and sealing. (Might not be needed)

New menus are provided:
R: Reencrypt LUKS container and change it's password
F: Factory reset GPG card
@tlaurion tlaurion force-pushed the x230_FBWhiptail_GPG2_clean_LibremKey-empty_keyring_detection-reown_hardware branch from e476647 to 22b7e3d Compare January 18, 2019 04:47
@tlaurion tlaurion changed the base branch from gpg2 to master January 18, 2019 04:53
Copy link
Contributor

@itay-grudev itay-grudev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove the two CONFIG_GPG=y lines in the Librem config files. When I added the CONFIG_GPG2=y lines I wasn't sure if the old one should be removed or not, so I didn't do it.

boards/librem13v2/librem13v2.config Outdated Show resolved Hide resolved
boards/librem15v3/librem15v3.config Outdated Show resolved Hide resolved
@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 19, 2019

So at this point, here is what we have. I know, I need a better camera. That will happen soon. :)

OEM/tech-savvy user common parts:

  • Generate Heads ROM ( in the case of x230: make BOARD=x230-flash && make BOARD=x230). And flash it externally to hardware.
    • x230: Backup 4mb SPI flash chip, reflash x230-flash Heads rom on it, Backup 8mb SPI flash chip, apply me_cleaner on it and reflash it externally.
    • x230: On first boot of x230-flash Heads, mount-usb && flash.sh /media/coreboot.rom (12mb rom generated with make BOARD=x230)
  • On first boot of Heads, the user is given an error that Heads couldn't find any GPG keys in the keyring. He is invited to Add a GPG key to the running BIOS from a USB drive if the GPG card was preowned externally, or to Factory reset, own GPG card, generate and add key into running BIOS to do the whole process from inside of Heads, with generated key and trustdb being backuped onto USB drive under gpg_keys directory for further use, before taking a backup of running rom, deleting actual user keys found in it, and injecting generated public key and trustdb into that rom prior to flashing it back into SPI flash internally.
    new doc 2019-01-19 15 13 25_1
    • The GPG generated public key is valid for one year and that validity can be extended by the user. The key /gpg_keys/public.key can be published online and is a 4096 bits RSA key, ready to use, combined with it's private key, secured inside of the GPG card. By selecting Factory reset, own GPG card, generate and add key into running BIOS, the user also injected otrust.txt (trustdb: trusted keyring) inside of the rom, which is imported at each reboot, ultimately trusting generated user key.
  • On next reboot, the user/OEM is warned that Heads couldn't generate the TOTP code and is invited to Reset the TPM if he didn't own it yet with its own passphrase, or to Generate new TOTP/HOTP secret, to seal BIOS integrity attestation measures into the TPM and into GPG card with its previously chosen admin password.
    new doc 2019-01-19 15 13 25_2
  • At this point, the BIOS attestation with HOTP/TOTP is done and any modification done to it will detected. Here is a video demonstration of the user experience of LibremKey/Nitrokey Pro v2 in practice.
    new doc 2019-01-19 15 13 25_3
  • OEM/User then installs QubesOS from Heads (Whiptail) from Advanced Settings-> Other Boot Options -> USB boot which validates integrity of the ISO with companion .asc downloaded checksum signed file, while Heads validates that checksum authenticity with Heads included distro signatures keys
    new doc 2019-01-19 15 13 25_4
    new doc 2019-01-19 15 13 25_5
    new doc 2019-01-19 15 13 25_6
  • On next reboot when the OEM/user will attempt to select a default boot option from normal boot menu, he will receive an error saying that The file containing hashes for /boot is missing and will be prompted to update the checksums and sign them with his GPG card and linked user chosen password (PIN).
    new doc 2019-01-18 15 06 28_19
    new doc 2019-01-18 15 06 28_20
  • On next reboot, the user/OEM will be prompted to select a default boot option and Make it the default. By doing so, the user/OEM will enter Disk Recovery key passphrase chosen at OS installation, and will be prompted to choose a distinct Disk Unlock key, that will be released in LUKS slot 1 (instead of slot 0 by the Recovery Key) by the TPM only if it attests BIOS integrity. This is important for data privacy. By doing so, even if the user is filmed typing its Unlock disk passphrase (instead of typing otherwise his Disk Recovery Key), an attacker would only be able to access the disk content on this computer, and won't be able to clone that disk content and use that same passphrase to unlock it. Consequently, if the BIOS is tampered with/upgraded/modified, attempting to boot the default boot option while typing Disk Unlock Key passphrase won't work, which is an additional safeguard against external tampering.
    new doc 2019-01-18 15 06 28_22
    new doc 2019-01-18 15 06 28_23
    new doc 2019-01-18 15 06 28_24
    new doc 2019-01-18 15 06 28_25
    new doc 2019-01-18 15 06 28_26
    new doc 2019-01-18 15 06 28_27
    new doc 2019-01-18 15 06 28_28

OEM specifics:

  • After having done all the previous steps, the OEM enters recovery shell and enters: mount -o remount,rw /boot && touch /boot/oem && umount /boot && reboot
  • The OEM then ships the GPG card and computing hardware separately.

OEM-> user devices transfer of ownership:

  • The user plugs in the LibremKey/NitroKey Pro v2 and boots the hardware and gets the following:
    new doc 2019-01-18 15 06 28_1
    new doc 2019-01-18 15 06 28_2
    new doc 2019-01-18 15 06 28_3
    new doc 2019-01-18 15 06 28_4
    new doc 2019-01-18 15 06 28_5
    new doc 2019-01-18 15 06 28_6
    new doc 2019-01-18 15 06 28_7
    new doc 2019-01-18 15 06 28_8
    new doc 2019-01-18 15 06 28_9
    new doc 2019-01-18 15 06 28_10
    new doc 2019-01-18 15 06 28_11
    new doc 2019-01-18 15 06 28_12
    new doc 2019-01-18 15 06 28_13
    new doc 2019-01-18 15 06 28_14
    new doc 2019-01-18 15 06 28_15
    new doc 2019-01-18 15 06 28_16
    new doc 2019-01-18 15 06 28_17
    new doc 2019-01-18 15 06 28_18
    new doc 2019-01-18 15 06 28_19
    new doc 2019-01-18 15 06 28_20
    new doc 2019-01-18 15 06 28_21
    new doc 2019-01-18 15 06 28_22
    new doc 2019-01-18 15 06 28_23
    new doc 2019-01-18 15 06 28_24
    new doc 2019-01-18 15 06 28_25
    new doc 2019-01-18 15 06 28_26
    new doc 2019-01-18 15 06 28_27
    new doc 2019-01-18 15 06 28_28

@marmarek @mfc @andrewdavidwong @kylerankin @osresearch @flammit : Your input would be more then welcome. I'm going to use this PoC as it is for a start, but would love it to be mainstreamed and merge efforts to ease remote support of users.

This seals my PoC to go forward with the QubesOS Hardware Certification.
I await from you guys what kind of partnership/collaboration can be constructed to facilitate QubesOS adoption to a larger user base, mostly those who really need it.

@tlaurion tlaurion changed the title OEM-> User reownership wizard triggered by the presence of an empty /boot/oem file OEM-> User transfer of devices ownership wizard, triggered by the presence of an empty /boot/oem file Jan 19, 2019
@tlaurion
Copy link
Collaborator Author

replaced by #511

@tlaurion tlaurion closed this Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants