Skip to content

Fix/xss and undefined http accept language#2101

Merged
theCalcaholic merged 1 commit intodevelfrom
fix/xss-and-undefined-http-accept-language
Apr 3, 2026
Merged

Fix/xss and undefined http accept language#2101
theCalcaholic merged 1 commit intodevelfrom
fix/xss-and-undefined-http-accept-language

Conversation

@theCalcaholic
Copy link
Copy Markdown
Collaborator

@theCalcaholic theCalcaholic commented Apr 3, 2026

From the original PR (#2096):

Summary

This PR fixes two issues in the NextCloudPi web panel that can cause the admin dashboard to fail loading:

1. XSS vulnerability / HTML parser breakage via ncp.log content

Problem: When /var/log/ncp.log contains HTML-like strings (e.g., <strftime_format> from backup operations), the unescaped output in index.php breaks the browser's HTML parser. This causes:

  • The browser to treat log content as HTML tags
  • Subsequent <script> tags to be ignored
  • minified.js and ncp.js never execute
  • Dashboard shows infinite "System Info" loading spinner

Fix: Wrap file_get_contents('/var/log/ncp.log') with htmlspecialchars(..., ENT_QUOTES, 'UTF-8') to properly escape HTML entities.

2. PHP warning for undefined HTTP_ACCEPT_LANGUAGE array key

Problem: When HTTP requests lack the Accept-Language header (common with API calls, curl, automated scripts), PHP emits an "Undefined array key" warning. In ncp-launcher.php, this warning can corrupt JSON responses.

Fix: Use PHP's null coalescing operator (?? '') to provide a default empty string when the header is missing.

Files Changed

  • ncp-web/index.php (lines 68, 290)
  • ncp-web/ncp-launcher.php (line 24)

Testing

Tested on NextCloudPi running in an LXC container on Proxmox. After applying these fixes:

  • Dashboard loads correctly even with HTML-like content in logs
  • No PHP warnings in Apache error logs for missing Accept-Language header
  • All existing functionality remains intact

Related Issues

This addresses a real-world issue where users see an infinite loading spinner on the "System Info" section of the NCP admin panel.

@theCalcaholic theCalcaholic force-pushed the fix/xss-and-undefined-http-accept-language branch from b267721 to 2bbc685 Compare April 3, 2026 16:40
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
@theCalcaholic theCalcaholic force-pushed the fix/xss-and-undefined-http-accept-language branch from 2bbc685 to 658157d Compare April 3, 2026 17:04
@theCalcaholic theCalcaholic merged commit efeec6a into devel Apr 3, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants