Closed Bug 1758155 Opened 4 years ago Closed 2 years ago

PBackground-managed Actors can be opened for the wrong process

Categories

(Core :: Networking, task, P2)

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox-esr115 - wontfix
firefox117 --- wontfix
firefox118 - wontfix
firefox119 + fixed

People

(Reporter: nika, Assigned: kershaw)

References

Details

(Keywords: csectype-sandbox-escape, sec-want, Whiteboard: [necko-triaged][necko-priority-queue][adv-main119-])

Attachments

(6 files, 3 obsolete files)

Since bug 1503834 and bug 1603420, we've been creating the PBackground actor between not just a content and parent process, but also between content & socket or socket & parent processes. For each of these different connections, a different subset of the managed actors and messages on PBackground are actually supported, and the others should never be used.

Unfortunately, there appear to be no checks in the individual Recv and Alloc methods on BackgroundParentImpl confirming that the source process is as expected (https://searchfox.org/mozilla-central/rev/7f1db1d2c556b82114b62f5aa4aa29397ad5bce4/ipc/glue/BackgroundParentImpl.cpp), and producing an error if it is not. This could theoretically allow a compromised content process to open actors which normally are only supposed to be connected between a different process pair to the parent or socket processes.

Methods should be added to help check that the process connection is of each of the relevant types, and checks should probably be added to every method in BackgroundParentImpl to prevent opening an actor in the wrong process when sent an invalid message, in order to reduce the potential untested attack surface.

Alternatively, we could switch away from using PBackground with the socket process, and use a different toplevel actor, giving us static guarantees about which methods are actually available between each process pair.

Group: core-security → dom-core-security

Since the stuff from Friday relating to access to webgpu this scares me... more... than it might otherwise have done. Is that reasonable or am I just being overly paranoid? If it's not just me, I guess let's find out how hard it would be to do something here?

Flags: needinfo?(continuation)

Is that reasonable or am I just being overly paranoid?

I think the timing of this bug being filed is not a coincidence ;-)

Oops, I thought I was posting in another bug. Yes, this came out of me mentioning the WebGPU issue to Nika.

(In reply to :Gijs (he/him) from comment #5)

(In reply to Andrew McCreight [:mccr8] from comment #3)

Unfortunately it does feel like it could be a big project, unless we can somehow reuse Chrome's work. I'm not sure we can afford to do this, but I'm not sure we can afford to not do this.

Can you elaborate a little on this? I'm not terribly familiar with our ipdl stuff - but I would have hoped that we could enforce having certain annotations on the interfaces that describe what process the parent/child is meant to run in, and then enforce those when the actors get instantiated. Does it not work that way? comment #0 mentions having to add checks in every method; is checking on instantiation not sufficient / possible?

mccr8's comment was for a different bug (Bug 1758522).

My general understanding of IPC is that top-level actors (i.e. ones without a manages line) should not be able to be created for a process they should not exist in. i.e. a Parent <-> GPU Actor can't be created by a Content Process between either Content <-> GPU or Content <-> Parent. I haven't seen an example of this being bypassed but I never understood the mechanism that prevented it. (This is what Nika meant by static guarantees I believe.)

However if an actor is a child actor, and its manager actor exists, then the process can request the child actor be created (unless there is an explicit process check that prevents it, but that's prone to omission.) That's the focus of this bug; that PBackground is being used for different types of process connections (e.g. Content <-> Parent, Content <-> Socket). Only some of the methods (and child actors) should be used for each of those types.

While annotations could help here; it really feels like the answer is separating Top-Level Actors by process type.

It might also be necessary to allow child actors to have two managers, so that messages in common for Parent <-> Socket and Content <-> Socket will live once, on a single child actor, managed by separate top-level actors for each type of process.

What :tjr said is roughly correct. We do have strong guarantees about what processes toplevel actors etc. can be created in, and that propagates out to everything which uses them. The problem here is specifically that when the socket process was introduced, rather than introducing a new toplevel actor for the socket process' connections, the PBackground protocol was re-used for the new actors. This probably simplified implementation, especially at the time when implementing new toplevel protocols was quite painful, but meant that we didn't get the structural checks preventing this kind of mistake for these new process types.

I think the best approach here would be to split the PBackground actor into different actors. PBackground would stay for {content,parent} -> parent connections, and a new actor would need to be added for content -> socket connections and socket -> parent connections.

If we can't do that, we should probably at least go through all implemented methods on PBackground and add a check for the type of PBackground actor they're acting on to perform the relevant check dynamically.

Flags: needinfo?(nika)

Calling this "sec-moderate" because we don't know of specific badness, but the pattern is bad and could well escalate to a sec-high or sec-critical if we do find a specific abusable instance.

Keywords: sec-moderate

The severity field is not set for this bug.
:jld, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jld)
Severity: -- → S3
Flags: needinfo?(jld)

(In reply to Nika Layzell [:nika] (ni? for response) from comment #7)

I think the best approach here would be to split the PBackground actor into different actors. PBackground would stay for {content,parent} -> parent connections, and a new actor would need to be added for content -> socket connections and socket -> parent connections.

I think that is reasonable. Thank you for bringing this up.

Component: IPC → Networking
Priority: -- → P2
Whiteboard: [necko-triaged][necko-priority-queue]
Assignee: nobody → kershaw
Group: dom-core-security → network-core-security

Depends on D167228

Attachment #9312981 - Attachment is obsolete: true
Attachment #9312982 - Attachment description: Bug 1758155 - P2: Introduce PSocketBackground and PSocketBackgroundStarter, r=nika → Bug 1758155 - Introduce PSocketBackground and PSocketBackgroundStarter, r=nika
Attachment #9312984 - Attachment description: Bug 1758155 - P3: Move actors to PSocketBackground, r=nika → Bug 1758155 - Move actors to PSocketBackground, r=nika
Attachment #9312984 - Attachment is obsolete: true
Attachment #9312982 - Attachment is obsolete: true
Attachment #9342734 - Attachment description: Bug 1758155 - Use background task queue for PSocketProcessBridge, r=nika → Bug 1758155 - Make PMediaTransport and PBackgroundDataBridge toplevel actors, r=nika

Depends on D185031

Pushed by kjang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7b628b437e19 Make PMediaTransport and PBackgroundDataBridge toplevel actors, r=nika,necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/4bc26c75c26a Remove some PSM actos from PBackground, r=keeler,nika,necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/230add1b5bb5 Make PWebSocketConnection a toplevel actor, r=necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/bec8e6762e2a PBackground clenup, r=nika
Regressions: 1848972

Backed out for causing build bustages in NetworkConnectivityService.cpp:

https://hg.mozilla.org/integration/autoland/rev/4624b75883dcdffc153eb7c168709962a46c71b7

Push with failures
Failure log

netwerk/base/NetworkConnectivityService.cpp(50,3): error: use of undeclared identifier 'ClearOnShutdown'

followed by more failure lines.

Flags: needinfo?(kershaw)

Apparently, MOZ_WEBRTC is not defined on some platforms and it looks like the IPDL parser doesn't like an empty IPDL file.
This patch adds an Dummy IPC message to make the compiler happy.

Flags: needinfo?(kershaw)
Pushed by kjang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cae68edb7ea6 Make PMediaTransport and PBackgroundDataBridge toplevel actors, r=nika,necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/629d45b0c814 Remove some PSM actos from PBackground, r=keeler,nika,necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/e8c4fe7a2819 Make PWebSocketConnection a toplevel actor, r=necko-reviewers,jesup https://hg.mozilla.org/integration/autoland/rev/247891c73bc5 PBackground clenup, r=nika https://hg.mozilla.org/integration/autoland/rev/bdcde8c620b4 Allow empty top-level IPC protocol, r=nika https://hg.mozilla.org/integration/autoland/rev/75efbbfb861e Fix mingwclang build, r=nika

FWIW, this will need rebasing for both Beta and ESR.

The patch landed in nightly and beta is affected.
:kershaw, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval. Also, don't forget to request an uplift for the patches in the regression caused by this fix.
  • If no, please set status-firefox118 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(kershaw)

No need to uplift.

Flags: needinfo?(kershaw)

We'd like to figure out some solution for ESR115 - nika suggested adding manual checks to each method on PBackground if that seems easier and less risky than rebasing.

See Also: → 1851989

(In reply to Tom Ritter [:tjr] (Back 9/5) from comment #27)

We'd like to figure out some solution for ESR115 - nika suggested adding manual checks to each method on PBackground if that seems easier and less risky than rebasing.

I filed bug 1851989 for this.
if the patches in this bug cause no regression, we could consider just uplifting them.

IIUC, ESR won't be getting the changes from this bug in favor of bug 1851989.

Type: defect → task
Keywords: sec-moderatesec-want
Whiteboard: [necko-triaged][necko-priority-queue] → [necko-triaged][necko-priority-queue][adv-main119-]
QA Whiteboard: [post-critsmash-triage]
Flags: qe-verify-

Bulk-unhiding security bugs fixed in Firefox 119-121 (Fall 2023). Use "moo-doctrine-subsidy" to filter

Group: core-security-release
Regressions: 1898040
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: