Diff for /wikisrc/security/cgdroot.mdwn between versions 1.10 and 1.17

version 1.10, 2017/02/10 10:55:36 version 1.17, 2018/04/14 21:48:34
Line 1 Line 1
 Root filesystem encryption  [[!meta title="Root Filesystem Encryption"]]
 ==========================  
   
 It is possible to run NetBSD with [complete root filesystem encryption][1], thanks to the `cgdroot.kmod` kernel module. It really is a memory disk (also knows as RAM disk) that is expected to be loaded in the kernel while booting. It is named after CGD, the "cryptographic device driver", which implements encryption for storage in the NetBSD kernel.  It is possible to run NetBSD with [complete root filesystem encryption][1], thanks to the `cgdroot.kmod` kernel module. It really is a memory disk (also knows as RAM disk) that is expected to be loaded in the kernel while booting. It is named after CGD, the "cryptographic device driver", which implements encryption for storage in the NetBSD kernel.
   
Line 19  The boot partition on disk needs to cont Line 18  The boot partition on disk needs to cont
 * a GENERIC kernel  * a GENERIC kernel
 * the `cgdroot.kmod` kernel module  * the `cgdroot.kmod` kernel module
 * the configuration file for CGD, `cgd.conf`  * the configuration file for CGD, `cgd.conf`
 * the encryption key for the volume to start from, named after its partition (like `wd0f`)  * the CGD parameters file for the volume, named after its partition (like `wd0f`), which determines how the encryption key is derived and verified
   
 Once loaded the memory disk mounts the `wd0a` partition onto `/etc/cgd`, and asks for the encryption passphrase as usual (with [[!template id=man name="cgdconfig" section="8"]]). If successful, the `cgd0a` volume configured is mounted on `/altroot`, and [[!template id=man name="init" section="8"]] is told via [[!template id=man name="sysctl" section="7"]] to chroot into this volume before actually booting. The system then starts normally.  Once loaded the memory disk mounts the `wd0a` partition onto `/etc/cgd`, and asks for the encryption passphrase as usual (with [[!template id=man name="cgdconfig" section="8"]]). If successful, the `cgd0a` volume configured is mounted on `/altroot`, and [[!template id=man name="init" section="8"]] is told via [[!template id=man name="sysctl" section="7"]] to chroot into this volume before actually booting. The system then starts normally.
   
Line 29  really ran from a chroot in `/altroot`. Line 28  really ran from a chroot in `/altroot`.
 Obtaining the kernel module  Obtaining the kernel module
 ---------------------------  ---------------------------
   
 The `cgdroot.kmod` kernel module is part of the regular NetBSD releases since NetBSD 7.0. It can be found in the `<arch>/installation/miniroot` folder from the release. For instance, for the amd64 architecture on the German mirror for the 7.0.1 release, download it at (ftp://ftp.de.netbsd.org/pub/NetBSD/NetBSD-7.0.1/amd64/installation/miniroot/cgdroot.kmod).  The `cgdroot.kmod` kernel module is part of the regular NetBSD releases since NetBSD 7.0. It can be found in the `<arch>/installation/miniroot` folder from the release. For instance, for the amd64 architecture on the German mirror for the 7.0.1 release, download it at [ftp.de.netbsd.org/pub/NetBSD/NetBSD-7.0.1/amd64/installation/miniroot/cgdroot.kmod](ftp://ftp.de.netbsd.org/pub/NetBSD/NetBSD-7.0.1/amd64/installation/miniroot/cgdroot.kmod).
   
 Configuring the kernel module  Configuring the kernel module
 -----------------------------  -----------------------------
Line 65  Then the kernel module can be built: Line 64  Then the kernel module can be built:
 src/distrib/amd64/kmod-cgdroot$ /path/to/tooldir/bin/nbmake-amd64  src/distrib/amd64/kmod-cgdroot$ /path/to/tooldir/bin/nbmake-amd64
 """]]  """]]
   
   It will be found in `/path/to/objdir/distrib/amd64/kmod-cgdroot/cgdroot.kmod`.
   
 Caveats  Caveats
 -------  -------
   
 The biggest (known) issue with this setup occurs when firmware needs to be loaded early in the boot process (such as graphics drivers for the console). At the moment they need to be provided as part of the memory disk. Some network interfaces, of which some wireless devices in particular, also require loading firmware to work properly.  The biggest (known) issue with this setup occurs when firmware needs to be loaded early in the boot process (such as graphics drivers for the console). At the moment they need to be provided as part of the memory disk. Some network interfaces, of which some wireless devices in particular, also require loading firmware to work properly.
   
 This setup is not entirely safe against physical attacks. An attacker can modify the boot process to store the passphrase for later retrieval, or insert a backdoor while booting. To defend against such attacks, the bootloader, kernel and ramdisk all need to be signed and their integrity checked before booting (eg with [[!template id=man name="tpm" section="4"]]). Alternatively, it is possible to boot from a removable medium (eg USB stick), which can be protected against tampering attacks (eg secure storage, read-only volume...).  Firmware that can be loaded later (e.g. microcode in `sysutils/intel-microcode-netbsd`) can be found only if the corresponding paths in the `hw.firmware` sysctl variable are adjusted to start with `/altroot`. 
   
   This setup is not entirely safe against physical attacks. An attacker can modify the boot process to store the passphrase for later retrieval, or insert a backdoor while booting. To defend against such attacks, the bootloader, kernel and ramdisk all need to be signed and their integrity checked before booting (e.g. with [[!template id=man name="tpm" section="4"]]). Alternatively, it is possible to boot from a removable medium (e.g. USB stick), which can be protected against tampering attacks (e.g. secure storage, read-only volume...).
   
 It is also possible to boot a Xen DOM0 system with root filesystem encryption. However, Xen-enabled NetBSD kernels currently do not support loading modules at boot-time. The memory disk has to be placed directly inside the kernel instead (with [[!template id=man name="mdconfig" section="8"]] or a new kernel configuration).  It is also possible to boot a Xen DOM0 system with root filesystem encryption. However, Xen-enabled NetBSD kernels currently do not support loading modules at boot-time. The memory disk has to be placed directly inside the kernel instead (with [[!template id=man name="mdconfig" section="8"]] or a new kernel configuration).
   
   It should really be possible to install NetBSD this way with [[!template id=man name="sysinst" section="8"]]. Unfortunately this is not supported yet.
   
 References  References
 ----------  ----------
   

Removed from v.1.10  
changed lines
  Added in v.1.17


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb