Summary
Postiz contains a stored Cross-Site Scripting (XSS) vulnerability where authenticated users can upload executable files (such as HTML or SVG) by spoofing the Content-Type header and bypassing server-side validation.
Because nginx later serves these files based on their original file extension, attacker-controlled script content can execute in the context of the Postiz origin, potentially leading to session riding, account takeover, and full compromise of other users' accounts.
Affected context
The vulnerability manifests in Postiz deployments that expose the built-in file upload functionality to authenticated users and rely on the Content-Type request header for upload validation.
It primarily affects environments where:
- User-uploaded files are stored on the same domain or origin as the main Postiz application.
- nginx (or a similar web server) serves uploaded files directly and infers the response
Content-Typefrom the file extension instead of trusted metadata. - Uploaded content is not constrained to a strictly non-executable, content-only set of types (e.g., images without active content).
Exploit preconditions
- Attack surface: Authenticated web interface for file uploads within the Postiz application.
- Required access: Any authenticated user account with permission to upload files (e.g., regular user, not necessarily an administrator).
- Trigger point: Upload of a malicious file (e.g.,
.html,.svg) while spoofing theContent-Typerequest header to pass server-side checks. - Why exploitation is possible: The backend trusts the client-supplied
Content-Typeheader for validation, allowing an attacker to bypass controls and store active content; nginx later serves the file with an executable MIME type based on the file extension, enabling script execution in the browser under the Postiz origin.
Why this happens
The core issue is an insecure trust model around file upload validation and content handling.
The application validates uploads primarily by inspecting the Content-Type request header, a client-controlled value that can be easily spoofed. This behavior aligns with CWE-345: Insufficient Verification of Data Authenticity, as the system assumes authenticity of header metadata without independent verification, and CWE-434: Unrestricted Upload of File with Dangerous Type, since potentially executable file types can be stored and delivered.
Once uploaded, nginx determines the response Content-Type from the file extension, not from vetted server-side classification, which enables active content (HTML, SVG with scripts, or similar) to be served as executable resources. When a victim user accesses these resources, untrusted script executes in their browser within the Postiz origin, directly corresponding to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting) in its stored form.
Potential impact
- Stored Cross-Site Scripting that executes whenever another user visits the malicious uploaded file or a page that embeds it.
- Hijacking of authenticated sessions via theft of session tokens or cookies where not otherwise protected.
- Account takeover for other users, including administrators, if they are lured into viewing attacker-controlled content.
- Unauthorized actions performed on behalf of victims (session riding / CSRF-like abuse using in-context JavaScript).
- Potential pivot to broader application compromise through manipulation of application settings or connected integrations accessed via a compromised account.
General mitigation guidance
Effective mitigation focuses on tightening upload validation, file serving policies, and origin separation:
- Treat all client-supplied metadata, including
Content-Type, as untrusted; perform server-side type verification using file signatures, whitelisting, and strict extension checks. - Restrict uploads to a minimal, well-defined set of non-executable types (e.g., specific image formats) and reject or sanitize formats that can embed scripts (such as HTML, SVG, or PDF with active content).
- Serve uploaded content from a separate domain or subdomain with no access to session cookies or sensitive origin-bound data (content isolation).
- Configure the web server to force safe
Content-Typeheaders (e.g.,application/octet-stream) for generic or ambiguous file types and to disable execution of active content where not required. - Apply security headers such as
Content-Security-Policy(CSP) andX-Content-Type-Options: nosniffto reduce the risk of executing unintended content. - Follow least-privilege principles for application roles: grant upload capabilities only where necessary and avoid unnecessary exposure of uploaded files to other users.
How teams detect issues like this
Detection approaches can combine code-level review, configuration analysis, and runtime monitoring:
- Static analysis & code review:
- Search for file upload handlers that rely on
Content-Typerequest headers, file extensions, or unvalidated client metadata for security decisions. - Identify any logic that allows HTML, SVG, or generic file types to be uploaded without robust server-side validation or sanitization.
- Review file-serving paths where uploaded files are returned directly by nginx or another web server, especially if they share the same origin as the web application.
- Configuration review:
- Audit nginx (or equivalent) configuration to ensure mappings between file extensions and MIME types do not inadvertently treat user-generated content as executable when this is not intended.
- Verify that response headers for uploaded content are enforced server-side and do not rely on user-controlled metadata.
- Runtime monitoring:
- Log and analyze upload activity, looking for unusual patterns such as uploads of
.html,.svg, or other potentially active file types. - Use web application firewalls (WAF) or reverse proxies configured with rules to flag or block suspicious upload attempts and script-like content in files.
- Automated code review or SAST tools can help flag insecure upload validation patterns and potential stored XSS sinks when integrated into the CI/CD pipeline.

