Commit efeec6a
fix(ncp-web): prevent XSS via log output and undefined array key warning (#2101)
This commit addresses two issues in the NextCloudPi web panel:
1. HTML injection via ncp.log content (XSS vulnerability)
- When /var/log/ncp.log contains HTML-like content (e.g., <strftime_format>
from certain backup operations), the unescaped output breaks the HTML parser
- This causes the browser to ignore subsequent <script> tags, preventing
minified.js and ncp.js from loading
- Result: the dashboard never loads and shows infinite "System Info" spinner
- Fix: wrap file_get_contents() with htmlspecialchars() in index.php line 290
2. PHP warning for undefined HTTP_ACCEPT_LANGUAGE
- When requests lack Accept-Language header (e.g., API calls, curl),
PHP emits "Undefined array key" warning
- This warning can corrupt JSON responses from ncp-launcher.php
- Fix: use null coalescing operator (?? '') in both index.php and
ncp-launcher.php
Tested on NextCloudPi running in LXC container on Proxmox.
Made-with: Cursor
Co-authored-by: Aroldo de Mattos Bossoni <github@bossone.com.br>2 files changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments