Skip to content

[Bug]: DOM reconstruction may execute unintended scripts #1817

Closed

Description

@rotemreiss

Preflight Checklist

  • I have searched the issue tracker for a bug report that matches the one I want to file, without success.

What package is this bug report for?

rrweb-snapshot

Version

1.0.0, <= 2.0.0-alpha.18

Expected Behavior

Description

The rebuild method in rrweb-snapshot does not sufficiently sanitize snapshot data before reconstructing the DOM. This means that crafted content within a recorded session can cause unintended script execution when the session is replayed.

Affected Versions

rrweb-snapshot >= 1.0.0, <= 2.0.0-alpha.18 — no fixed version is available at the time of writing.

Suggested Fix

Rendering the reconstructed DOM inside a sandboxed iframe (using the sandbox attribute) isolates the replayed content and prevents unintended scripts from running in the parent document's context.

If you are using rrweb in your application, please ensure session replays are rendered inside a properly sandboxed iframe until an official fix is released.

Additional Context

I discovered this behavior approximately a year ago and reached out to the maintainers multiple times. The communication was acknowledged, but no fix has been provided or published as of today.

I also identified this issue in several real-world services that use rrweb for session replay. Their security teams were notified and have successfully remediated it by adjusting how they integrate rrweb in their applications.

A proof-of-concept is not being shared at this time to give the maintainers an opportunity to release a proper fix.


A CVE ID has been assigned for this issue (CVE-2025-45806) and is pending publication.

Actual Behavior

N/A

Steps to Reproduce

N/A

Testcase Gist URL

No response

Additional Information

No response

Activity

  1. added
    bug
    on Apr 8, 2026
  2. eoghanmurray commented on May 16, 2026

    @eoghanmurray
    Collaborator

    I haven't seen the details of this vulnerability yet, but have requested that Justin share it with me.

    real-world services that use rrweb for session replay

    If they are using the rrweb package and not the rrweb-snapshot package alone in some custom configuration (rrweb-snapshot on it's own doesn't give you 'replay'), then I believe this is a non-issue, as rrweb/replay has always used the sandbox attribute:
    https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb/src/replay/index.ts#L620

    Rendering the reconstructed DOM inside a protected iframe is the intended and primary way of rebuilding. While rrweb-snapshot does not record/rebuild JavaScript scripts, the intention was never to use scrubbing/sanitizing in order to protect against malicious scripts, as there is such a large surface area for injection of XSS, and getting involved in such an arms race is brittle. The sandbox attribute is the better solution.
    The sandbox.md doc covers some of this.

    I believe the above reasons are why it might seem like nothing has been done, but again I'll take a proper at the details you privately shared previously.

  3. rotemreiss commented on May 16, 2026

    @rotemreiss
    ContributorAuthor

    I haven't seen the details of this vulnerability yet, but have requested that Justin share it with me.

    real-world services that use rrweb for session replay

    If they are using the rrweb package and not the rrweb-snapshot package alone in some custom configuration (rrweb-snapshot on it's own doesn't give you 'replay'), then I believe this is a non-issue, as rrweb/replay has always used the sandbox attribute: https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb/src/replay/index.ts#L620

    Rendering the reconstructed DOM inside a protected iframe is the intended and primary way of rebuilding. While rrweb-snapshot does not record/rebuild JavaScript scripts, the intention was never to use scrubbing/sanitizing in order to protect against malicious scripts, as there is such a large surface area for injection of XSS, and getting involved in such an arms race is brittle. The sandbox attribute is the better solution. The sandbox.md doc covers some of this.

    I believe the above reasons are why it might seem like nothing has been done, but again I'll take a proper at the details you privately shared previously.

    @eoghanmurray - this has been reported after seeing it in the wild in multiple applications (reported to them separately). IMO the snapshot rebuild functionality must rebuild the DOM in a sandboxed iframe to follow the secure by default security principle and prevent the XSS.

  4. Juice10 commented on May 18, 2026

    @Juice10
    Member

    @eoghanmurray - this has been reported after seeing it in the wild in multiple applications (reported to them separately). IMO the snapshot rebuild functionality must rebuild the DOM in a sandboxed iframe to follow the secure by default security principle and prevent the XSS.

    @rotemreiss to prevent this exploit from being possible, would it be sufficient for the rebuild param to check if content is rendered in a sandboxed iframe?

    I agree with Eoghan, that scrubbing/sanitizing has such big surface area that it isn't doable.
    And documenting that rebuild alone can be used as a foot cannon probably isn't enough.

  5. Juice10 commented on Sep 8, 2026

    @Juice10
    Member

    Fixed by #1834
    Thanks for submitting this @rotemreiss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions