From 341c2353ab25aa14f0bca1487b447cfb46771f17 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 Jan 2026 00:52:01 +0800 Subject: [PATCH] add audit of boot mode to audit and security assessment Turns out we *can* check this at run-time. I thought originally once the chip was sealed these became hidden. I was wrong. So, this means we can actually test to confirm that production was done correctly and in fact the CM7 and debug ports are sealed off. this adds that test. --- bao1x-boot/boot1/src/repl.rs | 11 +++++++++++ bao1x-boot/boot1/src/secboot.rs | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/bao1x-boot/boot1/src/repl.rs b/bao1x-boot/boot1/src/repl.rs index 94f36d887..09f6e3080 100644 --- a/bao1x-boot/boot1/src/repl.rs +++ b/bao1x-boot/boot1/src/repl.rs @@ -438,6 +438,17 @@ impl Repl { } else { crate::println!("In-system keys have been generated"); } + let ifr = unsafe { core::slice::from_raw_parts(0x6040_0180 as *const u8, 0x10) }; + let ref_value = [ + 0x00u8, 0x00, 0x00, 0x00, 0x82, 0x8c, 0x42, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, + ]; + if ifr == &ref_value { + crate::println!("CM7 & debug confirmed fused off"); + } else { + crate::println!("Factory configuration error - CM7 or debug is enabled!"); + secure = false; + } if !secure { crate::println!("** System did not meet minimum requirements for security **"); } diff --git a/bao1x-boot/boot1/src/secboot.rs b/bao1x-boot/boot1/src/secboot.rs index 4927bfc16..4bcf6a976 100644 --- a/bao1x-boot/boot1/src/secboot.rs +++ b/bao1x-boot/boot1/src/secboot.rs @@ -36,6 +36,22 @@ pub fn try_boot(or_die: bool, csprng: &mut Csprng) { if dev2 != 0 { bao1x_hal::sigcheck::erase_secrets(&mut Some(csprng)).inspect_err(|e| crate::println!("{}", e)).ok(); // "ok" because the expected error is a check on logic/configuration bugs, not attacks } + bollard!(bao1x_hal::sigcheck::die_no_std, 4); + csprng.random_delay(); + { + // check IFR settings - this confirms that the Cortex M7 is disabled, and that hardware JTAG debug is + // disabled + let ifr = unsafe { core::slice::from_raw_parts(0x6040_0180 as *const u8, 0x10) }; + let ref_value = [ + 0x00u8, 0x00, 0x00, 0x00, 0x82, 0x8c, 0x42, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + if ifr != &ref_value { + bao1x_hal::sigcheck::erase_secrets(&mut Some(csprng)) + .inspect_err(|e| crate::println!("{}", e)) + .ok(); // "ok" because the expected error is a check on logic/configuration bugs, not attacks + crate::println!("Incorrect IFR: factory error, or under attack. Secrets erased."); + } + } csprng.random_delay(); let (paranoid1, paranoid2) = one_way.hardened_get2(PARANOID_MODE, PARANOID_MODE_DUPE).unwrap();