Repository navigation
Add signed-OTA verifier to firmware (Ed25519 + sha256) - #2
Merged
Merged
Conversation
1 of 4 tasks
johnsonflix
pushed a commit
that referenced
this pull request
May 3, 2026
Eight related security fixes in wled_cloud_auth.{h,cpp}, plus matching
verifier invariants. Each is anchored with EVOLIGHTS-ANCHOR comments so a
future merge can't silently regress them.
1. cloud-token-loopback-only: cloud-trusted token only honoured when the
request peer is 127.0.0.1. Previously any LAN client carrying a leaked
or guessed token bypassed auth.
2. ap-setup-allowlist: replace blanket "AP + no WiFi configured" bypass
with an explicit allowlist (welcome, /settings, /settings/wifi*, .js,
.css, /favicon.ico). /edit, /update, /json/cfg, /settings/sec etc.
now require auth even pre-setup.
3. auth-setup-mutex + auth-setup-presence: serialize concurrent
/auth/setup POSTs (single-flight via volatile flag + RAII guard) AND
require physical-presence proxy (request must be in AP mode OR within
5 minutes of boot). Closes the post-factory-reset takeover window.
4. cloud-pairing-session-only: refuse the cloud-trusted token for
/cloud/pair and /cloud/unpair. Those endpoints require a real local
session so a remote actor with the bypass token can't wipe pairing.
7. pbkdf2-iters: bump PBKDF2 from 4096 -> 50000 (target ~600ms login
latency on ESP32 @ 240MHz). Stored hashes embed the iter count so
existing accounts keep working with their original iter count until
the user changes their password.
8. login-timing-oracle-verify: always run PBKDF2 against a fixed dummy
salt+hash on the unknown-user path, denying the attacker a
username-enumeration timing oracle.
9. session-lru-eviction: when the session table fills, evict the slot
with the smallest lastUsedAt (real LRU) instead of always slot 0,
which used to boot the active admin out on a 9th login.
10. cookie-parse-anchored: cookie matcher now requires "EVOAUTH=" to be
at the start of the Cookie header OR preceded by "; ", so a
malicious cookie like "EVOAUTHX=junk" can't smuggle a token in.
The parsed token is also trimmed before use.
Also: extend tools/verify-evolights-integration.sh with the eight new
anchors plus positive security checks (PBKDF2 floor, isLoopbackPeer
reference, /cloud/pair && /cloud/unpair mention in isAuthorized,
g_setupInProgress flag, anchored cookie parse markers).
Deferred from this PR (file lives in feat/firmware-signed-ota PR #2,
not in evolights/main):
- ota_verifier downgrade-attack (#5)
- ota_verifier CDN CA pinning (#6)
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
johnsonflix
pushed a commit
that referenced
this pull request
May 3, 2026
Trust chain:
- Cloud signs (version|url|sha256) with Ed25519 private key kept on the
cloud panel host only
- Firmware embeds matching 32-byte raw pubkey as PROGMEM OTA_PUBKEY_B64
- On receipt the device verifies sig FIRST, then downloads the binary,
streams it to flash while computing sha256 inline, and aborts if either
the manifest version is <= current OR the sha256 doesn't match
- Update.end() commits only on full success; ESP.restart() to swap
Downgrade protection (added during PR #2 rebase): refuses any manifest
whose yymmddb version integer isn't strictly greater than the running
firmware's VERSION. Without this, a signed older manifest could be
replayed to roll back security fixes.
Trust model: the Ed25519 signature is the trust anchor for what we flash,
not TLS. The download itself runs over plain HTTP because WLED's slim
Tasmota ESP32 framework lacks mbedtls SSL support entirely (see TLS
deferral notes in cloud_relay.cpp). A MITM can drop bytes (sha256
mismatch -> abort), feed a previously-signed bin (downgrade check ->
refuse OR sha256 mismatch -> abort), or attempt malware injection
(signature wouldn't verify -> never reach flash).
Verifier extensions:
- ota_verifier.{h,cpp} required-files check
- ota-pubkey + ota-downgrade-protection + ota-trust-model anchors
- cloud_relay must include ota_verifier.h and dispatch to processManifest
- OTA_PUBKEY_B64 must be non-empty (base64 of 40+ chars)
- Code must literally contain `manifestVer <= currentVer` check
The dev key in OTA_PUBKEY_B64 was generated by
evolights-cloud/tools/generate-ota-keys.sh and MUST be replaced with a
production key before any production firmware build.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
johnsonflix
force-pushed
the
feat/firmware-signed-ota
branch
from
May 3, 2026 15:17
663d065 to
0739813
Compare
johnsonflix
added a commit
that referenced
this pull request
May 3, 2026
8 of 10 critical findings fixed:
1. Cloud-trusted token loopback-only (LAN forgery blocked)
2. AP-mode bypass replaced with explicit allowlist
3. /auth/setup mutex + 5min post-boot/AP-only window
4. /cloud/{pair,unpair} no longer honor cloud-trusted token
7. PBKDF2 iters 4096 -> 50000
8. Login timing equalized (always run PBKDF2)
9. Session eviction is now LRU
10. Cookie parser anchored against EVOAUTHX= bug
The two OTA criticals (#5 downgrade, #6 CDN CA pin) are addressed in PR #2.
Verifier: 41/41 invariants pass.
Trust chain:
- Cloud signs (version|url|sha256) with Ed25519 private key kept on the
cloud panel host only
- Firmware embeds matching 32-byte raw pubkey as PROGMEM OTA_PUBKEY_B64
- On receipt the device verifies sig FIRST, then downloads the binary,
streams it to flash while computing sha256 inline, and aborts if either
the manifest version is <= current OR the sha256 doesn't match
- Update.end() commits only on full success; ESP.restart() to swap
Downgrade protection (added during PR #2 rebase): refuses any manifest
whose yymmddb version integer isn't strictly greater than the running
firmware's VERSION. Without this, a signed older manifest could be
replayed to roll back security fixes.
Trust model: the Ed25519 signature is the trust anchor for what we flash,
not TLS. The download itself runs over plain HTTP because WLED's slim
Tasmota ESP32 framework lacks mbedtls SSL support entirely (see TLS
deferral notes in cloud_relay.cpp). A MITM can drop bytes (sha256
mismatch -> abort), feed a previously-signed bin (downgrade check ->
refuse OR sha256 mismatch -> abort), or attempt malware injection
(signature wouldn't verify -> never reach flash).
Verifier extensions:
- ota_verifier.{h,cpp} required-files check
- ota-pubkey + ota-downgrade-protection + ota-trust-model anchors
- cloud_relay must include ota_verifier.h and dispatch to processManifest
- OTA_PUBKEY_B64 must be non-empty (base64 of 40+ chars)
- Code must literally contain `manifestVer <= currentVer` check
The dev key in OTA_PUBKEY_B64 was generated by
evolights-cloud/tools/generate-ota-keys.sh and MUST be replaced with a
production key before any production firmware build.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Was: extern const char[] / const char[] = pubkey_array — array copy-init
errors at compile time on the .cpp side ('initializer fails to determine
size of array').
Now: extern const char* const / const char* const = pubkey_array — pointer
to the same PROGMEM bytes, valid in both TUs. The marker is purely so the
verifier (or any future tooling) has a stable C symbol to look up.
johnsonflix
force-pushed
the
feat/firmware-signed-ota
branch
from
May 3, 2026 15:37
d70534b to
02fe2ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires up the OTA receive path on the device.
Manifest format:
Over
evolights/<device_id>/ota. The device:OTA_PUBKEY_B64Dev pubkey is in the file; must be replaced before production. The matching private key lives only on the cloud panel host.
Local verifier: 27/27 (+5 OTA invariants).
Note: Stacks on top of #1 (the platformio env fix needs to land first for the build matrix to actually compile this). Will rebase if #1 lands first.