Summary
A stored Cross-Site Scripting (XSS) vulnerability in the Payload CMS admin panel allowed authenticated users with write access to a collection to persist malicious content.
When another user viewed the crafted content in the admin interface, the attacker-controlled script could execute in the victim's browser under their authenticated session.
Affected context
This vulnerability affects deployments of Payload CMS using the @payloadcms/next admin panel where:
- Users are granted authenticated access to the admin interface
- At least some users have write permissions to one or more collections
- Admin UI views render stored content back to users within their browser
The issue manifests when user-supplied content from collections is rendered without sufficient sanitization or escaping, allowing scripts to run in the context of the admin panel.
Exploit preconditions
- Attack surface: Web-based admin panel of Payload CMS (
@payloadcms/next). - Required access: Authenticated account with write permissions to at least one affected collection.
- Trigger point: Viewing of the maliciously stored content by another authenticated user (e.g., editor, administrator) in the admin interface.
- Why exploitation is possible: The application fails to consistently neutralize or encode dangerous characters and scripting constructs before rendering stored content into HTML, enabling attacker-controlled JavaScript to execute in other users' browsers.
Why this happens
The core issue aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
User-provided content from collections is stored in the database and later incorporated into admin panel pages without robust output encoding or sanitization appropriate to the rendering context (HTML, attribute, or script).
This insecure pattern—treating stored, user-controlled data as safe for direct inclusion in the DOM—allows injected script payloads to run with the privileges of the viewing user's browser session.
Potential impact
- Attacker-controlled scripts may execute within the admin panel for affected users.
- Session hijacking or impersonation of more privileged admin accounts could occur if session tokens or sensitive context are accessible to script.
- Unauthorized actions can be performed on behalf of victims (e.g., modifying content, changing configuration, managing users) via CSRF-like behavior from within the XSS context.
- Exposure of sensitive data visible in the admin UI, such as unpublished content or internal configuration details.
- Potential pivot into broader application compromise if the admin panel controls critical operational or integration settings.
General mitigation guidance
Effective mitigation focuses on consistently treating all user-supplied content as untrusted and encoding it according to its rendering context:
- Apply robust output encoding (HTML, attribute, URL, JavaScript context-aware encoding) at every point where stored content is rendered in the admin panel.
- Use well-tested templating or UI frameworks that auto-escape content by default and require explicit, reviewed opt-outs for raw HTML rendering.
- Introduce server-side sanitization for fields intended to allow rich text or HTML, using allowlists of safe tags and attributes rather than blocklists.
- Design permission models so that high-privilege admin accounts are limited in number and do not routinely browse untrusted contributed content.
- Enforce content validation at the schema/field level, restricting where HTML or script-like constructs are allowed and favoring plain text where possible.
How teams detect issues like this
Detection generally combines code-focused and behavior-focused approaches:
- Use static analysis or linters to flag direct insertion of user-controlled data into HTML templates or React components without escaping.
- During code review, look for patterns such as dangerouslySetInnerHTML, raw HTML injection, or bypassing framework auto-escaping mechanisms in admin views.
- Implement automated security testing (DAST) that attempts to store and later trigger XSS payloads across collections and admin listings/detail views.
- Instrument server and client logs to capture anomalous script errors, unexpected DOM modifications, or suspicious parameters appearing in admin panel views.
- Integrate SAST/secret scanning tools into CI pipelines to enforce policies around safe rendering and to catch new unescaped rendering paths early.

