Repository navigation
fix(security): firmware critical findings (8 of 10 fixed; 2 deferred) - #4
Conversation
CI statusThe The
Nothing in this PR changes the JsonObject forward decl, the cfg.cpp signature, or the firmware-build workflow — so those failures remain identical to base. The intended order of operations is to land PR #3 first, after which a rebase here will go fully green. This PR's actual code changes are confined to 🤖 Generated with Claude Code |
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]>
fec8b77 to
5799cde
Compare
Summary
Fixes 8 of 10 critical/HIGH findings from the recent EvoLights security review of
wled_cloud_auth.{cpp,h}and the AuthGate. Each fix is anchored withEVOLIGHTS-ANCHORcomments and matched by a positive check intools/verify-evolights-integration.shso a future merge can't silently regress them.Fixes in this PR (FIXED)
cloud-token-loopback-onlyap-setup-allowlist/auth/setuprace + post-factory-reset takeoverauth-setup-mutex,auth-setup-presence/cloud/pairand/cloud/unpairhonoured cloud-trusted tokencloud-pairing-session-onlypbkdf2-iterslogin-timing-oracle-verifysession-lru-evictionEVOAUTHX=cookie-parse-anchoredDeferred
usermods/cloud_relay/ota_verifier.cpp, which is onfeat/firmware-signed-ota(PR #2), not onevolights/main. Will follow up in that PR.ota_verifier.cppnot in this base. The simplest implementation also requires editingcloud_relay.cpp(owned by PR #3feat/cloud-relay-tls). Will follow up after #2 lands.Verifier additions
New anchors enforced by
tools/verify-evolights-integration.sh:cloud-token-loopback-only,cloud-pairing-session-only(in cpp)ap-setup-allowlist(in cpp)auth-setup-mutex,auth-setup-presence(in cpp)session-lru-eviction,cookie-parse-anchored,login-timing-oracle-verify(in cpp)pbkdf2-iters(in header)Plus positive security invariants:
PBKDF2_ITERS >= 50000isLoopbackPeersymbol referenced/cloud/pairand/cloud/unpairmentioned inisAuthorizedg_setupInProgressflag existsatStart,afterDelim)Compatibility
v1$<iters>$<salt>$<hash>), so existing 4096-iter accounts keep working until the user changes their password.PBKDF2_ITERSwidened fromuint16_ttouint32_t;pbkdf2(),encodeHashBlob(), anddecodeHashBlob()updated to match. Format string switched from%uto%lu.decodeHashBlobnow usesstrtoulinstead ofatoi./welcome,/settings/wifi,/settings.js,/settings/wifi.js,/style.css,/favicon.ico— all in the new allowlist.Test plan
bash tools/verify-evolights-integration.sh(37 PASS / 0 FAIL locally)/auth/setup403 after 5min uptime when not in AP mode🤖 Generated with Claude Code