You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: DOM reconstruction may execute unintended scripts #1817
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.
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.
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.
@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.
Activity
eoghanmurray commentedon May 16, 2026
I haven't seen the details of this vulnerability yet, but have requested that Justin share it with me.
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.
rotemreiss commentedon May 16, 2026
@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.
Juice10 commentedon May 18, 2026
@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
rebuildalone can be used as a foot cannon probably isn't enough.Juice10 commentedon Sep 8, 2026
Fixed by #1834
Thanks for submitting this @rotemreiss!