Potential sandbox bypass in docs iframe examples
Author: Marco1567Created Jul 14, 2026Updated Jul 14, 2026
Summary
A documentation example iframe is rendered without a restrictive sandbox attribute. Because the iframe content executes script from the example source, a malicious snippet could access the parent window and modify the surrounding documentation page.
Impact
A crafted example could potentially manipulate the parent DOM, alter page content, or trigger unexpected behavior for users viewing the docs.
Steps to reproduce
- Open a documentation page that renders a code block example inside the iframe-based chart component.
- Include a snippet that runs in the iframe context, for example:
window.parent.document.body.innerHTML = "<h1>pwned</h1>"; - Observe that the parent page can be modified.
Proposed mitigation
Add a sandbox attribute to the iframe, for example:
<iframe
srcDoc={srcDoc}
sandbox="allow-scripts"
/>Notes
I also added a regression test to ensure the sandbox attribute remains present.
Source: tradingview/lightweight-charts