Summary
A stored cross-site scripting (XSS) vulnerability in pyLoad's modern WebUI theme allows unescaped user-supplied URLs to be injected into HTML and executed as JavaScript in the operator's browser.
An attacker who can submit a package link can craft a malicious URL that breaks out of an HTML attribute and runs arbitrary script code whenever an operator opens the downloads view.
Affected context
The issue occurs in the packages.js template of pyLoad's modern WebUI theme, where package link URLs returned from the backend API are interpolated into a JavaScript-built HTML string and inserted into the DOM using $(div).html(html).
The vulnerability is relevant when:
- The modern theme is enabled and used to render the downloads view.
- Users are allowed to submit or influence package link URLs.
- The browser loads the affected view, causing the unescaped URL value to be rendered as part of the page's HTML.
The absence of a restrictive Content Security Policy (CSP) for inline scripts or event handlers increases the exploitability of this pattern.
Exploit preconditions
- Attack surface: Web-based, through the pyLoad WebUI downloads view.
- Required access: Ability to submit or control a package link (e.g., authenticated or semi-trusted user "Alice" who can add download URLs).
- Trigger point: An operator (or any user with access to the WebUI) navigates to the downloads view where the malicious package entry is rendered by
packages.js. - Why exploitation is possible: The link URL from the API is directly interpolated into a single-quoted HTML attribute inside a template literal without HTML encoding or attribute escaping, and the resulting string is injected into the DOM via
.html(). This lets an attacker break out of the attribute context and inject event handlers or inline JavaScript, which the browser executes because no restrictive CSP blocks it.
Why this happens
This vulnerability stems from treating untrusted data as safe HTML and inserting it into the DOM without encoding or escaping, a direct instance of CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).
In the affected template, the package link URL from the backend is concatenated into an HTML fragment within JavaScript, embedded inside single quotes in an attribute. Since no HTML or attribute escaping occurs, an attacker-supplied single quote and event handler (for example, onerror, onclick) terminates the original attribute value and injects executable script.
The use of $(div).html(html) amplifies the issue by instructing the browser to interpret the string as raw HTML rather than as text, allowing any injected tags or attributes to become active content.
Potential impact
- Execution of arbitrary JavaScript in the operator's browser when viewing the downloads page.
- Theft or modification of session data accessible to the injected script (e.g., cookies, local storage, in-page tokens) subject to browser protections.
- Manipulation of the WebUI, including spoofing UI elements, altering visible download entries, or tricking operators into unintended actions.
- Use of the operator's browser as a pivot to perform authenticated actions against pyLoad or integrated services.
- Persistent compromise of operators' browsing sessions as long as the malicious package entry remains in the system.
General mitigation guidance
Effective mitigation focuses on treating all user-influenced values as untrusted and ensuring they cannot be interpreted as executable content when rendered:
- Apply context-appropriate output encoding for all user-supplied data before inserting into HTML, especially within attributes. For attribute contexts, ensure characters like quotes, angle brackets, and backticks are encoded.
- Prefer safe DOM APIs that separate data from markup, such as setting
element.textContent/$(element).text()or using attribute setters (element.setAttribute) instead of building HTML strings and passing them to.html()/innerHTML. - Adopt a templating system that auto-escapes variables by default and requires explicit opt-out for raw HTML insertion.
- Introduce a restrictive Content Security Policy (CSP) that disallows inline event handlers and inline scripts, reducing the blast radius if encoding gaps occur.
- Minimize the privileges of data providers: restrict who can submit package links, validate links server-side, and reject clearly malformed or script-like URLs where appropriate.
How teams detect issues like this
Organizations can detect this class of issue through a combination of code analysis and runtime checks:
- Static analysis rules that flag:
- Concatenation of untrusted variables into strings passed to
.html(),innerHTML, or similar sink APIs. - Interpolation of backend/API values into HTML attributes without encoding helpers.
- Secure coding guidelines and code review checklists requiring reviewers to:
- Verify that all user-derived data in templates passes through encoding/escaping functions appropriate to the output context.
- Question any use of raw HTML insertion methods in UI code and prefer safer DOM operations.
- Automated scanning tools (SAST and DAST) configured to detect stored XSS patterns, including payload injection via persisted fields like URLs, titles, and descriptions.
- CSP violation monitoring (when CSP is present) to identify attempts to execute inline script or event handlers, which can highlight residual XSS vectors.

