Security·Intermediate·Conceptual·1 min read
How does loading a third-party widget in a sandboxed iframe reduce risk?
Short interview answer
The iframe runs in a separate browsing context, so its script can't read the host page's DOM, cookies, or localStorage, and the sandbox attribute can further restrict what it may do. A compromise of the widget is contained to the iframe instead of the whole origin.
Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.