/

CVE-2026-40487

Severity:

HIGH RISK

(8.9)

Cross-Site Scripting (XSS) in Postiz

CVE-2026-40487

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79, CWE-345, CWE-434

Impact:

Stored Cross-Site Scripting leading to account takeover and session compromise

Severity:

HIGH RISK

(8.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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-Type from 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 the Content-Type request header to pass server-side checks.
  • Why exploitation is possible: The backend trusts the client-supplied Content-Type header 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-Type headers (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) and X-Content-Type-Options: nosniff to 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-Type request 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.

Sources

SourceLink
github.comgithub.com/gitroomhq/postiz-app/releases/tag/v2.21.6
github.comgithub.com/gitroomhq/postiz-app/security/advisories/GHSA-44wg-r34q-hvfx

Frequently asked

questions

Yes. Any remote attacker who can obtain an authenticated account (including low-privileged or self-registered accounts, where allowed) can exploit this issue by uploading a malicious file and then tricking other users into viewing it.

The attacker must be able to authenticate to the Postiz application and access the file upload functionality. Administrative privileges are not required; a basic user account with upload rights is sufficient.

Enforce strict, server-side validation of uploaded files using a whitelist of allowed types, verify content independently of client-supplied headers, and ensure uploaded content is served from an isolated origin or with safe MIME types and headers that prevent script execution.

Adopt a defense-in-depth strategy for file handling: never trust client-controlled metadata, minimize the set of allowed upload types, isolate user-generated content from sensitive origins, apply strong security headers, and incorporate automated checks for insecure upload and XSS patterns into the development and review process.

Find out what's already
exploitable in your codebase.