Summary
Sharp contains a stored cross-site scripting vulnerability in its rich-text Editor field because the sanitizer permits the srcdoc attribute on iframe elements. An authenticated user who can edit such content may store JavaScript that executes when another user views it, potentially enabling account compromise or unauthorized actions.
Affected context
The vulnerability occurs in Sharp deployments using the affected rich-text Editor field and an HTML sanitizer that permits srcdoc on iframe elements. Exploitation generally requires an authenticated account with permission to edit Editor content, followed by another user rendering the stored content in a browser.
Exploit preconditions
- Attack surface: Rich-text Editor content rendered in the Sharp administrative or content-management interface
- Required access: An authenticated user with permission to edit an Editor field
- Trigger point: Another user views the stored content in a browser
- Why exploitation is possible: The sanitizer permits iframe
srcdoccontent, and browsers decode attribute entities before interpreting the embedded document, allowing stored markup to execute script
Why this happens
The underlying issue is insufficient HTML sanitization of a browser-interpreted attribute. Although markup within srcdoc may be encoded during filtering, permitting the attribute allows the browser to decode and process the resulting iframe document as HTML. This represents CWE-79: Improper Neutralization of Input During Web Page Generation, because attacker-controlled content is stored and later interpreted as executable browser markup.
Potential impact
- A malicious user may execute JavaScript in another user's browser session
- An attacker could steal session information where browser protections permit it
- Unauthorized administrative actions could be performed
- User or administrator accounts could be compromised
- Privileges could be escalated through actions available to the affected viewer
- Sensitive administrative or application data could be disclosed
General mitigation guidance
Mitigation focuses on removing browser-executable content from stored rich-text input and reducing trust in user-supplied markup.
Common defensive patterns include:
- Disallowing iframe
srcdocattributes in all Editor content before storage and rendering - Applying a context-aware, allowlist-based HTML sanitizer
- Using safe-by-default rich-text components that do not permit executable embedded documents
- Performing sanitization both at input boundaries and immediately before rendering
- Enforcing restrictive Content Security Policy controls as defense in depth
- Limiting Editor permissions according to least privilege
- Escaping output appropriately for its rendering context rather than relying solely on input filtering
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis and dependency review for permissive HTML sanitizer configurations
- Code review checks for allowed iframe attributes, especially
srcdoc - Tests that submit encoded and nested markup and verify that no executable document is stored or rendered
- Repository and database scans for existing iframe
srcdocattributes in Editor content - Content policies that reject disallowed embedded-document attributes at ingestion and rendering boundaries
- Dynamic application testing that verifies stored rich-text content cannot execute script in another user's session

