Open Bug 1613879 Opened 6 years ago Updated 3 years ago

AddressSanitizer: heap-use-after-free [@ GetConsoleService] in fuzzer harness

Categories

(Core :: Fuzzing, defect, P5)

x86_64
Linux
defect

Tracking

()

Tracking Status
firefox74 --- affected

People

(Reporter: decoder, Assigned: decoder)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Running the ContentParentIPC target locally, I found out two things first

  1. I had to fix some easy null checks that caused immediate crashes (note that this can cause some line numbers in the backtrace to be slightly off).

  2. I had to limit the allocation size in the JS engine to a reasonable value, because the fuzzer was creating GB large TypedArrays through StructuredClone deserialization.

Once I did this, I hit the use-after-free attached, which seems to involve an OOM condition (caused by MOZ_FUZZ_LARGE_ALLOC_LIMIT in the fuzzing case).

This looks dangerous to me because a compromised child could easily provoke such an OOM by using really large TypedArrays, leading to a sandbox escape.

So far, I was not able to reproduce the issue reliably with a testcase, but I will continue to work on it and also try it without my fixes on Monday. In the meantime, maybe the uaf trace is already enough to confirm that this is a legit issue and to find the right fix.

I think this is being caused by the ContentParentIPC test runner, not by a bug in the protocol. The issue here appears to be that the ContentParent actor itself was freed by the cycle-collector. The code in https://searchfox.org/mozilla-central/rev/623de665034eee43a54ff02939b61385ffd5990d/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp#19-30 allocates a ContentParent, and doesn't ever call AddRef on it.

I'm guessing that, because there are no non-cc-ed strong references, the cycle-collector (which is run due to the memory pressure warning) cleans up the dangling object, thus causing the apparent UAF.

You will want to make the references used in content_parent_ipc_libfuzz.cpp and ProtocolFuzzer.cpp hold a RefPtr to keep the actor alive while tests are running.

Flags: needinfo?(choller)
Group: core-security → dom-core-security

(In reply to :Nika Layzell (ni? for response) from comment #1)

I think this is being caused by the ContentParentIPC test runner, not by a bug in the protocol. The issue here appears to be that the ContentParent actor itself was freed by the cycle-collector. The code in https://searchfox.org/mozilla-central/rev/623de665034eee43a54ff02939b61385ffd5990d/dom/ipc/fuzztest/content_parent_ipc_libfuzz.cpp#19-30 allocates a ContentParent, and doesn't ever call AddRef on it.

I'm guessing that, because there are no non-cc-ed strong references, the cycle-collector (which is run due to the memory pressure warning) cleans up the dangling object, thus causing the apparent UAF.

You will want to make the references used in content_parent_ipc_libfuzz.cpp and ProtocolFuzzer.cpp hold a RefPtr to keep the actor alive while tests are running.

Confirmed, holding a RefPtr fixes the problem for me. I'll post a patch soon. And we can unhide this bug.

Flags: needinfo?(choller)
Group: dom-core-security
Summary: AddressSanitizer: heap-use-after-free [@ GetConsoleService] → AddressSanitizer: heap-use-after-free [@ GetConsoleService] in fuzzer harness

(In reply to Christian Holler (:decoder) from comment #2)

Confirmed, holding a RefPtr fixes the problem for me. I'll post a patch soon. And we can unhide this bug.

Assigning to decoder. This is a bug in the fuzzer.

Component: DOM: Content Processes → Platform Fuzzing Team

The priority flag is not set for this bug.
:Sylvestre, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(sledru)
Priority: -- → P5
Flags: needinfo?(sledru)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: