Review which options would work the best when creating a sandbox for script evaluation
Categories
(Remote Protocol :: WebDriver BiDi, task, P3)
Tracking
(Not tracked)
People
(Reporter: Sasha, Unassigned)
Details
(Whiteboard: [webdriver:backlog])
Follow up from https://phabricator.services.mozilla.com/D153440#inline-848836
The sandbox documentation (https://udn.realityripple.com/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.Sandbox) contain following information about sandboxPrototype property:
"Passing a content window object, setting wantXrays:true (default) and using an extended principal provides a clean, isolated execution environment in which javascript code that needs Web APIs (such as accessing the window's DOM) can be executed without interference from untrusted content code."
Which could mean that instead of Cu.Sandbox(win, opts), we could use Cu.Sandbox(extendedPrincipal, opts), where extendedPrincipal is supposed to simply be an array of principals. There's more information about principals at https://udn.realityripple.com/docs/Mozilla/Gecko/Script_security#Security_checks.
We could also review here which options(opts), which we use in Cu.Sandbox(win, opts), would work the best for the script evaluation use case.
| Reporter | ||
Updated•4 years ago
|
Comment 1•4 years ago
|
||
See also: Bug 1491490 - Kill wantXrays
| Reporter | ||
Comment 2•4 years ago
|
||
Might also make sense to review sandbox creation in Marionette
Comment 3•4 years ago
|
||
We landed some documentation for sandbox options in the meantime: https://searchfox.org/mozilla-central/rev/9cd1e8cabf67ef5a47e95d70b7f40c9d3ad02ad0/js/xpconnect/idl/xpccomponents.idl#127-244
Re: wantXRays:
- wantXrays: {Boolean} Whether the sandbox wants Xray vision with
respect to same-origin objects outside the sandbox.
Note that wantXrays is essentially deprecated. The preferred method
of handling this now is to give the sandbox an expanded principal
which inherits from the principal of the content compartment the
sandbox will interact with. That lets the sandbox see the content
compartment through X-ray wrappers, and gives any object passed from
the sandbox to the content compartment opaque security wrappers unless
export helpers are explicitly used.
So this option is more or less deprecated and we should instead use the approach mentioned on Phabricator at https://phabricator.services.mozilla.com/D154260?id=612995#inline-849209
Description
•