Commit graph

10340 commits

Author SHA1 Message Date
bunnie
8b06b212bb add oem-baosec-lite support to usb driver
there is currently no method to detect USB power connect
in this board. Considering adding a simple circuit to enable
this. This design is not meant to be battery powered but
it is possible that an aftermarket modification would introduce
a battery, in which case, vbus detection does become A Thing.
2026-01-24 23:54:21 +08:00
bunnie
bcf73733c3 oem-baosec-lite support in hal-service
this one is a little bit tricky. The lite version of baosec
forgoes the off-chip TRNG to save cost. Thus, there is an
"anti-feature" in the configuration, and so in this case
the dabao version of the server has to be selected despite
the baosec flag.
2026-01-24 23:52:37 +08:00
bunnie
e329ebeb1d oem-baosec-lite support to bao-video
remap pwm lock output. This reduces power consumption in
camera mode by removing an I/O conflict with the keyboard
scanner.
2026-01-24 23:51:22 +08:00
bunnie
00e70d8c1d add oem-baosec-lite support to loader 2026-01-24 23:51:02 +08:00
bunnie
4523fea62c add support for more board options
- oem-baosec-lite board support
- more flash memory types
- transparent polarity switching on reset line

The reset line in particular is having its polarity switched
because the I/Os pull-up by default, and we'd like the reset
line for peripherals to be asserted on reset (this prevents
glitching on e.g. displays while the CPU boots).
2026-01-24 23:49:19 +08:00
bunnie
42a55cc238 add support for more flash memory types 2026-01-24 23:48:57 +08:00
bunnie
b6e85f551d add oem-baosec-lite to boot1 2026-01-24 23:48:35 +08:00
bunnie
b37d58fd59 add baosec-lite targets
baosec-lite strategy is to use the OEM board type, and then diff
off of the baosec target.

The assumption is that if you're building for a baosec-lite target,
you're committing to re-doing the bootloader from the stock bootloader
and pivoting into a full-custom baosec-lite build.

This assumption allows us to "hard code" more of the baosec-lite
differences, instead of having to leave other board options available
for a more portable firmware.
2026-01-24 23:06:14 +08:00
bunnie
b678d53165
Merge pull request #788 from betrusted-io/antirollback
Antirollback
2026-01-23 13:01:43 +08:00
bunnie
d96f0ad654 update dependencies 2026-01-22 23:18:18 +08:00
bunnie
013a4e8771 add anti-rollback and receipt processing to security audit command 2026-01-22 23:17:50 +08:00
bunnie
dce0bac16e add receipt processing to boot0 2026-01-22 23:17:26 +08:00
bunnie
27250c65dc move anti-rollback check to after the signature has been validated
I decided i feel too uncomfortable doing any state changes based
on unvalidated data. I can't see a downside to moving the check
to only after the signature has been verified.
2026-01-22 23:15:53 +08:00
bunnie
04dd447745 add anti-rollback checking to the signature check routine
one minor issue with this implemnetation is it requires dev
images to have an anti-rollback counter that matches or exceed
the last signed image seen.

This is more of a developr ergonomics issue - this will certainly
lead to some surprise by developers who are trying to take
production devices and "downgrade" them to an old dev tree
that has an old anti-rollback firmware number in it.

However, I think this is navigable and probably the simplicity
of not having an "escape" path for dev-signed imgaes is worth it.
All a developer has to do is to set the anti-rollback version
number to be equal to or greater than what was reported in
the device.
2026-01-22 19:48:37 +08:00
bunnie
23b7bc0142 add an upper limit for counter increments
this is a sanity check number that can be used by firmware
to vet a counter value before incrementing to it. it's particularly
useful to thwart wear-out attacks agaisnt anti-rollback firmware
versions, i.e. by specifying an extremely high anti-rollback number
one might be able to cause a reset-to-0 failure and this prevents
that from happening by limiting the maximum value of the the
counter that can be requested.
2026-01-22 19:46:07 +08:00
bunnie
9d972f59d5 add specifications for anti-rollback and receipt tracking
anti-rollback is a number that is stored in a monatomic counter
inside the device that is compared against the firmware images
presented to the device. If the image version is lower than the
anti-rollback counter, the image is rejected. If the image is
higher, the anti-rollback counter is incremented until it equals
the vesrion in the image.

the receipt mechanism is a method for ensuring that cross-third
party signed images can't be used to dump keys on other third party
images. Every time a boot1 is accepted, a copy of the key block
that was used to accept the third party image is stored in the
receipt block.

If those keys rotate, then the collateral keys are rotated. this
prevents a rotation of third-party images from being used to
dump other third party images.

it does mean that third party signers have to be careful to not
rotate any of their signing keys uninitentially.
2026-01-22 19:42:51 +08:00
bunnie
672f04bcff add anti-rollback specification file
this contains the anti-rollback codes for images signable
by the signing tool.
2026-01-22 19:40:52 +08:00
bunnie
3050fead41 add anti-rollback to image creation tool 2026-01-22 19:40:38 +08:00
bunnie
5eec0702f9
Merge pull request #786 from betrusted-io/release-ci
Release CI testing
2026-01-19 03:59:09 +08:00
bunnie
97df81de44 fix permissible function code on altboot
this allows recovery from revoked keys and trying to load
a dev-boot signed image from alt-boot loader
2026-01-19 03:34:55 +08:00
bunnie
6bb94a148e when usb is disconnected, toggle the correct flag
was turning off console altogether
we actually just want to turn off printing to USB.
2026-01-19 02:41:47 +08:00
bunnie
18a58c7d18 add more graceful handling of erase inconsistencies 2026-01-19 00:18:13 +08:00
bunnie
763a2c290d make boot more forgiving of inconsistent initial values 2026-01-18 22:37:08 +08:00
bunnie
32397a8d9f upgrade tag message to beta-0 2026-01-18 21:41:40 +08:00
bunnie
10ef6bda02
add information about root key seed to regular sign_image
Three pieces of inforation are leaked about the root seed:

- whether or not the first 64 bits are all 0
- whether or not the first 64 bits are all 3's
- whether if none of the above are true

It's fairly indirect leakage, and I think it is a relatively
minor price to pay for the confidence it gives that some underlying
library behavior didn't accidentally lead to faulty keygen.

Note that these 64 bits are 64 bits out of tens of thousands
of bits that go into the keygen, because the nuisance keys
and the chaff key are all blended together to create the final
derived root key. Thus the security margin on the key is quite
large and even a full disclosure of these 64-bits is a minor
impact on overall security.
2026-01-18 20:52:51 +08:00
bunnie
ce260d2f42
Merge pull request #785 from betrusted-io/collateral
Collateral & mutual distrust for third party firmwares
2026-01-18 03:16:44 +08:00
bunnie
cc00201774 add collateral erasure check to keystore
in no case should any baochip firmware be holding secret
collateral used by third party firmwares, thus a non-erased
state is a panic
2026-01-18 02:58:32 +08:00
bunnie
6b7ff11b4e
add collateral erasure and checking of IFR copy of pubkeys
The IFR copy of pubkeys is truly actually indelible because
of the no-exceptions write inhibit byte. Add code to check
against that copy.

Note that the IFR region's downside is the presence of
the write-inhibit byte means the check is complicated
as the full key is striped across two locations, but
this code handles that.
2026-01-18 02:56:14 +08:00
bunnie
24c76b077e
update boot0 to implement collateral protocol
this also makes boot0 erase secret keys in the case that the
signing public keys on boot0 or boot1 don't match the indelible
values expected in IFR.
2026-01-18 02:54:08 +08:00
bunnie
26636561f5 add collateral check to audit 2026-01-18 02:52:42 +08:00
bunnie
491a1c14dc add key range for collateral 2026-01-18 02:17:25 +08:00
bunnie
620f6fa22d add explanation of how collateral keys & mutual distrust work 2026-01-18 02:16:30 +08:00
bunnie
8993f43712
Merge pull request #784 from betrusted-io/fix-console
enable USB console by default
2026-01-17 17:45:25 +08:00
bunnie
f6c7d9c89e enable USB console by default
this helps with production & ci
2026-01-17 16:23:53 +08:00
bunnie
c36e937250
Merge pull request #783 from betrusted-io/locales-cleanup
Fix for #779
2026-01-17 01:43:29 +08:00
bunnie
a8d9b53c26 Fix for #779
This patch removes the option to scan out-of-tree json files
for locales resolution.

When the time comes to have to incorporate out-of-tree apps
with locales, a method should be devised that doesn't expand
the dependency surface of the project beyond the immediate
repository.
2026-01-17 01:33:16 +08:00
bunnie
d26ce7fbf1
Merge pull request #780 from sbellem/docker-sec
Improve security of dockerfiles
2026-01-16 17:59:53 +08:00
bunnie
af5a28ebc0
Merge pull request #782 from betrusted-io/bootwait
Add bootwait to test console
2026-01-16 17:59:17 +08:00
bunnie
4c3d2f677c fix hosted mode 2026-01-16 17:52:00 +08:00
bunnie
5a73d17a0a handle the no-arg case correctly 2026-01-16 17:40:17 +08:00
bunnie
b2c464be0f add keystore as dependency to console 2026-01-16 17:36:15 +08:00
bunnie
2a7cffb86e add bootwait command line API to test
also refactor the test argument parsing so that i can use the
more modern version of the api
2026-01-16 17:35:41 +08:00
bunnie
2b19c4bd21 add a command for setting the bootwait flag
The keystore is a sensitive server, and the one-way counters
have security-critical propoerties. So instead of revealing a
generic one-way counter API to the world, specific, limited
requests to do things are going to be created for the keystore.

In this case, the bootwait flag would be convenient to be able
to set from userspace. The motivation for this requirement is
actually continuous integration - a normal human could just
hold down a button while turning on power, but in CI, I don't
have a robotic thumb (or an alternative electrical signal) to
simulate the nerve-pinch on boot.

Previously I was "cheating" and simulating this by nuking the
loader, which effectively forces a bootwait.

However, in production, this is *not possible* because the JTAG
port is sealed off. Thus, this may be the first of a series
of small PRs to incorporate CI tooling that clears up tech
debt like nuking the loader to get into boot wait.
2026-01-16 17:32:12 +08:00
bunnie
81f35b17be add the missing 4 bytes from the public key block
after some discussion with a cryptographer it's just safer to do
this even if it might mean some compatibility issues in the future
2026-01-16 17:25:47 +08:00
Sylvain Bellemare
0959ea80db
Improve security of dockerfiles
* Verify checksum of downloaded rust target riscv32imac-unknown-xous_*.zip
* Pin base image to a sha256 digest
* Quote build arg to prevent shell injection attacks
* Run cargo --locked to make sure builds follow Cargo.lock
* Use --proto '=https' for curl to only allow HTTPS protocol to prevent downgrade attacks
* Create non-root user to run cargo commands and build artifacts
2026-01-16 16:41:43 +09:00
bunnie
a16c176bab
Merge pull request #781 from betrusted-io/production-keys
Transition to production settings
2026-01-16 03:59:08 +08:00
bunnie
341c2353ab 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.
2026-01-16 00:52:01 +08:00
bunnie
6eda3925ae update fuse blocks 2026-01-16 00:51:18 +08:00
bunnie
b06c124b3e
add a routine to print the info region
The info region is a region of RRAM that is used to configure
the chip - boot security, what CPUs can run, access control
lists, etc. There's no secrets in here, but it's very helpful
to inspect for audits and correctness of configuration, so
a routine is added to print it in boot1.
2026-01-15 17:04:11 +08:00
bunnie
86f0b18fdc
add the actual raw signing key handles to the repo
note that the "sk" is just a handle that points to the residential
key on an HSM, so the "private key" contains nothing of
cryptographic interest.
2026-01-15 17:03:06 +08:00