You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added security review guidelines and a short checklist covering critical security areas including buffer safety, input validation, authentication, secure defaults, and protection against common vulnerabilities. Refined rule wording and priorities to better fit WLED’s technical constraints and realistic deployment model.
The lists are based on the OWASP "top 10" from https://github.com/github/awesome-copilot/blob/main/instructions/security-and-owasp.instructions.md, and on lessons learned from past reviews.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: softhack007 <91616163+softhack007@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
# docs/hardening.instructions.md — basic rules for code hardening and robustness
10
+
# docs/securecode.instructions.md — more detailed checklists for common vulnerabilities
9
11
#
10
12
# NOTE: This file must be committed (tracked by git) for CodeRabbit to read
11
13
# it from the repository. If it is listed in .gitignore, CodeRabbit will
@@ -54,15 +56,50 @@ reviews:
54
56
6. CHECK for implied but weakly justified assumptions - like usermod loop() call frequency - and ask for clarification.
55
57
7. FLAG changes that appear unrelated: deleted comments, unnecessary re-formatting or re-factoring, and modifications in files that seem unrelated to the PR description.
Always reference these instructions - including coding guidelines in `docs/` - first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
10
11
@@ -27,7 +28,7 @@ required C headers for firmware compilation.
27
28
Tests use Node.js built-in test runner (`node:test`). The single test file is
28
29
`tools/cdata-test.js`. Run it with:
29
30
30
-
```sh
31
+
```bash
31
32
npm test# runs all tests via `node --test`
32
33
node --test tools/cdata-test.js # run just that file directly
33
34
```
@@ -41,7 +42,7 @@ target environments. Always build after code changes: `pio run -e esp32dev`.
data/ # Web UI source (HTML/JS/CSS) — tabs for indentation
56
57
html_*.h, js_*.h # Auto-generated (NEVER edit or commit)
@@ -132,6 +133,7 @@ main # Main development trunk (daily/nightly) 17.0.0-dev. Target
132
133
-**Performance**: Prefer DRAM (or IRAM) for hot-path data that is *frequently* used. Prefer PSRAM for capacity-oriented buffers where slightly slower access times can be tolerated.
133
134
134
135
Background Info:
136
+
135
137
- PSRAM access is up to 18× slower than DRAM on ESP32 (dual-SPI bus), 3–10× slower than DRAM on ESP32-S3/-S2 with quad-SPI bus. On ESP32-S3 with octal PSRAM (`CONFIG_SPIRAM_MODE_OCT`), the penalty is smaller (~2×) because the 8-line DTR bus can transfer 8 bits in parallel. On ESP32-P4 with hex PSRAM (`CONFIG_SPIRAM_MODE_HEX`), the 16-line bus runs at 200 MHz which brings it on-par with DRAM.
136
138
- Consider that ESP32 often crashes when the largest DRAM chunk gets below 10 KB.
137
139
@@ -158,10 +160,10 @@ Background Info:
158
160
159
161
#### ESP32 Task Synchronization
160
162
161
-
* Use FreeRTOS mutexes, semaphores or queues when true concurrent access from multiple FreeRTOS tasks is possible, and race-conditions can lead to unexpected behaviour.
162
-
***Avoid `portENTER_CRITICAL()` / `portEXIT_CRITICAL()`**, as these functions stall the complete system and may cause LEDs flickering. Prefer FreeRTOS mutexes, semaphores or queues.
163
-
***Important**: Not every shared resource needs a mutex. Some synchronization is guaranteed by the overall control flow, for example when function calls are sequenced within the same loop iteration.
164
-
* Consider RAII as an alternative to mutexes or semaphores.
163
+
- Use FreeRTOS mutexes, semaphores or queues when true concurrent access from multiple FreeRTOS tasks is possible, and race-conditions can lead to unexpected behaviour.
164
+
-**Avoid `portENTER_CRITICAL()` / `portEXIT_CRITICAL()`**, as these functions stall the complete system and may cause LEDs flickering. Prefer FreeRTOS mutexes, semaphores or queues.
165
+
-**Important**: Not every shared resource needs a mutex. Some synchronization is guaranteed by the overall control flow, for example when function calls are sequenced within the same loop iteration.
166
+
- Consider RAII as an alternative to mutexes or semaphores.
165
167
166
168
## Web UI Code Style (wled00/data/)
167
169
@@ -240,9 +242,16 @@ No automated linting is configured. Match existing code style in files you edit.
240
242
- Provide references when making analyses or recommendations. Support factual claims with verifiable citations, references or concrete evidence; **never fabricate citations**.
241
243
- **Highlight user-visible breaking changes and ripple effects** during reviews. Ask for confirmation that these were introduced intentionally.
242
244
245
+
### Security Hardening
246
+
247
+
When writing or reviewing code in `wled00/`, `usermods/`, `wled00/data/`, or `.github/workflows/`,
248
+
consult `docs/hardening.instructions.md` (concise checklist) and `docs/securecode.instructions.md` (detailed rules with examples).
249
+
These files define WLED's threat model, trust boundary model, and WLED-specific constraints (no TLS baseline, no UDP authentication for protocol-defined
Using AI-generated code can hide the source of the inspiration / knowledge / sources it used.
254
+
Using AI-generated code can hide the source of the inspiration / knowledge / sources it used.
246
255
247
256
- Document attribution of inspiration / knowledge / sources used in the code, e.g. link to GitHub repositories or other websites describing the principles / algorithms used.
248
257
- When a larger block of code is generated by an AI tool, embed it into `// AI: below section was generated by an AI` ... `// AI: end` comments (see Comments section).
@@ -251,5 +260,5 @@ Using AI-generated code can hide the source of the inspiration / knowledge / sou
251
260
252
261
### Supporting Reviews and Discussions
253
262
254
-
- **For "is it worth doing?" debates** about proposed reliability, safety, or data-integrity mechanisms (CRC checks, backups, power-loss protection): suggest a software **FMEA** (Failure Mode and Effects Analysis).
263
+
- **For "is it worth doing?" debates** about proposed reliability, safety, or data-integrity mechanisms (CRC checks, backups, power-loss protection): suggest a software **FMEA** (Failure Mode and Effects Analysis).
255
264
Clarify the main feared events, enumerate failure modes, assess each mitigation's effectiveness per failure mode, note common-cause failures, and rate credibility for the typical WLED use case.
0 commit comments