Fix Privacy Side-Channel in Device Posture API via Background Tabs [chromium/src : main]

0 views
Skip to first unread message

Alvin Ji (Gerrit)

unread,
Jun 16, 2026, 7:17:57 PM (14 days ago) Jun 16
to Matt Reynolds, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Matt Reynolds

Alvin Ji added 1 comment

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Alvin Ji . resolved

Hi Matt,
PTAL and thanks!
Alvin

Open in Gerrit

Related details

Attention is currently required from:
  • Matt Reynolds
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ie5c757727cf7787c9968c816e1ff2eb50679a08c
Gerrit-Change-Number: 7927408
Gerrit-PatchSet: 7
Gerrit-Owner: Alvin Ji <alv...@chromium.org>
Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
Gerrit-Attention: Matt Reynolds <mattre...@chromium.org>
Gerrit-Comment-Date: Tue, 16 Jun 2026 23:17:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Matt Reynolds (Gerrit)

unread,
Jun 17, 2026, 7:34:21 PM (13 days ago) Jun 17
to Alvin Ji, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Alvin Ji

Matt Reynolds added 2 comments

File content/browser/device_posture/device_posture_provider_impl_unittest.cc
Line 23, Patchset 7 (Latest):class FakeDevicePostureClient : public blink::mojom::DevicePostureClient {
Matt Reynolds . unresolved

Let's make this a mock instead of a test fake so we can mock OnPostureChanged in tests.

Line 91, Patchset 7 (Latest): EXPECT_TRUE(base::test::RunUntil([&]() {
return client.last_posture() == blink::mojom::DevicePostureType::kFolded;
}));
Matt Reynolds . unresolved

We shouldn't need to use RunUntil to poll here since the client (which we faked) is notified when the posture changed. Instead of keeping internal state in the test fake and polling for that state, it would be better to register a callback with the fake that gets called with the current posture whenever OnPostureChanged is called. That's basically just a mock so I recommend switching the test fake to a mock.

Open in Gerrit

Related details

Attention is currently required from:
  • Alvin Ji
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie5c757727cf7787c9968c816e1ff2eb50679a08c
    Gerrit-Change-Number: 7927408
    Gerrit-PatchSet: 7
    Gerrit-Owner: Alvin Ji <alv...@chromium.org>
    Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
    Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
    Gerrit-Attention: Alvin Ji <alv...@chromium.org>
    Gerrit-Comment-Date: Wed, 17 Jun 2026 23:34:04 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Alvin Ji (Gerrit)

    unread,
    Jun 22, 2026, 4:21:53 PM (8 days ago) Jun 22
    to Matt Reynolds, Chromium LUCI CQ, chromium...@chromium.org
    Attention needed from Matt Reynolds

    Alvin Ji added 2 comments

    File content/browser/device_posture/device_posture_provider_impl_unittest.cc
    Line 23, Patchset 7:class FakeDevicePostureClient : public blink::mojom::DevicePostureClient {
    Matt Reynolds . resolved

    Let's make this a mock instead of a test fake so we can mock OnPostureChanged in tests.

    Alvin Ji

    Done

    Line 91, Patchset 7: EXPECT_TRUE(base::test::RunUntil([&]() {

    return client.last_posture() == blink::mojom::DevicePostureType::kFolded;
    }));
    Matt Reynolds . resolved

    We shouldn't need to use RunUntil to poll here since the client (which we faked) is notified when the posture changed. Instead of keeping internal state in the test fake and polling for that state, it would be better to register a callback with the fake that gets called with the current posture whenever OnPostureChanged is called. That's basically just a mock so I recommend switching the test fake to a mock.

    Alvin Ji

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Matt Reynolds
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie5c757727cf7787c9968c816e1ff2eb50679a08c
      Gerrit-Change-Number: 7927408
      Gerrit-PatchSet: 10
      Gerrit-Owner: Alvin Ji <alv...@chromium.org>
      Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
      Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
      Gerrit-Attention: Matt Reynolds <mattre...@chromium.org>
      Gerrit-Comment-Date: Mon, 22 Jun 2026 20:21:38 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Matt Reynolds <mattre...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Matt Reynolds (Gerrit)

      unread,
      Jun 24, 2026, 9:38:08 PM (6 days ago) Jun 24
      to Alvin Ji, Code Review Nudger, Chromium LUCI CQ, chromium...@chromium.org
      Attention needed from Alvin Ji

      Matt Reynolds added 4 comments

      File content/browser/device_posture/device_posture_provider_impl.cc
      Line 54, Patchset 10 (Latest): (is_posture_emulated_ && emulated_posture_)
      ? *emulated_posture_
      : platform_provider_->GetDevicePosture();
      Matt Reynolds . unresolved

      This logic is duplicated below in `OnVisibilityChanged`, please factor it out into a helper function.

      Line 124, Patchset 10 (Latest): if (visibility == Visibility::HIDDEN) {
      Matt Reynolds . unresolved

      `visibility` can have three states: VISIBLE, HIDDEN, or OCCLUDED. Here we're treating OCCLUDED the same as VISIBLE, which seems unintended. If the tab is covered by other windows, should it be counted as visible? Is there any reason an occluded tab would need to know the device posture?

      Line 133, Patchset 10 (Latest): : platform_provider_->GetDevicePosture();
      Matt Reynolds . unresolved

      Before calling platform_provider_->GetDevicePosture(), check if there are any posture_clients_. If there are no clients we can skip checking the posture.

      File content/browser/device_posture/device_posture_provider_impl_unittest.cc
      Line 68, Patchset 10 (Latest): test_web_contents()->WasShown();
      Matt Reynolds . unresolved

      Please add a test with `WasOccluded`

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Alvin Ji
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ie5c757727cf7787c9968c816e1ff2eb50679a08c
        Gerrit-Change-Number: 7927408
        Gerrit-PatchSet: 10
        Gerrit-Owner: Alvin Ji <alv...@chromium.org>
        Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
        Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
        Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
        Gerrit-Attention: Alvin Ji <alv...@chromium.org>
        Gerrit-Comment-Date: Thu, 25 Jun 2026 01:37:53 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Alvin Ji (Gerrit)

        unread,
        Jun 26, 2026, 2:20:25 PM (4 days ago) Jun 26
        to Code Review Nudger, Matt Reynolds, Chromium LUCI CQ, chromium...@chromium.org
        Attention needed from Matt Reynolds

        Alvin Ji voted and added 4 comments

        Votes added by Alvin Ji

        Commit-Queue+1

        4 comments

        File content/browser/device_posture/device_posture_provider_impl.cc
        Line 54, Patchset 10: (is_posture_emulated_ && emulated_posture_)
        ? *emulated_posture_
        : platform_provider_->GetDevicePosture();
        Matt Reynolds . resolved

        This logic is duplicated below in `OnVisibilityChanged`, please factor it out into a helper function.

        Alvin Ji

        I added `GetCurrentPosture` to reuse the code here. Thanks!

        Line 124, Patchset 10: if (visibility == Visibility::HIDDEN) {
        Matt Reynolds . resolved

        `visibility` can have three states: VISIBLE, HIDDEN, or OCCLUDED. Here we're treating OCCLUDED the same as VISIBLE, which seems unintended. If the tab is covered by other windows, should it be counted as visible? Is there any reason an occluded tab would need to know the device posture?

        Alvin Ji

        Thanks for pointing this out. I think we should treat OCCLUDED as HIDDEN and only passing update when page is VISIBLE. I updated the visibility check now only allow the update in VISIBLE case.

        Line 133, Patchset 10: : platform_provider_->GetDevicePosture();
        Matt Reynolds . resolved

        Before calling platform_provider_->GetDevicePosture(), check if there are any posture_clients_. If there are no clients we can skip checking the posture.

        Alvin Ji

        Done

        File content/browser/device_posture/device_posture_provider_impl_unittest.cc
        Line 68, Patchset 10: test_web_contents()->WasShown();
        Matt Reynolds . resolved

        Please add a test with `WasOccluded`

        Alvin Ji

        `DeferUpdatesWhileOccluded` is added.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Matt Reynolds
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ie5c757727cf7787c9968c816e1ff2eb50679a08c
          Gerrit-Change-Number: 7927408
          Gerrit-PatchSet: 13
          Gerrit-Owner: Alvin Ji <alv...@chromium.org>
          Gerrit-Reviewer: Alvin Ji <alv...@chromium.org>
          Gerrit-Reviewer: Matt Reynolds <mattre...@chromium.org>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          Gerrit-Attention: Matt Reynolds <mattre...@chromium.org>
          Gerrit-Comment-Date: Fri, 26 Jun 2026 18:20:12 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: Yes
          Comment-In-Reply-To: Matt Reynolds <mattre...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages