| applyTo | **/*.{cpp,h,hpp,ino,js,htm,html,css,yml,yaml} |
|---|---|
| description | WLED-focused security review guide based on OWASP Top 10 for embedded firmware and web UI. |
Use this guide for AI-assisted code reviews in:
wled00/usermods/.github/workflows/
- Assume typical deployment behind a firewall/DMZ/VPN; prioritize LAN-local and supply-chain risks.
- Do not require TLS/HTTPS as a baseline control for findings in this repo.
- Do not require authentication for standards-based UDP multicast/broadcast protocols where auth is not part of the spec.
- Do not propose mitigations that break protocol compliance just to add authentication.
- CRITICAL — exploitable vulnerability; block merge.
- IMPORTANT — meaningful risk; fix before or with merge when practical.
- SUGGESTION — defense-in-depth; track for follow-up.
Prioritize:
- C++ memory safety and input validation
- Auth and access checks for state-changing HTTP/JSON APIs
- XSS and DOM safety in
wled00/data/* - Secrets handling (
wsec.json) and secure logging - Dependency and GitHub Actions supply-chain hygiene
- Fail-safe behavior on constrained devices
De-prioritize unless explicitly introduced by a PR:
- SQL/NoSQL checks, JWT/OAuth flows, GraphQL-specific checks, generic backend framework checks not used by WLED.
- Severity: CRITICAL
- Flag
strcpy,sprintf, uncheckedmemcpy, unchecked pointer arithmetic. - Require explicit bounds checks and length validation.
- Severity: CRITICAL
- Do not pass untrusted input as a format string to
DEBUG_PRINTF*or similar APIs.
- Severity: IMPORTANT
- Review
count * size, index math, narrowing casts before allocations or copies.
- Severity: CRITICAL
- Validate and clamp external values from HTTP/JSON/UDP/serial before use as lengths, indices, IDs, or pin references.
- In UDP handlers (
parsePacket(),read(), and any lower-level socket wrappers), validatepacketSizebefore buffer writes and clamp protocol-specific universe/channel ranges to valid limits.
- Severity: CRITICAL
- HTTP/JSON and other control paths that support auth must enforce configured auth policy.
- Do not flag standards-based UDP multicast/broadcast paths solely for lacking authentication when authentication is not defined in the protocol specification.
- Severity: IMPORTANT
- On error, reject update and preserve safe previous state.
- Explicitly check parse status (
DeserializationError error = deserializeJson(...); if (error) return/reject;) and avoid silently applying unsafe zero/default values to safety-relevant fields (for example LED count and pin assignment).
- Severity: IMPORTANT
- Avoid repeated dynamic allocation in render/effect loops; prefer pre-allocation and reuse.
- Flag allocation patterns in loop and ISR-adjacent paths that can trigger fragmentation or timing instability.
- Severity: IMPORTANT
- In hot paths, avoid repeated
Stringgrowth; reserve or use fixed buffers. - Flag repeated
Stringconcatenation inside loop-heavy or ISR-adjacent code.
- Severity: IMPORTANT
- Verify all new
WLED_ENABLE_*/WLED_DISABLE_*names are valid known flags; typos silently alter build behavior.
- Severity: IMPORTANT
- OTA update flows should validate firmware integrity using the checksum/hash/signature mechanism available in the firmware/platform implementation.
- Do not require TLS/certificate pinning as a mandatory review criterion.
- In OTA paths (
Update.begin(),Update.write(), and related flows), flag flashing without integrity verification.
- Severity: IMPORTANT
- In
xTaskCreate/xTaskCreatePinnedToCoretasks that processString/JSON-heavy data, verify stack-size sufficiency and avoid unbounded recursion.
- Severity: IMPORTANT
- For
MDNS.begin(),MDNS.addService(), andArduinoOTA.setHostname(), ensure user-provided hostnames are RFC-compliant (letters/digits/hyphen, no leading/trailing hyphen) and clamped to 63 characters.
- Severity: SUGGESTION
- When using user-provided URL strings with
HTTPClient.begin()/equivalent, validate scheme/format and constrain host targets (allowlist or equivalent policy). - Do not require HTTPS/TLS as a baseline review rule.
- Severity: SUGGESTION
- For unicast UDP receive paths, prefer optional user-configurable source filtering.
- Do not require this for multicast/broadcast protocol flows.
- Severity: CRITICAL
- Prefer
textContent; if HTML is required, sanitize trusted content path explicitly.
- Severity: CRITICAL
- Reject
eval,new Function, and string-based timer execution.
- Severity: IMPORTANT
- Require strict origin allowlist checks before processing payloads.
- Severity: IMPORTANT
- Do not navigate directly from untrusted query/input without relative-path or allowlist checks.
- Severity: IMPORTANT
- UI validation is not sufficient; equivalent firmware-side validation is required.
- Severity: IMPORTANT
- Treat fetched and config-derived strings as untrusted unless proven otherwise.
- Severity: SUGGESTION
- For state-changing HTTP routes (for example
/json/state,/win), preferOrigin/Refererheader validation as low-cost defense-in-depth for deployments that are not directly internet-exposed. - Treat this as advisory only, since some legitimate clients may omit these headers.
- Severity: CRITICAL
- Reject committed API keys, passwords, tokens, private keys, or test backdoors with potential security impact.
- Severity: CRITICAL
- Do not log passwords, tokens, Wi-Fi keys, auth headers, or full sensitive payloads.
- Severity: IMPORTANT
- Reject new default credentials or insecure auto-enable behavior for privileged functions.
- For setup/onboarding flows, require first-change behavior for default credentials where applicable.
- Severity: IMPORTANT
- Avoid exposing stack traces or internal details to API/UI consumers.
- Severity: IMPORTANT
- Flag API/config serialization that exposes password-like fields (for example Wi-Fi/AP/MQTT passwords) to unauthenticated or untrusted clients.
- Severity: SUGGESTION
- Prefer explicit logging for auth failures, OTA attempts, config resets, and AP activation events, without logging secret values.
- Severity: IMPORTANT
- Review new npm/pip/PlatformIO dependencies for legitimacy, pinning, and known vulnerabilities.
- Severity: IMPORTANT
- Check for broad
permissions, unpinned third-party actions, or unsafe secret exposure. - Flag mutable third-party action refs (
@main,@master, broad tags) where SHA pinning is expected by project policy. - Flag overly broad permissions such as
write-allwithout clear need.
- Severity: IMPORTANT
- Avoid direct interpolation of untrusted
${{ github.event.* }}values inruncommands.
- No new memory-safety hazards (bounds, overflow, unsafe copies/format strings)
- External input is validated and range-clamped before use
- State-changing API paths enforce auth policy
- OTA paths enforce integrity verification (without requiring TLS baseline)
- Suggested rule patterns are checked where relevant (UDP bounds, hostname sanitization, workflow pinning/permissions)
- Web UI changes avoid unsafe DOM execution/injection patterns
- No secrets added; no sensitive logging introduced
- Error handling remains fail-safe and non-leaky
- Dependency/workflow changes are supply-chain safe
- Feature-flag names are valid and not typoed
- Prefer concrete, file/line-specific findings over generic guidance.
- Prioritize CRITICAL and IMPORTANT findings.
- Skip irrelevant framework checks not used by WLED.
- If control-flow trust is unclear, ask for clarification instead of guessing.