Skip to content

`calamares-nixos-extensions` LUKS keyfile exposure

Critical
RaitoBezarius published GHSA-3rvf-24q2-24ww Jun 28, 2023

Package

Graphical Calamares Installer (NixOS)

Affected versions

≤0.3.12

Patched versions

0.3.13

Description

Impact

Users who installed NixOS through the graphical calamares installer, with an unencrypted /boot, on either:

  • non-UEFI systems
  • with a LUKS partition different from /

have their LUKS key file in /boot as a plaintext CPIO archive attached to their NixOS initrd.

nixos-install is not affected.

Am I affected?

Run nix-shell -p binwalk --run "binwalk /boot/EFI/nixos/*.efi | grep -i cpio | grep -i crypto_keyfile.bin" on an EFI system, if you have a match, you are likely to be vulnerable.

Patches

The problem has been patched in this unreleased commit vlinkz@837ca4d.

We plan to release a new extension for 0.3.13 and backport it to NixOS 22.11, 23.05 and unstable channels.

Workarounds

This is reserved for expert users who have a copy of their data, we will provide a remediation tool shortly.

To remediate this vulnerability by yourself:

  1. Reboot with a NixOS live environment you trust.
  2. Mount your rootfs and all relevant LUKS devices using the crypto_keyfile.bin, you can achieve by doing binwalk $initrd -D cpio:.bin on an initrd containing this "secret", you will obtain a folder containing all the data of CPIO archives, otherwise, you can look for the append-initrd-secrets Bash script in your Nix store which shows how to copy this information
  3. Confirm you have a backup of your valuable data before moving on.
  4. Unmount everything and proceed to a re-encryption procedure:
  5. cryptsetup reencrypt $affected_partition
  6. Remount your partition and confirm that crypto_keyfile.bin is not able to unlock your LUKS partition anymore
  7. Remount your whole NixOS system
  8. Remove any mention of boot.initrd.secrets."crypto_keyfile.bin" in your NixOS configuration.
  9. Perform a nixos-rebuild boot while staying in that live environment via nixos-enter or anything you prefer
  10. Reboot, you should have a rotated key for all your affected LUKS partitions now

References

Initial report: linuxboot/heads#1348

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N

CVE ID

CVE-2023-36476

Weaknesses

Credits