Security review: the Turing Pi BMC firmware fork
Verdict
Section titled “Verdict”Use with mitigations.
The review covers the fork excavador-turing/BMC-Firmware and its installer
excavador-turing/BMC-Installer. The use is one: the BMC firmware of the two Turing Pi 2 boards
that hold the k3s nodes. A read-only agent cloned the repositories and read the code. It ran
nothing from them. Gate 2 of design D3 of the OpenSpec change main-off-the-tailnet asked for
this review.
What was reviewed
Section titled “What was reviewed”| Repository | Revision | Note |
|---|---|---|
excavador-turing/BMC-Firmware, branch hive |
858e64cb439f2077455aa1c58332e14c5c27de37 |
The commit message names it the v2.44.0 release. 147 commits on top of upstream turing-machines/BMC-Firmware at d9c55b7a, all by one author |
excavador-turing/BMC-Installer, branch master |
cd86ef888e1262e48dc9050f30425d14a4552b2b |
The revision that tp2bmc/package/bmc_installer/bmc_installer.mk line 8 pins. 5 commits on top of upstream |
excavador-turing/bmcd |
2027ba5e (v2.40.0) |
The daemon. 116 commits on top of upstream |
excavador-turing/tpi |
90c22266 |
The command line client |
| BMC-UI v4.1.0 tarball | sha256 5c796b65 |
Matches tp2bmc/package/bmc-ui/bmc-ui.hash and the SHA256SUMS of the release |
The firmware is a Buildroot image for the BMC. Its daemon bmcd runs as root on ports 80, 443
and 9110. It can power, reset and flash the four nodes and open their serial consoles. SSH
listens on port 22. The image installs from an SD card or from a .tpu package that
/sbin/osupdate writes.
The image contacts four endpoints. It reaches api.github.com and github.com for the update
check and the install, only when the UI or the API asks (update_check.rs line 94,
firmware_catalog.rs line 166). It reaches pool.ntp.org from overlay/etc/chrony.conf line
5. It reaches firmware.turingpi.com only when the operator enables that source. It speaks
mDNS on br0. No cron job or timer installs anything. The root crontab holds only
mdnsd-guard.
Two attackers are in scope. The first is the fork’s single maintainer, with his GitHub account
and CI. The second is anyone on the management network. By default that network includes the
four nodes, because the BMC bridge br0 is flat.
Findings
Section titled “Findings”1. High, confirmed: one GitHub account is the root of trust of the firmware
Section titled “1. High, confirmed: one GitHub account is the root of trust of the firmware”tpi-selfupdate (lines 16, 145 to 174 and 504 to 513) resolves the release tag through the
GitHub API. It then checks the image against the SHA256SUMS file of the same release. Nobody
signs anything. The one-click install of the web UI (bmcd/src/api/legacy.rs lines 535 to 562)
runs that script. CI cuts a release on each tag push (.github/workflows/build.yml lines 575
to 592). The organisation lists no public member, and every fork commit has one author. If an
attacker takes over that account or its workflow, both BMCs install attacker firmware at the
next click. This is not a bug. It is the trust decision that adopting the fork makes.
2. Medium, confirmed: an authenticated caller gets a root shell through the file parameter
Section titled “2. Medium, confirmed: an authenticated caller gets a root shell through the file parameter”legacy.rs line 1327 builds a path from the file query parameter.
streaming_data_service/data_transfer.rs lines 101 to 107 return that whole path as the file
name. app/upgrade_worker.rs lines 285 to 310 push that name onto the staging directory. An
absolute name replaces the directory. The code opens the result for writing as root and then
runs sh -c "osupdate <name>". The type=firmware request goes straight there (legacy.rs
lines 1117 to 1150). Nothing checks the characters or the .tpu suffix. A caller with a
password, a token or a proxy identity gets a root shell at once, or overwrites /etc/shadow.
The caller needs no image and never meets the boot gate. osupdate also deletes the rollback
volume on the way. Upstream has the same code (legacy.rs line 626, upgrade_worker.rs lines
180 to 183), so the boards run it today.
3. Medium, confirmed: the factory password works for SSH as root
Section titled “3. Medium, confirmed: the factory password works for SSH as root”tp2bmc/configs/tp2bmc_defconfig line 9 sets the root password to turing.
overlay/etc/ssh/sshd_config sets PermitRootLogin yes and PasswordAuthentication yes. The
factory-password gate of bmcd (authentication/factory_password.rs lines 88 to 96) covers
/api/bmc only, not SSH. A file factory-reset.txt on an SD card (board/tp2bmc/install.scr)
restores the factory password.
4. Low: the metrics endpoint is open
Section titled “4. Low: the metrics endpoint is open”/metrics listens on plain HTTP on every address (default_config.yaml lines 3 and 18,
main.rs lines 313 to 319) with no authentication. Every host on br0 can read it. It reports
the firmware and daemon versions, the node power states, the staged image, the TLS certificate
details and the switch counters.
5. Low: a proxy identity can replace the client CA
Section titled “5. Low: a proxy identity can replace the client CA”api/access.rs lines 345 to 418 let a caller replace the client CA, and nothing refuses a
caller whose scheme is mtls. The delete path at lines 425 to 440 has that refusal. A
compromised fleet gateway can install its own CA and survive a rotation of the real one.
6. Low: the --tag argument of tpi-selfupdate is not validated
Section titled “6. Low: the --tag argument of tpi-selfupdate is not validated”Lines 456 to 458 accept any value, and the comment at lines 470 to 471 claims otherwise. The
value flows into the download URL and the JSON. Only an authenticated caller reaches it. The
install path for an HTTP source is dead code. Nothing calls http_asset, and nothing reads
SOURCE_URL after line 433. So an install from firmware.turingpi.com fetches from GitHub and
fails.
7. Low: a committed private key
Section titled “7. Low: a committed private key”board/tp2bmc/factory_overlay/upper/etc/ssl/certs/bmcd_key.pem is upstream’s self-signed key,
with the name “Turing-Pi self signed” and an expiry in 1970. The factory SD image includes it
(post_image.sh lines 27 to 46 and 55, and files_to_delete.txt is empty). The release
artifacts do not include it (scripts/build.sh lines 133 to 176). The new certificate generator
keeps it when it exists (generate_self_signedx509.sh lines 133 to 138 and 223 to 235). Do not
flash the factory image.
- The nodes share
br0with BMC management (README line 77). The firmware ships VLAN presets inbmcd/src/app/switch_document.rs. - The password change feeds
chpasswdthrough stdin (access.rslines 299 to 311). A newline in a new password applies the first line and reports success. - CI grants
contents: writeonly on push and tag, and usespull_request, notpull_request_target(build.ymllines 22 to 32 and 245 to 248). Every action carries a SHA pin except the one inupstream-watch.ymlline 32, which holdsissues: writeonly. The build pulls the toolchain image by a mutable tag (build.ymllines 159 and 373). A workflow dispatch input lands in a shell command (build.ymlline 285), and only a caller with write access can trigger it. - SysRq is reachable over the serial console with BREAK, which needs physical access
(
linux_defconfig,S00sysrq). - Developer tooling:
.envrcevaluates devbox, andJustfileline 32 mounts the parent directory read-only into the build container. - No file in the repositories addresses an AI agent. A scan for zero-width and bidirectional characters found nothing. The two HTML comments in the issue templates are benign.
- The BMC-UI v4.1.0 artifact (658,860 bytes, built by
release.yamlfrom the tag withnpm ci) loads no remote script and calls noeval. Its only links are documentation. - The RK3588 loader blob
bmcd/src/usb_boot/rk3588_spl_loader_v1.08.111.bin(448,960 bytes, sha256a4765bcc) is identical to upstream.
Mitigations without a patch
Section titled “Mitigations without a patch”- Build the
.tpupackage from the reviewed revision and install it by hand (README.mdlines 141 to 144).scripts/configure.shline 77 checks Buildroot by sha256, andbuildroot_patches/0003pins the kernel hash. If you install a release instead, read its diff first and prefer--channel stable(tpi-selfupdatelines 44 to 48). - Change the root password at first boot.
bmcdforces that for the API (factory_password.rs). Install anauthorized_keysfile and setPasswordAuthentication noinsshd_configon the overlay. - Set
host:in/etc/bmcd/config.yamlto the management address (default_config.yamllines 3 and 15 to 17). Keep ports 22, 443 and 9110 away from the node ports with a firewall rule or a VLAN preset. - Remove or disable the GitHub and HTTP firmware sources (
type=firmware_sources, stored at/mnt/overlay/firmware-sources.json,firmware_sources.rsline 37). That stops the egress and the one-click install. - If you use the fleet proxy, pin
tls.client_cainconfig.yaml. The API then refuses to change it (access.rslines 352 to 356).
Patches worth carrying
Section titled “Patches worth carrying”upgrade_worker.rslines 285 to 310 andos_park: takePath::file_name(), reject any character outside[A-Za-z0-9._-], require the.tpusuffix, and run/sbin/osupdate <path>withoutsh -c.access.rsline 345: add the samemtlsrefusal thatdelete_client_cahas.tpi-selfupdateline 456: validate the tag withis_versionedand reject/,"and...sshd_config:PasswordAuthentication noafter the keys are in place.
Not verified
Section titled “Not verified”- The kernel patches (
rtl8370-vlan-support.patch, 928 lines, and the rebased i2c and realtek patches). The reviewer skimmed them.RTL8365MB_VLAN_MAXbounds the VLAN id index, but the reviewer did not read the driver. - The UBI preservation parser of BMC-Installer (
src/ubi/preserve.rs). Its input needs a prior write to the flash. - The 26,000-line delta of
bmcd. The reviewer read its authentication, shell calls, file writes, TLS and egress, not every handler, and did not audit the Cargo dependency tree. - The BMC-UI bundle. The reviewer did not compare it byte for byte with its source, because the bundle is minified.
- The mapping from the tag
v2.44.0to commit858e64cb. It comes from the commit message, not fromgit tag.