diff --git a/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart b/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart index ab96f867ec0..9d281858d9d 100644 --- a/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart +++ b/packages/devtools_app/lib/src/extensions/embedded/_controller_web.dart @@ -59,6 +59,16 @@ String _debugExtensionPlaceholderHtml(String name) { '''; } +/// The sandbox permissions granted to embedded extension iframes. +/// +/// Configures the iframe sandbox to allow: +/// - Script execution (`allow-scripts`) +/// - Origin-based features like local storage and service workers (`allow-same-origin`) +/// - Form submissions and downloads (`allow-forms`, `allow-downloads`) +/// - Unrestricted popup windows and links (`allow-popups`, `allow-popups-to-escape-sandbox`) +const _extensionSandboxRules = + 'allow-scripts allow-same-origin allow-forms allow-downloads allow-popups allow-popups-to-escape-sandbox'; + class EmbeddedExtensionControllerImpl extends EmbeddedExtensionController with AutoDisposeControllerMixin { EmbeddedExtensionControllerImpl(super.extensionConfig); @@ -123,7 +133,8 @@ class EmbeddedExtensionControllerImpl extends EmbeddedExtensionController // This url is safe because we built it ourselves and it does not include // any user input. ..src = extensionUrl - ..allow = 'usb'; + ..allow = 'usb' + ..sandbox.value = _extensionSandboxRules; _extensionIFrame.style ..border = 'none' ..height = '100%' diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md index 0d7aeb830ce..21e70e2bbcc 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md @@ -79,6 +79,8 @@ TODO: Remove this section if there are not any updates. * Hide the DevTools extensions menu button in single-screen embedded mode (`EmbedMode.embedOne`) on standard screens. [#8507](https://github.com/flutter/devtools/issues/8507) +* Added iframe sandboxing for embedded DevTools extensions to enforce origin + isolation. [#9967](https://github.com/flutter/devtools/pull/9967) ## Advanced developer mode updates