Skip to content

Trust Mozilla's current root list in u64ctrl's network recovery (fixes the emSign roots) - #1034

Merged
chrisgleissner merged 1 commit into
GideonZ:masterfrom
JC-000:u64ctrl-ca/r1
Oct 29, 2026
Merged

chrisgleissner merged 1 commit into
GideonZ:masterfrom
JC-000:u64ctrl-ca/r1

Conversation

@JC-000

@JC-000 JC-000 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 of DEFAULT_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 in run-tests as u64ctrl-ca (smoke profile, no device).
  • .github/workflows/build.yml: two steps that run the test on a stock python:3.12-slim image:
    • "Test u64ctrl Recovery CA List", before the firmware builds;
    • "Test u64ctrl Recovery CA List In The Build", right after the U64-II software build.
  • software/esp_depends.py: hashes u64ctrl/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 of
eight eMudhra intermediates under it were found to be trivially recoverable (Mozilla bugs 2083449 and 2084101). The list also holds
emSign Root CA - C1 and emSign ECC Root CA - C3. eMudhra asked for those two to be removed, in the same NSS release, as retired
dual-purpose roots under which no TLS certificates were issued (bug 2083709); dropping them is plain hygiene. emSign Root CA - G1
stays, 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.py

It 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:

  • Downloads cacert.pem and cacert.pem.sha256 from curl.se, over https only, redirects included, and into memory only. Nothing
    downloaded is executed.
  • Refuses the file, and changes nothing, unless:
    • the sha256 matches the one curl publishes;
    • the file is not older than the committed one, and not over the age limit;
    • it holds at least MIN_ROOTS roots, including ISRG Root X1 and X2, and none of the roots in REMOVED;
    • both built-in recovery servers verify against it with openssl s_client. That means exit code 0, the exact
      Verify return code: 0 (ok) line, and the top of the chain each server sends issued by a root in the new list. It finds the
      top 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.
  • Prints the roots added and removed, for review.
  • Then updates three things together: cacert.pem, the pinned CACERT_SHA256 in the test, and the date in the README. It writes all
    three 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:

  • [01] the sdkconfig selects the committed root list;
  • [02] the list holds ISRG Root X1 and X2 and none of the removed emSign roots, and its sha256 is the pinned CACERT_SHA256, so it is curl's file unmodified;
  • [03] the list is less than a year old (MAX_AGE_DAYS = 365, read offline from the file's "Mozilla as of" header), and a list that
    is older is caught. If Mozilla's data really has not changed for a year, refresh.py says "no change", and the README says to raise the limit;
  • [04] a list that lacks X2 or holds a removed root is caught;
  • [05] the embedded-bundle check accepts the list's bundle and refuses an extra or a missing root;
  • [06] refresh.py changes nothing unless every check passes, and then updates the three places. This runs against a fake curl.se on a
    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;
  • [07] the server check refuses a spoofed result, a failed exit code and a chain top the list does not issue, and ignores an
    unrelated certificate sent after the chain;
  • [08] check_server against a local openssl s_server: verified, unknown CA, spoofed name (skipped without OpenSSL 3);
  • [09] the ESP32 cache key hashes the list;
  • [10] the bundle the build embedded was made from the list (skipped when there is no build output; the second CI step runs it after the build).

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, or u64ctrl.bin on a cache hit. That means it relies on ESP-IDF's bundle layout again, which the first version
was criticised for. It does so in a way that degrades safely:

  • The main check is layout-free. Every root's subject and public key must appear in the output, and the removed roots' names must not.
    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.
  • The only layout-dependent part is the size check on a whole bundle. Its size must equal the roots' size plus ESP-IDF 5's count header
    or ESP-IDF 6's offset table, which proves no extra root of ESP-IDF's own list slipped in.
  • If a future ESP-IDF changes the layout, the size check fails loudly with the actual and expected sizes. It cannot pass wrongly,
    and fixing it means updating one formula in the test.

Results

  • On the C64U, Chris built this branch, flashed it and ran a recovery, and the recovery flash worked.
  • On an ESP32-S3 devkit with u64ctrl's mbedTLS settings and this list, both recovery URLs validate and answer, and both are refused
    when ISRG Root X1 and X2 are removed.
  • Both servers' real chains verify against this list with ESP-IDF 5.3.1's mbedTLS and with ESP-IDF 6.0.3's.
  • [10] fails on a real build with DEFAULT_FULL (missing roots, wrong size, the emSign roots present), also when only u64ctrl.bin is given.

Threat model.

  • It is a low-priority target, but the stale list, no revocation and no date check together lower the bar to intercept the recovery's TLS.
  • Concrete case: a unit in recovery joins the fallback hotspot, which has public credentials (recovery_trust.c:20-25). An impostor
    there 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.
  • The manifest is signed and every file is hash-checked, so for everything except the FPGA bitstream the worst outcome is a denial.
    Someone on the path can cause a denial anyway.
  • The bitstream is streamed into the FPGA before its hash is known (recovery.c:48-54), so tampering there can start a foreign design.
  • Realistic only for a targeted, nearby attacker during a rare event, but it is the case the HTTPS servers exist for.

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.

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

Alternatives considered

Option For Against
ESP-IDF "common" subset (DEFAULT_CMN) 2 lines; drops the three roots; keeps Let's Encrypt and some old cross-sign anchors A name filter over ESP-IDF's own aging copy (5.3.1: 2024-03-11; 6.0.3: 2025-12-02); keeps 31 of 118 current roots, so menu-set servers on less common CAs fail; saving space is not needed (the full bundle is 54,752 bytes, and the app partition has about 2.1 MB free)
ESP-IDF "deprecated list" option — Only adds old roots; cannot remove any
A newer ESP-IDF No project change Fixed on release/v6.0 and master in October 2026 but in no tag yet; no 5.x fix
The first version of this PR Same list, many guards About 650 lines of tooling in new places and patterns: a build hook, a checker of ESP-IDF's private bundle format, a pin file, mbedTLS compiled in CI
Pinning the Let's Encrypt roots Smallest Ties the servers to one CA; breaks menu-set servers
Mozilla's current list, one file, a refresh script and one test (this PR) Current and complete; one command to refresh; one store for every TLS user in the tree; checks follow the tests/ pattern About 3,000 lines of data, plus 264 lines of script and 569 of test (the review asked for the refresh script and the end-to-end check); drops old cross-sign anchors

Written with Claude Opus 5.5 (description) and Claude Sonnet 5.5 (code) in Claude Code.

@chrisgleissner chrisgleissner added enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. labels Oct 29, 2026
@chrisgleissner

chrisgleissner commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @JC-000 , great work.

Just some asks:

  • What is the actual user-facing, concrete problem that this PR fixes? Where do we use HTTPS other than for downloading the firmware for the new recovery feature? And if this is why you added this, what is the concrete threat scenario, and is this realistic?
  • Please check whether these changes are truly minimal. They strike me as quite extensive. I am not talking about reducing test coverage. And I do not mean strange hacks just to reduce lines of code. I mean - please check and thoroughly investigate whether this is the simplest, architecturally correct, maintainable solution to this problem. I do not doubt that it is, but I wonder whether you adversarially reviewed it from this angle.
  • Some of the tests are named check and are at locations which I am not sure are idiomatic for this project. We do not want to establish new patterns of where we place tests, or how we name them. I would generally favour the term test being mentioned somewhere in a test, unless the test is not mean to run automatically. I am fine if you have seen this pattern elsewhere, but please make sure that newly added tests reuse and if possible extend the e2e/soak/perf test infrastructure we built under tests.

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

@JC-000

JC-000 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, these were the right questions. I went back over it from the "is this minimal" angle, and the first version was not.
I have cut it to one commit. Short answers first.

1. The user-facing problem, and where HTTPS is used

On master, the only TLS client is the U64-II network recovery in u64ctrl (software/u64ctrl/main/recovery.c, http_open).
It fetches the manifest and the files from the two built-in servers, or from one set in the menu. Nothing else on master makes a
TLS connection. The Wi-Fi bridges enable the bundle but never open a TLS socket, and the application has no TLS library.

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
still holds emSign ECC Root CA - G3, which Mozilla removed after the keys of eight eMudhra intermediates under it were found to be
trivially recoverable. It also holds two other emSign roots that eMudhra itself asked to retire, under which no TLS certificates were
issued. Nothing visibly breaks for users.

A concrete scenario:

  • A unit is in recovery. When no stored access point is in reach, it joins a fallback hotspot with a public name and password
    (recovery_trust.c:20-25), and the comment there relies on HTTPS to stop an impostor on that hotspot.
  • The impostor presents a certificate for the recovery host, made with one of the eMudhra keys. Mozilla's bug notes that those keys
    "all used integers less than 256", so that takes no special access. The module still trusts G3.
  • The module checks no revocation. Mozilla removed G3 explicitly "to protect clients which do not use revocation information", and u64ctrl is such a client.
  • The impostor now sits in the middle of the recovery's TLS.

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
LAN can ARP-spoof the gateway and put themselves in the path of a unit that recovers there. Again, the stale store is what then lets
them present a certificate the module accepts.

What that gains them: the manifest is signed and every file is hash-checked. So for everything except the FPGA bitstream, the worst
outcome is a denial: a rejected package is just one more way to deny service, which someone on the path can always do anyway. The
bitstream is the exception. It is streamed into the FPGA before its hash is known (recovery.c:48-54, FPGA_HOLDBACK), so
tampering there can start a design of the attacker's choosing.

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
with no revocation and no certificate date checks, lowers the bar, and this is exactly the case the HTTPS servers exist for.
The stale store covers three kinds of certificate: one from a compromised CA, an old one for a recovery host whose key leaked, and a
revoked one. This PR fixes the stale list, which is the first. Date checks and revocation are not in it. Separately, I suggest in #1033
that the bitstream be verified before it starts, which removes the dependence on TLS altogether. That one is Gideon's call, and there is
no PR from me for it.

2. Is it minimal? What I considered

  • ESP-IDF's "common" subset (DEFAULT_CMN).
    • Pros: two sdkconfig lines and nothing to maintain. It leaves out the three roots and keeps the Let's Encrypt roots both servers
      use. It also keeps some older roots that matter for cross-signed chains.
    • Cons:
      • It is only a name filter over ESP-IDF's own Mozilla copy, so it ages with the IDF version: 5.3.1's data is 2024-03-11, and 6.0.3's is 2025-12-02.
      • It keeps 31 of the current 118 roots, so a menu-set recovery server on a less common CA would fail.
      • Saving space buys nothing: the full list's bundle is 54,752 bytes, and the app partition has about 2.1 MB free.
  • ESP-IDF's "deprecated list" option. It only adds old roots back and cannot remove any. Not usable.
  • A newer ESP-IDF. Espressif moved the three roots to its opt-in deprecated list on release/v6.0 (2026-10-22) and synced master
    to the 2026-10-20 Mozilla data. Neither is in a tag yet, and no 5.x branch has the change. It will reach u64ctrl only with an IDF 6
    release after 6.0.3. It does nothing for 5.3.1 today.
  • My first version of this PR. It had the same list, plus a build hook, a checker that parses ESP-IDF's private bundle format
    (already different between IDF 5 and 6), a pin file, a chain test that compiles mbedTLS in CI, sdkconfig.defaults and two CI
    steps. That was about 650 lines of tooling and several patterns this repository does not have. All of that is gone, and the two
    CI steps are replaced by one that runs the single test below.
  • Pinning the Let's Encrypt roots. Smallest, but it ties the servers to one CA and breaks menu-set servers. That is not acceptable
    for a recovery path.

What I settled on: curl's unmodified copy of Mozilla's current list (2026-10-20, 118 roots) as software/u64ctrl/ca/cacert.pem,
selected by three sdkconfig lines. The commit also has a 12-line README with the refresh steps, one test and its CI step, the ESP32
cache-key line so a refreshed list rebuilds the module, and the module version bump. The reasons:

  • the list is current, and it is the same list browsers use;
  • refreshing it means replacing one file at release time;
  • the same file can serve the other TLS users above.

The precise compatibility claim: a server works if the topmost certificate it sends is issued by a root in this list, because mbedTLS
does no path building. Both built-in servers meet that. The new list drops 45 entries compared with today, mostly long-retired roots.
A server that still sends a cross-certificate from one of them would now fail, where CMN would keep it working. That is the cost of
this option, together with about 3,000 lines of data.

3. The tests

One test, tests/lib/u64ctrl_ca_test.py, next to esp_depends_test.py and in the same style. It is registered in run-tests as
the suite u64ctrl-ca (smoke profile, no device needed). It also runs in build CI as the step "Test u64ctrl Recovery CA List" in
build.yml, on a stock python:3.12-slim image like the lint step, before the firmware builds. Its four checks:

  • [01] the sdkconfig selects the committed list;
  • [02] the list holds ISRG Root X1 and X2 and none of the three removed emSign roots;
  • [03] a self-test: a list that lacks X2, or holds a removed root, is caught;
  • [04] the ESP32 cache key hashes the list.

It fails on master (the sdkconfig selects ESP-IDF's list) and passes with this change. One regression it will catch is ours:
#1028 (u64ctrl on ESP-IDF 6) still has DEFAULT_FULL=y. It takes these lines when rebased onto this, and the CI step fails if it does not.

Other test approaches I weighed:

  • A configure-time FATAL_ERROR in u64ctrl/CMakeLists.txt: about 3 lines and fails the real build, but it is a pattern this tree does not use.
  • A host C test under target/pc/linux/: the wrong tool for checking a configuration.
  • A chain test that compiles mbedTLS in CI: it tests something this change does not touch.

Two results are one-off evidence in the PR description and are not kept in the tree:

  • the servers' real chains verify against this list, under ESP-IDF 5.3.1 and 6.0.3;
  • on an ESP32-S3 devkit, both servers validate, and both are refused once the Let's Encrypt roots are removed.

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.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

Review of the certificate list and the wiring around it.

Certificates: correct.

  • software/u64ctrl/ca/cacert.pem at 760ba38 is byte-identical (cmp) to https://curl.se/ca/cacert.pem fetched today. Its sha256 is 796f1389bfea13c0ed78f663b765baaff54a508e5483786bd6ece73c5e3e3cbe, the value curl publishes in cacert.pem.sha256. The header reads "Mozilla as of Tue Oct 20 13:32:40 2026".
  • The file holds 118 PEM blocks. All parse with openssl, all are CA:TRUE, and none has a notAfter before today.
  • None of emSign ECC Root CA - G3, emSign Root CA - C1, emSign ECC Root CA - C3 is present. The three REMOVED fingerprints in the test match those certificates' published sha256 values, and the REQUIRED fingerprints match ISRG Root X1 and X2.
  • emSign Root CA - G1 is still in the list because Mozilla still ships it. The PR text says "the three emSign roots", which is accurate, but the README could say that G1 remains.
  • Both built-in servers (recovery.ultimate64.com, ultimate64.ddns.net) currently send leaf, Let's Encrypt YE1/YE2, ISRG Root YE (cross-signed by X2) and ISRG Root X2 (cross-signed by X1). openssl s_client -CAfile cacert.pem verifies both chains (return code 0).

Remaining concerns

  1. The test does not enforce "unmodified". Check [02] only looks for specific fingerprints and a minimum count of 100. A hand-edited or partly refreshed file passes. Pinning the sha256 of the whole file in the test, next to the date in the README, would make the "curl's copy, unmodified" claim checkable. It would cost one line per refresh, and a refresh already edits the test.
  2. The CI step reads the inputs only, as the test docstring says. Nothing checks that the bundle the u64ii build embeds contains the roots. The sdkconfig path is relative (ca/cacert.pem). It was checked on a devkit, per the description, but the kept test cannot catch a later IDF change in how that path is resolved.
  3. The list does not contain ISRG Root YE or YR. Verification works today only because the servers send the cross-signed X2 and X1 certificates. mbedTLS does no path building, as the description says. If the servers drop the extra cross-certificates, which a certbot or nginx chain change can do, the topmost certificate is issued by YE and the module refuses the connection. That would be a recovery failure with no on-device indication. A one-line README note on this, and a recovery-server check on each refresh, would help.
  4. Not tested on a C64U in this review. The unit at 192.168.1.148 did not answer ping or REST when I tried, and a recovery run reflashes the unit, so I only checked the chains against the file on the host. A recovery attempt on a C64U with this module is still worth doing before merge.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

The PR has no refresh mechanism. software/u64ctrl/ca/README.md lists four manual steps: download curl's file, replace cacert.pem, add removed roots to REMOVED in the test, and bump IDENT_MINOR. No script performs them, and nothing detects that the list has aged. The failure this PR fixes (a root list that goes stale until someone notices) therefore recurs, with a longer interval.

Suggested additions:

  • A script, for example software/u64ctrl/ca/refresh.py, that downloads cacert.pem and cacert.pem.sha256 from curl.se, refuses the file if the hash does not match, and prints the roots dropped and added compared with the committed file. It would also check that both built-in recovery servers verify against the new file with openssl s_client -CAfile, which catches the missing cross-certificate case before a release.
  • A check in u64ctrl_ca_test.py that reads the "Mozilla as of" date from the file header and fails when it is older than a set limit. That limit is a policy choice, for example 12 months, and it must stay offline so CI does not depend on curl.se. Alternatively, a scheduled workflow could compare the file with curl's current copy and open an issue when they differ.
  • Pin the sha256 of the whole file in the test, so the "unmodified" claim is enforced.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

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:

  • One command, no arguments, runnable from a clean checkout, for example python3 software/u64ctrl/ca/refresh.py.
  • It must not change the tree unless every check passes. It downloads to a temporary file, verifies the sha256 published at https://curl.se/ca/cacert.pem.sha256, checks that the file parses as PEM and holds at least MIN_ROOTS certificates, and only then replaces cacert.pem. A failed download or hash mismatch leaves the committed file untouched.
  • It reads the file over HTTPS only and does not execute anything it downloads.
  • It prints the roots added and removed compared with the committed file, so the person refreshing can review the change and add removed roots to REMOVED in the test.
  • It checks that both built-in recovery servers verify against the new list, so a refresh that would break recovery is caught before commit.

Verification I did on the PR head (760ba38), built with build-tool -s u64ii: software/u64ctrl/build/esp-idf/mbedtls/x509_crt_bundle is 54,752 bytes, as stated in the description. The built u64ctrl.bin contains ISRG Root X1, ISRG Root X2 and emSign Root CA - G1, and contains none of emSign ECC Root CA - G3, emSign Root CA - C1 or emSign ECC Root CA - C3. The custom bundle path therefore resolves and is used in the build.

@chrisgleissner

chrisgleissner commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

@JC-000 I successfully verified your change on my C64U:

I built the PR head (760ba38) with build-tool -s u64ii.

  • The embedded bundle is 54,752 bytes, as the description says.
  • u64ctrl.bin has ISRG Root X1, ISRG Root X2 and emSign Root CA - G1.
  • It has none of the three removed emSign roots (G3, C1, C3).

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>
@JC-000

JC-000 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

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
myself without reflashing a unit. I have updated the description to match. Here is what changed for each point.

Review of the list and wiring

  1. "Unmodified" is not enforced. The test now pins the sha256 of the whole file (CACERT_SHA256, curl's published value), so any
    hand edit or partial refresh fails [02].
  2. Nothing checks what the build embeds. Check [10] reads the generated x509_crt_bundle, or u64ctrl.bin on a cache hit. Every root of the
    list must be in it, and none of the removed ones. It runs in a second CI step, right after the U64-II software build. On a build with
    ESP-IDF's own list it fails. It relies on ESP-IDF's bundle layout only for a size check. If that layout changes, the check fails loudly;
    it cannot pass wrongly. The description says how.
  3. No ISRG Root YE or YR. Right, and it matters because mbedTLS builds no path. The README now has a "Chains" section that says
    the servers verify only because they send the cross-signed X2 and X1. The refresh script checks both servers against the new list on
    every refresh. That includes walking the chain each server sends the way mbedTLS does, and requiring its top to be issued by a root in
    the list. So a server-side chain change is caught at refresh time.
  4. The README could say G1 remains. It does now.

Refresh mechanism

  • python3 software/u64ctrl/ca/refresh.py: one command, no arguments. It meets each requirement you listed:
    • It downloads over https only, redirects included, into memory, and executes nothing downloaded.
    • It changes nothing unless every check passes: the published sha256, the file parses and holds at least MIN_ROOTS, the
      file is not older than the committed one, ISRG X1/X2 are present and no REMOVED root is, and both recovery servers verify.
    • It prints the roots added and removed.
    • It then updates the file, the pinned sha256 and the README date together, and puts the old files back if a write fails.
  • Hardening from our own review:
    • The server check requires openssl's exit code 0 and the exact verify line, so a certificate named "Verify return code: 0 (ok)" cannot fake it.
    • It refuses LibreSSL, which also trusts the system store.
  • Age check. The test fails when the list's "Mozilla as of" date is more than 365 days old, offline ([03]). If Mozilla's data really
    has not changed for that long, refresh.py says so, and the README says to raise the limit.
  • The refresh script is tested too, against a fake curl.se on a copy of the tree. Every failure case leaves the tree byte-identical
    ([06]), and so does a redirect to http. The server-check judgement is tested offline ([07]), including an unrelated certificate appended
    after the chain, and against a local openssl s_server ([08]).

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.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

Reviewed at dc3a31f.

  • software/u64ctrl/ca/cacert.pem is byte-identical to the current file from https://curl.se/ca/cacert.pem (118 roots, Mozilla data of 2026-10-20). Its sha256 796f1389bfea13c0ed78f663b765baaff54a508e5483786bd6ece73c5e3e3cbe matches both curl's published cacert.pem.sha256 and the CACERT_SHA256 pin in the test.
  • refresh.py was run against the network. Both recovery servers verified against the list, and it reported no change. A second run against a copy of the tree with an older list updated cacert.pem, the test pin and the README together, and left no stray files.
  • tests/lib/u64ctrl_ca_test.py passes all 9 checks that apply without build output (check 10 is skipped without one). registry_test.py and esp_depends_test.py pass, and u64ctrl-ca is listed by ./run-tests --list.
  • The CI build check is green.

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.

@chrisgleissner
chrisgleissner merged commit 03c70e6 into GideonZ:master Oct 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wi-Fi recovery trusts an ESP-IDF CA bundle that still holds the root Mozilla removed after the eMudhra key compromise

2 participants