Skip to content

[Medium][general-editor] XSS via RichText rendering (dangerouslySetInnerHTML/srcDoc) #229

@ashutoshkumarsingh-dev

Description

@ashutoshkumarsingh-dev

Vulnerability
RichText renders untrusted HTML using dangerouslySetInnerHTML and iframe srcDoc without sanitization.

Affected file:

  • general-editor/src/tags/object/RichText/view.js

Impact
Stored/reflected XSS in annotation content can execute arbitrary JS in another users browser (token theft, actions as victim).

Steps to Reproduce

  1. Render a value containing one of:
    <img src=x onerror=alert('XSS')>
    or
    <svg onload=alert('XSS')>
  2. The alert fires on render.

PoC
Any payload above in item._value triggers execution on render.

Expected vs Actual
Expected: HTML sanitized; no script execution.
Actual: Script executes.

Working Patch
Public gist (single-commit patch): https://gist.github.com/ashutoshkumarsingh-dev/49880549b5786b43e39e4954a59d74d5
Apply with:

�ash git am -3 < fix-general-editor-xss-sanitize.patch

Files in patch:

  • general-editor/src/tags/object/RichText/view.js: sanitize value with DOMPurify; use sanitizedVal for dangerouslySetInnerHTML and iframe srcDoc
  • general-editor/package.json: add dompurify dependency

CVSS v3.1
AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N = 6.1 (Medium)

Notes
I can submit a PR as well; I couldnt fork the public repo due to access. The patch is complete and ready to apply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions