Summary
Statamic CMS versions 5.73.8 and below, and 6.0.0-alpha.1 through 6.3.1, contain a stored cross-site scripting (XSS) vulnerability in HTML fieldtypes that allows authenticated users with field management permissions to inject malicious JavaScript.
The injected script executes when higher-privileged users view the affected content, potentially enabling privilege abuse and account compromise within the administrative interface.
Affected context
The vulnerability exists in Statamic installations that:
- Use HTML fieldtypes in content or configuration schemas, and
- Grant some users permissions to create or manage fields and fieldsets, and
- Allow higher-privileged users (e.g., admins, content architects) to view or edit content that includes those HTML fields via the control panel.
It manifests when user-supplied HTML is rendered without sufficient sanitization or encoding in the browser context for other users, especially those with higher privileges.
Exploit preconditions
- Attack surface: Statamic control panel and any interface where HTML fieldtypes are rendered.
- Required access: Authenticated Statamic user with permissions to manage or configure fields/fieldsets that use the vulnerable HTML fieldtype.
- Trigger point: Viewing of the crafted field content or configuration by another user, particularly a higher-privileged account, in the Statamic control panel or related views.
- Why exploitation is possible: User-controlled HTML from field definitions is stored and later rendered as active HTML/JavaScript in other users' browsers without robust sanitization and output encoding, allowing persistent script execution.
Why this happens
This issue is rooted in insufficient output encoding and sanitization of user-controllable HTML content associated with Statamic's HTML fieldtypes.
The application stores attacker-supplied HTML in configuration or content and later renders it in privileged users' browsers within the same origin as the Statamic control panel. This behavior aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where untrusted input is integrated into a web page without proper neutralization, enabling execution of arbitrary JavaScript in the victim's session.
Potential impact
- Theft of session tokens or CSRF tokens from higher-privileged users' browsers
- Execution of privileged actions on behalf of an administrator (e.g., creating new users, changing settings, editing content)
- Unauthorized modification or defacement of site content and configuration
- Creation of hidden backdoor administrator accounts through UI-driven actions
- Pivoting into broader application compromise if administrative capabilities are abused
General mitigation guidance
Effective mitigation focuses on treating all HTML associated with field configurations as untrusted and limiting its ability to run active script:
- Prefer fieldtypes and UI components that store data, not raw executable HTML, especially for configuration or shared fields.
- Apply robust context-aware output encoding whenever user-controlled content is rendered in the control panel or other authenticated interfaces.
- Introduce strict server-side sanitization for HTML fields, stripping or normalizing dangerous constructs such as script tags, inline event handlers, and javascript: URLs.
- Use a positive-security model for allowed HTML (e.g., an allowlist-based sanitizer) rather than attempting to block known-bad patterns.
- Enforce least-privilege permissions for field and fieldset management so that only trusted administrators can define or edit HTML fieldtypes.
- Consider separating configuration-editing privileges from day-to-day content editing roles to reduce exposure if an account is compromised.
How teams detect issues like this
Organizations can detect and manage similar XSS risks in CMS platforms through:
- Static analysis and code review:
- Flag locations where raw HTML from configuration or database fields is directly echoed into templates without escaping.
- Look for template constructs or helper functions that bypass encoding (e.g., "raw" or "unescaped" output modes) when handling user-controlled content.
- Review fieldtype and form rendering logic for missing sanitization or reliance on client-side filters only.
- Security testing:
- Include stored XSS test cases in QA for all custom fieldtypes and control panel views.
- Use automated application security scanners configured to crawl authenticated control panel routes and input forms.
- Policy and process:
- Incorporate secure templating guidelines that mandate encoded output by default and require justification for exceptions.
- Use CI-based linting or SAST tools to enforce patterns like "no unescaped HTML from user fields."

