Filter eventDispatcher messages from content process
Categories
(GeckoView :: General, defect, P2)
Tracking
(firefox145 wontfix, firefox146 wontfix, firefox147 wontfix, firefox148+ fixed)
People
(Reporter: agi, Assigned: owlish)
References
Details
(Keywords: csectype-sandbox-escape, sec-high, Whiteboard: [sandboxing] [group7][adv-main148+r])
Attachments
(1 file)
|
48 bytes,
text/x-phabricator-request
|
tjr
:
sec-approval+
|
Details | Review |
Currently, we don't check whether eventDispatcher messages originate in the content process or in the main process.
This is potentially a security problem, as it weakens the content process sandbox and it increases the security envelope allowing the content process to exploit a bug in any messages that the parent process listens to.
We should limit what messages we allow the content process to send to the minimum and discard any unexpected message.
While here, we could also limit to top-level frames when appropriate.
See also Bug 1610969.
| Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 1•4 years ago
|
||
This bug is more of a sandboxing bug than a Fission bug.
Comment 2•3 years ago
|
||
Moving [sandboxing] bugs to the new GeckoView::Sandboxing component.
Updated•2 years ago
|
Comment 4•2 years ago
|
||
Without knowing exactly what's supported, this sounds like a straight up sandbox escape feature if a child content can send messages that should only have been sent from parent JS. That's not an "enhancement"; you could argue it's an unfinished feature "task" maybe
Comment 5•2 years ago
|
||
nika: mccr8 said you had more specific examples or thoughts you could add here while it's still on your mind
Comment 6•2 years ago
|
||
(In reply to Daniel Veditz [:dveditz] from comment #5)
nika: mccr8 said you had more specific examples or thoughts you could add here while it's still on your mind
There are many different messages sent over the EventDispatcher bus which could be sent by an untrusted content process, which have various powers. Fortunately most of the really scary messages (like GeckoView:WebExtension:Install) are on the global event dispatcher, which doesn't appear to have a way for content processes to send messages on them.
I think the most notable ones are messages which the browser UI uses to control the session's state, such as GeckoView:LoadUri (https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/modules/geckoview/GeckoViewNavigation.sys.mjs#171) to perform an arbitrary load on behalf of the user, with arbitrary load flags & headers, or GeckoView:RestoreState (https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/modules/geckoview/GeckoViewContent.sys.mjs#233-235), which will effectively restore the current session to an arbitrarily specified sessionstore state, including doing things like performing navigations. There may be other APIs which are more powerful than I am immediately noticing though. I believe some features like permissions flags are also passed over these APIs.
The simplest fix here would be to remvoe these messages from GeckoViewActorChild/Parent and require the callers in the content process to instead send a message to the parent actor, which then in turn dispatches the message to the EventDispatcher. A non-exhaustive search (https://searchfox.org/mozilla-central/search?q=eventDispatcher&path=Child.sys.mjs&case=false®exp=false) shows at least 8 actors which would need to be updated:
ContentDelegateChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/ContentDelegateChild.sys.mjs#26,100,141,150,156GeckoViewContentChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/GeckoViewContentChild.sys.mjs#325GeckoViewPermissionChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/GeckoViewPermissionChild.sys.mjs#17,32,65GeckoViewPrompterChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/GeckoViewPrompterChild.sys.mjs#14,22,44LoadURIDelegateChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/LoadURIDelegateChild.sys.mjs#27,32MediaControlDelegateChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/MediaControlDelegateChild.sys.mjs#37ScrollDelegateChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/ScrollDelegateChild.sys.mjs#21SelectionActionDelegateChild: https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/mobile/android/actors/SelectionActionDelegateChild.sys.mjs#272,278,434
Updated•2 years ago
|
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
Comment 7•2 years ago
|
||
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Updated•10 months ago
|
| Assignee | ||
Comment 8•10 months ago
|
||
(In reply to Nika Layzell [:nika] (ooo, ni? for response) from comment #6)
The simplest fix here would be to remvoe these messages from GeckoViewActorChild/Parent and require the callers in the content process to instead send a message to the parent actor, which then in turn dispatches the message to the EventDispatcher.
Hey Nika, looking at this briefly - looks like we actually already do this: the child actors do not have an actual EventDispatcher; when a a child actor is initialized, this.eventDispatcher field is populated by calling EventDispatcher.forActor, which returns new ChildActorDispatcher(aActor) (and the aActor is the child actor). When this.eventDispatcher.sendRequest is called on a child actor, the ChildActorDispatcher communicates with the parent actor.
It looks like we need to implement a check for the origin of the message, and potentially its type, to make sure it was sent from a trusted place. You mentioned that mccr8 has been working on implementing a message schema, I understand it is Bug 1885221. Should this bug be blocked on that work, or can we implement our own check specifically for EventDispatcher messages (because that bug is about actor messages)?
Comment 9•10 months ago
|
||
As we discussed earlier, the problem is that it is possible for a content process to send any EventDispatcher message over the pipe. My suggestion of changing the code to remove ChildActorDispatcher would do this by requiring each actor to implement the forwarding from content to parent themselves. This in turn would mean that the content process could no longer dispatch arbitrary events onto the EventDispatcher bus, as the specific events would be dispatched by the parent process with hard-coded types.
| Assignee | ||
Comment 10•10 months ago
|
||
Updated•9 months ago
|
| Assignee | ||
Comment 11•6 months ago
|
||
Comment on attachment 9506783 [details]
(secure)
Security Approval Request
- How easily could an exploit be constructed based on the patch?:
- Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: Yes
- Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?:
- If not all supported branches, which bug introduced the flaw?: None
- Do you have backports for the affected branches?: Yes
- If not, how different, hard to create, and risky will they be?:
- How likely is this patch to cause regressions; how much testing does it need?:
- Is the patch ready to land after security approval is given?: Yes
- Is Android affected?: Yes
| Assignee | ||
Comment 12•6 months ago
•
|
||
Comment on attachment 9506783 [details]
(secure)
How easily can the security issue be deduced from the patch?
- I think fairly easily, if one is familiar with the messaging security
Do comments in the patch, the check-in comment, or tests included in
the patch paint a bulls-eye on the security problem?
- I tried to be as vague as possible
Which older supported branches are affected by this flaw?
- Not sure how to answer
If not all supported branches, which bug introduced the flaw?
- The flaw was present from the start of GeckoView library
Do you have backports for the affected branches? If not, how
different, hard to create, and risky will they be?
- Not sure how to answer
How likely is this patch to cause regressions; how much testing does
it need?
- This is a risky change as far as potential regressions go.
Updated•6 months ago
|
Comment 13•6 months ago
|
||
Comment on attachment 9506783 [details]
(secure)
Approved to land. It sounds like there is not a known exploitation vector, and with the high risk of regressions, we probably want this to ride trains?
Updated•6 months ago
|
Comment 14•6 months ago
|
||
Comment 15•6 months ago
|
||
Comment 16•6 months ago
|
||
Backed out for causing lint failures
TEST-UNEXPECTED-ERROR | /builds/worker/checkouts/gecko/mobile/shared/actors/GeckoViewPrompterParent.sys.mjs:130:9 | Unreachable code. (no-unreachable)
Comment 17•6 months ago
|
||
Comment 18•6 months ago
|
||
Comment 19•6 months ago
|
||
Backed out for causing lint failure on SelectionActionDelegateParent.sys.mjs
Comment 20•6 months ago
|
||
Comment 21•6 months ago
|
||
Comment 22•5 months ago
|
||
Is this wontfix for 147?
Updated•5 months ago
|
Updated•4 months ago
|
Updated•3 months ago
|
Updated•14 days ago
|
Description
•