Skip to content

Commit 842fb88

Browse files
committed
[M74][Extensions] Gracefully handle unknown ids in ExtensionHost::OnEventAck
ExtensionHost::OnEventAck receives a message from a renderer that it received and dispatched an event to the extension. Currently, we kill the renderer (for sending a bad message) if it sends an event ID that wasn't recorded. However, it seems there are some cases in which this can happen even if the renderer isn't compromised or corrupted; some hypotheses for these are described in the linked bug. For now, since we are seeing evidence of this happening when the renderer shouldn't be killed, relax the kill to instead be a graceful early-out. Keep the other bad message kill for sending from a non-background page, since that should still never happen. TBR=rdevlin.cronin@chromium.org (cherry picked from commit a81c4ea4d763da0f99bb0762fe5b6e6191feea45) Bug: 939279 Change-Id: I93cb34a1a67c1a3575c5fda0b5c90b9d4f9da6f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1509363 Commit-Queue: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#638885} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1518464 Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/branch-heads/3729@{#49} Cr-Branched-From: d4a8972-refs/heads/master@{#638880}
1 parent 97bfcb1 commit 842fb88

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

extensions/browser/extension_host.cc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -336,24 +336,30 @@ void ExtensionHost::OnEventAck(int event_id) {
336336
// events for other extensions have been acked. Make sure that the event id
337337
// sent by the renderer is one that this ExtensionHost expects to receive.
338338
// This way if a renderer _is_ compromised, it can really only affect itself.
339-
const auto it = unacked_messages_.find(event_id);
340-
if (!is_background_page || it == unacked_messages_.end()) {
339+
if (!is_background_page) {
341340
// Kill this renderer.
342341
DCHECK(render_process_host());
343-
if (!is_background_page) {
344-
LOG(ERROR) << "Killing renderer for extension " << extension_id()
345-
<< " for sending an EventAck without a lazy background page.";
346-
} else {
347-
// We have received an unexpected event id from the renderer. It might
348-
// be compromised or it might have some other issue.
349-
LOG(ERROR) << "Killing renderer for extension " << extension_id()
350-
<< " for sending an EventAck message with a bad event id.";
351-
}
342+
LOG(ERROR) << "Killing renderer for extension " << extension_id()
343+
<< " for sending an EventAck without a lazy background page.";
352344
bad_message::ReceivedBadMessage(render_process_host(),
353345
bad_message::EH_BAD_EVENT_ID);
354346
return;
355347
}
356348

349+
const auto it = unacked_messages_.find(event_id);
350+
if (it == unacked_messages_.end()) {
351+
// Ideally, we'd be able to kill the renderer in the case of it sending an
352+
// ack for an event that we haven't seen. However, https://crbug.com/939279
353+
// demonstrates that there are cases in which this can happen in other
354+
// situations. We should track those down and fix them, but for now
355+
// log and gracefully exit.
356+
// bad_message::ReceivedBadMessage(render_process_host(),
357+
// bad_message::EH_BAD_EVENT_ID);
358+
LOG(ERROR) << "Received EventAck for extension " << extension_id()
359+
<< " for an unknown event.";
360+
return;
361+
}
362+
357363
EventRouter* router = EventRouter::Get(browser_context_);
358364
if (router)
359365
router->OnEventAck(browser_context_, extension_id(), it->second);

0 commit comments

Comments
 (0)