Skip to content

fix(anssi/R3): unquote regex pattern in Secure Boot check#187

Merged
jdauphant-dinum merged 1 commit into
cloud-gouv:mainfrom
arcanesys:fix/anssi-r3-secure-boot-detection
Jun 16, 2026
Merged

fix(anssi/R3): unquote regex pattern in Secure Boot check#187
jdauphant-dinum merged 1 commit into
cloud-gouv:mainfrom
arcanesys:fix/anssi-r3-secure-boot-detection

Conversation

@abstracts33d

Copy link
Copy Markdown
Contributor

Comme demandé par @rlahfa-dinum dans #128.

[[ "$status" =~ ".*01.*" ]] testait une chaîne littérale (bash 3.2+ : motif entre guillemets = comparaison littérale, pas regex). Le retrait des guillemets autour de 01 corrige le faux négatif.

Closes #128.

Test plan

  • nix flake check
  • anssi-nixos-compliance-check sur un hôte avec Secure Boot activé : R3 retourne pass
  • Même check sur un hôte avec Secure Boot désactivé : R3 retourne fail

The R3 check tested the hex dump of the SecureBoot efivar with
`[[ "$secure_boot_status" =~ ".*01.*" ]]`. Since bash 3.2, any quoted
portion of the right-hand side of `[[ =~ ]]` is matched as a literal
string, not a regex. Bash therefore searched the hex dump for the
literal substring `.*01.*` (dots and stars taken literally), which is
never present. The test always failed, so R3 reported "Secure Boot is
not enabled" on every host - including hosts where `sbctl status` and
`bootctl status` confirm Secure Boot is on. R5 (`depends = [ "R3" ]`)
inherited the false negative.

Drop the quotes so the substring `01` is matched as a regex. The
`SecureBoot` efivar carries attribute byte `0x06` (BS|RT) per the UEFI
spec and a single value byte (`0x01` enabled / `0x00` disabled), so `01`
only appears on the value byte in practice.

Fixes cloud-gouv#128.
@jdauphant-dinum jdauphant-dinum merged commit 109bfec into cloud-gouv:main Jun 16, 2026
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.

Fail to detect Secure Boot in compliance check

3 participants