Repository navigation
Trust Mozilla's current root list in u64ctrl's network recovery (fixes the emSign roots) - #1034
Conversation
|
Hi @JC-000 , great work. Just some asks:
Again, I do not mean that this needs changing. I just mean - probe into it and then either change it, or write why the current structure is the best possible one, with exactly what else you considered, what its pros and cons where, and why you settled for what you did. Also, in general, whilst I do appreciate highly detailed and precise PR descriptions, it would be hugely helpful if the PR descriptions could provide simple summaries, and if the write-up could be checked for being readable. All the precise details can then go into a technical details or similar chapter. It may also help to line by line read the PR description after you raise the PR and then assess yourself whether as a human, they are easy to read, and have the right level of detail. Thanks |
|
Thanks, these were the right questions. I went back over it from the "is this minimal" angle, and the first version was not. 1. The user-facing problem, and where HTTPS is used On master, the only TLS client is the U64-II network recovery in u64ctrl ( Two open PRs add TLS users:
The problem: the recovery trusts ESP-IDF 5.3.1's copy of Mozilla's root list, which is Mozilla data of 2024-03-11. That copy A concrete scenario:
The hotspot isn't the only way in. On any shared network, such as a show floor at a vintage computer festival, someone on the same What that gains them: the manifest is signed and every file is hash-checked. So for everything except the FPGA bitstream, the worst Is it realistic? Only for a targeted attacker on the same network during a rare event, though a busy show with many units in one place makes "nearby" easier. It is a low-priority target. But the stale store, together 2. Is it minimal? What I considered
What I settled on: curl's unmodified copy of Mozilla's current list (2026-10-20, 118 roots) as
The precise compatibility claim: a server works if the topmost certificate it sends is issued by a root in this list, because mbedTLS 3. The tests One test,
It fails on master (the sdkconfig selects ESP-IDF's list) and passes with this change. One regression it will catch is ours: Other test approaches I weighed:
Two results are one-off evidence in the PR description and are not kept in the tree:
Also, my description was too dense. The new one starts with a plain summary, and the details are below it. Written with Claude Opus 5.5 in Claude Code. |
|
Review of the certificate list and the wiring around it. Certificates: correct.
Remaining concerns
|
|
The PR has no refresh mechanism. Suggested additions:
|
|
Following up on the refresh mechanism: it would be best if the author adds it in this PR, since the list is expected to change in future and the refresh will be repeated by whoever does the next release. Requirements for the refresh script:
Verification I did on the PR head (760ba38), built with |
|
Thanks a lot for your earlier rework @JC-000 . I have now reviewed your latest changes and left a few comments. Thanks for having a look. Given this is security sensitive, it's important we get it right and easy to maintain, but I think we are very close. Also, your earlier write-up of why you did this change, and which options you considered, was truly great. That is exactly what I was looking for, and it would also be very helpful to amend already existing PRs and consider it for future PRs you may raise, once we will have merged this one. |
|
@JC-000 I successfully verified your change on my C64U: I built the PR head (760ba38) with build-tool -s u64ii.
I then flashed it, turned the device off, then entered recovery, and the subsequent recovery flash worked. Nice one! Now if you could address my final review findings, I think this is good to merge. |
ESP-IDF 5.3.1's bundle (Mozilla data of 2024-03-11) still holds emSign ECC Root CA - G3, which Mozilla removed after the eMudhra intermediate key compromise (bug 2084101), and emSign Root CA - C1 and emSign ECC Root CA - C3, removed in the same NSS release (bug 2083709). Build the bundle from curl's cacert.pem of 2026-10-20 instead, unmodified and complete. tests/lib/u64ctrl_ca_test.py checks that the sdkconfig selects the file, that it holds ISRG Root X1/X2 and none of the three roots, and that the ESP32 cache key hashes it, so a refreshed list rebuilds u64ctrl in CI. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thank you for the careful review, and especially for running a real recovery on your C64U. That was the one test I could not do Review of the list and wiring
Refresh mechanism
On the write-up: thank you. I'll write future PRs this way, and bring my open ones up to it once this is merged. Written with Claude Opus 5.5 in Claude Code. |
|
Reviewed at dc3a31f.
Not verified by me: a local ESP32 firmware build. I relied on the CI build and the flash test described in the PR. No changes needed from my side. |
The U64-II network recovery trusted ESP-IDF 5.3.1's copy of Mozilla's root list, from March 2024. That copy still contains a root
Mozilla removed this month after a CA's keys were compromised. This PR makes the recovery trust Mozilla's current list instead,
committed as one file, and adds a one-command script that refreshes it. Users notice nothing: both recovery servers work as before.
One device-free test guards the configuration, the list, the refresh script and what the build embeds. It runs in CI.
Fixes #1033.
Technical details
Change
software/u64ctrl/ca/cacert.pem: curl's unmodified copy of Mozilla's root list of 2026-10-20 (118 roots).software/u64ctrl/sdkconfig:CERTIFICATE_BUNDLE_DEFAULT_NONE=y,CUSTOM_CERTIFICATE_BUNDLE=y,CUSTOM_CERTIFICATE_BUNDLE_PATH="ca/cacert.pem", in place ofDEFAULT_FULL.software/u64ctrl/ca/refresh.py: the refresh script (below).software/u64ctrl/ca/README.md: what the file is, why the servers' chains verify, how to refresh it, and what the module does not check.tests/lib/u64ctrl_ca_test.py: the test, registered inrun-testsasu64ctrl-ca(smoke profile, no device)..github/workflows/build.yml: two steps that run the test on a stockpython:3.12-slimimage:software/esp_depends.py: hashesu64ctrl/ca/*.pem, so a refreshed list rebuilds the module in CI instead of reusing a cached binary.software/u64ctrl/main/rpc_dispatch.h: module version bump (a placeholder; assign as you see fit).What it fixes. ESP-IDF 5.3.1's list still holds
emSign ECC Root CA - G3. Mozilla removed it on 2026-10-20 after the keys ofeight eMudhra intermediates under it were found to be trivially recoverable (Mozilla bugs 2083449 and 2084101). The list also holds
emSign Root CA - C1andemSign ECC Root CA - C3. eMudhra asked for those two to be removed, in the same NSS release, as retireddual-purpose roots under which no TLS certificates were issued (bug 2083709); dropping them is plain hygiene.
emSign Root CA - G1stays, because Mozilla still ships it. The module checks neither revocation nor certificate dates, so the root list is its only control.
Chains. mbedTLS does no path building, so a server works only if the top of the chain it sends is issued by a root in the list.
The list has no ISRG Root YE or YR. Both built-in servers verify today only because they send the cross-signed ISRG Root X2 and X1.
A server that stops sending those cross-certificates would be refused. That is why the refresh script checks both servers. Relative
to today's ESP-IDF list, the new one drops 45 entries, mostly long-retired roots. A server that still sends a cross-certificate from
one of them would also fail.
Refresh script:
python3 software/u64ctrl/ca/refresh.pyIt takes no arguments and needs only the standard library and OpenSSL 3 or later. It refuses LibreSSL, macOS's
/usr/bin/openssl,with a clear message, because that build also loads the system trust store.
What it does:
cacert.pemandcacert.pem.sha256from curl.se, over https only, redirects included, and into memory only. Nothingdownloaded is executed.
MIN_ROOTSroots, including ISRG Root X1 and X2, and none of the roots inREMOVED;openssl s_client. That means exit code 0, the exactVerify return code: 0 (ok)line, and the top of the chain each server sends issued by a root in the new list. It finds thetop the way mbedTLS does: from the leaf, a certificate's parent is the first later certificate whose subject is its issuer.
A certificate the server appends after the chain does not count.
cacert.pem, the pinnedCACERT_SHA256in the test, and the date in the README. It writes allthree to temporary files first and replaces them together. If a replace fails, it puts the old files back.
The sha256 comes from the same server, so it proves the download is intact, not that curl.se is honest. That is why the printed
changes are meant to be reviewed. After refreshing: add any removed roots to
REMOVED, run the test (again after a firmware build),and bump the module version.
Tests:
tests/lib/u64ctrl_ca_test.py. It fails on master (check [01]) and passes here. Its checks:CACERT_SHA256, so it is curl's file unmodified;MAX_AGE_DAYS = 365, read offline from the file's "Mozilla as of" header), and a list thatis older is caught. If Mozilla's data really has not changed for a year,
refresh.pysays "no change", and the README says to raise the limit;copy of the tree. A hash mismatch, a truncated list, a list without X2, an older or over-age list, a redirect to http and a failing
server check all leave the tree byte-identical;
unrelated certificate sent after the chain;
openssl s_server: verified, unknown CA, spoofed name (skipped without OpenSSL 3);How [10] reads the build output. You asked for an end-to-end check of what the build embeds, so [10] reads the generated
x509_crt_bundle, oru64ctrl.binon a cache hit. That means it relies on ESP-IDF's bundle layout again, which the first versionwas criticised for. It does so in a way that degrades safely:
Any format that stores the DER subject and key, as both IDF 5 and IDF 6 do, keeps this working. It also works on
u64ctrl.bin.or ESP-IDF 6's offset table, which proves no extra root of ESP-IDF's own list slipped in.
and fixing it means updating one formula in the test.
Results
when ISRG Root X1 and X2 are removed.
DEFAULT_FULL(missing roots, wrong size, the emSign roots present), also when onlyu64ctrl.binis given.Threat model.
recovery_trust.c:20-25). An impostorthere presents a certificate for the recovery host made with one of the eMudhra keys, which are trivially recoverable. Mozilla removed
the root "to protect clients which do not use revocation information", and this module is such a client.
Someone on the path can cause a denial anyway.
recovery.c:48-54), so tampering there can start a foreign design.This PR closes the stale-list part. Verifying the bitstream before starting it is suggested in #1033 and is not part of this PR.
Other TLS users.
script, so the tree keeps one store.
IDF 6. ESP-IDF 6.0.3 has the same three Kconfig options with the same meaning. #1028 (u64ctrl on ESP-IDF 6) still has
DEFAULT_FULL=y. It takes these lines when rebased onto this PR, and the CI steps fail if it does not.Not in this PR
CONFIG_MBEDTLS_HAVE_TIME_DATEis unset);Alternatives considered
DEFAULT_CMN)Written with Claude Opus 5.5 (description) and Claude Sonnet 5.5 (code) in Claude Code.