-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat: Use sandboxed pages for Snaps execution in MV3 #25171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Builds ready [2b67003]
Page Load Metrics (55 ± 17 ms)
Bundle size diffs
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #25171 +/- ##
========================================
Coverage 65.64% 65.64%
========================================
Files 1367 1367
Lines 54257 54257
Branches 14189 14189
========================================
Hits 35616 35616
Misses 18641 18641 ☔ View full report in Codecov by Sentry. |
app/manifest/v3/chrome.json
Outdated
@@ -1,6 +1,7 @@ | |||
{ | |||
"content_security_policy": { | |||
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';" | |||
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';", | |||
"sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'none';" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intended to be stricter than the default policy: https://developer.chrome.com/docs/extensions/reference/manifest/content-security-policy#default_policy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could experiment with adding default-src 'none'
to these, but I think that could potentially block fetch. Maybe other things. But it'd also block some exfiltration techniques like image URLs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add default-src 'none'
, we would need something for connect-src *
to allow for fetch at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Builds ready [b0ad7b6]
Page Load Metrics (52 ± 5 ms)
Bundle size diffs
|
Looks great. |
98f0439
to
9c51502
Compare
Builds ready [89efe5d]
Page Load Metrics (53 ± 5 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, as long as the current state of the content_security_policy
changes are approved by @naugtur
@@ -1,6 +1,7 @@ | |||
{ | |||
"content_security_policy": { | |||
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';" | |||
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';", | |||
"sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'none'; default-src 'none'; connect-src *;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the default-src!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
Description
Moves the execution of Snaps to a sandboxed page referencing a local HTML file inside the offscreen document when using the MV3 build. This effectively gives us access to
eval
without hitting the network and should reduce the overhead when booting a Snap (+ allow for Snaps to execute when the user is offline).To support this, this PR introduces some new changes to the manifest as well as the build process. For the build process we simply copy the same iframe bundle currently used in the hosted version to
/dist/chrome/snaps
. For the manifest, we add a reference to the sandboxed page and tweak the CSP of the sandbox to be as restrictive as possible (the default is not very strict). Then we can simply point the existing offscreen executor to use the local iframe instead of the remote one.Closes #25250