-
Notifications
You must be signed in to change notification settings - Fork 564
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
Implement custom security for Events #1132
Comments
I spent around an hour trying to invoke any type of an event just to see if it actually leaks DOM/real global object inside a snap sandboxed iframe and was simply not able to, so this vector of attack seems to be rather safe IMO. Nevertheless, it is recommended that when creating the sandbox, to limit the events from leaking sensitive objects "just in case". This can be done by overriding own properties of prototypes of all existing events. I mapped out all the different prototypes that inherit from The result is: (function(global){
const map = {
"UIEvent": [
"view"
],
"MutationEvent": [
"relatedNode"
],
"MessageEvent": [
"source"
],
"FocusEvent": [
"relatedTarget"
],
"MouseEvent": [
"relatedTarget",
"fromElement",
"toElement"
],
"TouchEvent": [
"targetTouches",
"touches"
],
"Event": [
"target",
"currentTarget",
"srcElement",
"composedPath"
]
};
for (const event in map) {
const props = map[event];
for (const prop of props) {
Object.defineProperty(global[event].prototype, prop, {
value: undefined, configurable: false, writable: false,
});
}
}
}(globalThis)); I wish this could have been done automatically at runtime, but that's difficult because:
This code should be integrated into snaps arch, to where snaps creates the iframe, by calling it with the instance of the window proxy object of the sandboxed iframe right after is attached to DOM. I of course am open to better suggestions on this 🙏 (also the descriptor in the example can be anything else -
|
Initial proposal for wrapper implementation:
During the hardening endowments work it is discovered that
AbortController
andAbortSignal
endowments are exposing more functionalities that might be a security concern. Particularly the major concern was the exposure of the Event-related API.This ticket needs to focus on making
Events
secure, thenAbortSignal
andAbortController
will not be exposing security risks anymore.Acceptance criteria is taken from Gal's comment below: #1132 (comment)
The text was updated successfully, but these errors were encountered: