Secure MHTML generation against TOCTOU [chromium/src : main]

1 view
Skip to first unread message

Min Qin (Gerrit)

unread,
Jun 6, 2026, 3:16:22 AM (8 days ago) Jun 6
to Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
Attention needed from Avi Drissman, Bo Liu, James Cook and Justin DeWitt

Min Qin added 1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Min Qin . resolved

PTAL

+jamescook@ for page_capture
+dewittj@ for offline_pages
+boliu@ for content/browser
+avi@ for content/public

Open in Gerrit

Related details

Attention is currently required from:
  • Avi Drissman
  • Bo Liu
  • James Cook
  • Justin DeWitt
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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
Gerrit-Change-Number: 7906598
Gerrit-PatchSet: 6
Gerrit-Owner: Min Qin <qin...@chromium.org>
Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
Gerrit-Reviewer: James Cook <jame...@chromium.org>
Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
Gerrit-Reviewer: Min Qin <qin...@chromium.org>
Gerrit-Attention: James Cook <jame...@chromium.org>
Gerrit-Attention: Justin DeWitt <dew...@chromium.org>
Gerrit-Attention: Avi Drissman <a...@chromium.org>
Gerrit-Attention: Bo Liu <bo...@chromium.org>
Gerrit-Comment-Date: Sat, 06 Jun 2026 07:15:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Bo Liu (Gerrit)

unread,
Jun 7, 2026, 9:25:48 PM (6 days ago) Jun 7
to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
Attention needed from Avi Drissman, James Cook, Justin DeWitt and Min Qin

Bo Liu added 6 comments

Commit Message
Line 9, Patchset 6 (Latest):MHTML generation previously used base::CreateTemporaryFile() which
immediately closes the created file descriptor, then open the created
file path separately. This allows attackers to tamper the file during
Bo Liu . unresolved

umm, has anyone evaluated the security concern here? two separate thoughts..

if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

File content/browser/devtools/protocol/devtools_mhtml_helper.cc
Line 41, Patchset 6 (Latest): base::BindOnce([](base::File file) {}, std::move(mhtml_file_scoped_)));
Bo Liu . unresolved

there's base::DoNothingWithBoundArgs

Line 71, Patchset 6 (Latest): ReportFailure("Unable to create temporary file");
Bo Liu . unresolved

close immediately on failure

Line 150, Patchset 6 (Latest): FILE* stream = base::FileToFILE(std::move(mhtml_file_scoped_), "rb");
Bo Liu . unresolved

use base::ScopedFILE

File content/browser/download/mhtml_generation_manager.cc
Line 355, Patchset 6 (Latest): std::ignore = DenyExecuteAccessToMHTMLFile(file_path);
Bo Liu . unresolved

CreateMHTMLFile has a long comment explaining this, this just looks random

File content/public/common/mhtml_generation_params.h
Line 29, Patchset 6 (Latest): base::File output_handle;
Bo Liu . unresolved

sounds like these two should be an std::variant?

Open in Gerrit

Related details

Attention is currently required from:
  • Avi Drissman
  • James Cook
  • Justin DeWitt
  • Min Qin
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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
    Gerrit-Change-Number: 7906598
    Gerrit-PatchSet: 6
    Gerrit-Owner: Min Qin <qin...@chromium.org>
    Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
    Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
    Gerrit-Reviewer: James Cook <jame...@chromium.org>
    Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
    Gerrit-Reviewer: Min Qin <qin...@chromium.org>
    Gerrit-Attention: James Cook <jame...@chromium.org>
    Gerrit-Attention: Justin DeWitt <dew...@chromium.org>
    Gerrit-Attention: Avi Drissman <a...@chromium.org>
    Gerrit-Attention: Min Qin <qin...@chromium.org>
    Gerrit-Comment-Date: Mon, 08 Jun 2026 01:25:34 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Avi Drissman (Gerrit)

    unread,
    Jun 8, 2026, 10:22:53 AM (6 days ago) Jun 8
    to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
    Attention needed from James Cook, Justin DeWitt and Min Qin

    Avi Drissman added 1 comment

    Commit Message
    Line 9, Patchset 6 (Latest):MHTML generation previously used base::CreateTemporaryFile() which
    immediately closes the created file descriptor, then open the created
    file path separately. This allows attackers to tamper the file during
    Bo Liu . unresolved

    umm, has anyone evaluated the security concern here? two separate thoughts..

    if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

    a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

    Avi Drissman

    Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

    Open in Gerrit

    Related details

    Attention is currently required from:
    Gerrit-Attention: Min Qin <qin...@chromium.org>
    Gerrit-Comment-Date: Mon, 08 Jun 2026 14:22:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Bo Liu <bo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Bo Liu (Gerrit)

    unread,
    Jun 8, 2026, 10:43:36 AM (6 days ago) Jun 8
    to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
    Attention needed from James Cook, Justin DeWitt and Min Qin

    Bo Liu added 1 comment

    Commit Message
    Line 9, Patchset 6 (Latest):MHTML generation previously used base::CreateTemporaryFile() which
    immediately closes the created file descriptor, then open the created
    file path separately. This allows attackers to tamper the file during
    Bo Liu . unresolved

    umm, has anyone evaluated the security concern here? two separate thoughts..

    if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

    a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

    Avi Drissman

    Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

    Bo Liu

    note my take is that this isn't really a security concern; correctness or just general defensive programming, sure

    if attacker can already write to disk, there isn't anything we can do to protect against tampering here

    Gerrit-Comment-Date: Mon, 08 Jun 2026 14:43:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Avi Drissman <a...@chromium.org>
    Comment-In-Reply-To: Bo Liu <bo...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    James Cook (Gerrit)

    unread,
    Jun 8, 2026, 12:49:19 PM (6 days ago) Jun 8
    to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
    Attention needed from Justin DeWitt and Min Qin

    James Cook added 1 comment

    Patchset-level comments
    James Cook . resolved

    page_capture seems OK, but I'll take a closer look after you've addressed Bo's comments. Just add me back to the attention set when you're ready.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Justin DeWitt
    • Min Qin
    Gerrit-Attention: Justin DeWitt <dew...@chromium.org>
    Gerrit-Attention: Min Qin <qin...@chromium.org>
    Gerrit-Comment-Date: Mon, 08 Jun 2026 16:49:06 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Justin DeWitt (Gerrit)

    unread,
    Jun 8, 2026, 5:35:42 PM (6 days ago) Jun 8
    to Min Qin, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
    Attention needed from Min Qin

    Justin DeWitt voted and added 1 comment

    Votes added by Justin DeWitt

    Code-Review+1

    1 comment

    Patchset-level comments
    Justin DeWitt . resolved

    lgtm offline_pages only.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Min Qin
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement 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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
      Gerrit-Change-Number: 7906598
      Gerrit-PatchSet: 6
      Gerrit-Owner: Min Qin <qin...@chromium.org>
      Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
      Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
      Gerrit-Reviewer: James Cook <jame...@chromium.org>
      Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
      Gerrit-Reviewer: Min Qin <qin...@chromium.org>
      Gerrit-Attention: Min Qin <qin...@chromium.org>
      Gerrit-Comment-Date: Mon, 08 Jun 2026 21:35:08 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Min Qin (Gerrit)

      unread,
      Jun 8, 2026, 8:19:00 PM (6 days ago) Jun 8
      to Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
      Attention needed from Avi Drissman and Bo Liu

      Min Qin added 6 comments

      Commit Message
      Line 9, Patchset 6:MHTML generation previously used base::CreateTemporaryFile() which

      immediately closes the created file descriptor, then open the created
      file path separately. This allows attackers to tamper the file during
      Bo Liu . resolved

      umm, has anyone evaluated the security concern here? two separate thoughts..

      if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

      a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

      Avi Drissman

      Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

      Bo Liu

      note my take is that this isn't really a security concern; correctness or just general defensive programming, sure

      if attacker can already write to disk, there isn't anything we can do to protect against tampering here

      Min Qin

      I think the security concern is only for MacOS. On macOS, both the browser process and the sandboxed child processes obtain the temporary directory via NSTemporaryDirectory(), so the compromised gpu process can delete the temp file and replace it with a simlink. See POC in the attached bug.

      File content/browser/devtools/protocol/devtools_mhtml_helper.cc
      Line 41, Patchset 6: base::BindOnce([](base::File file) {}, std::move(mhtml_file_scoped_)));
      Bo Liu . resolved

      there's base::DoNothingWithBoundArgs

      Min Qin

      Done

      Line 71, Patchset 6: ReportFailure("Unable to create temporary file");
      Bo Liu . resolved

      close immediately on failure

      Min Qin

      If GetTempDir fails, the file is never created.
      If CreateAndOpenTemporaryFileInDir fails, it returns an invalid base::File object.

      So calling close() will be an no-op here

      Line 150, Patchset 6: FILE* stream = base::FileToFILE(std::move(mhtml_file_scoped_), "rb");
      Bo Liu . resolved

      use base::ScopedFILE

      Min Qin

      Done

      File content/browser/download/mhtml_generation_manager.cc
      Line 355, Patchset 6: std::ignore = DenyExecuteAccessToMHTMLFile(file_path);
      Bo Liu . resolved

      CreateMHTMLFile has a long comment explaining this, this just looks random

      Min Qin

      added comments

      File content/public/common/mhtml_generation_params.h
      Line 29, Patchset 6: base::File output_handle;
      Bo Liu . resolved

      sounds like these two should be an std::variant?

      Min Qin

      We actually always need both. On Windows, before passing the file handle to the renderer, we must deny execute access by calling DenyExecuteAccessToMHTMLFile(file_path) (which uses path-based ACL APIs since base/win/security_util.h doesn't have a handle-based equivalent). We also use the path for tracing in initializeJob.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Avi Drissman
      • Bo Liu
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement satisfiedCode-Review
        • requirement 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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
        Gerrit-Change-Number: 7906598
        Gerrit-PatchSet: 6
        Gerrit-Owner: Min Qin <qin...@chromium.org>
        Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
        Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
        Gerrit-Reviewer: James Cook <jame...@chromium.org>
        Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
        Gerrit-Reviewer: Min Qin <qin...@chromium.org>
        Gerrit-Attention: Avi Drissman <a...@chromium.org>
        Gerrit-Attention: Bo Liu <bo...@chromium.org>
        Gerrit-Comment-Date: Tue, 09 Jun 2026 00:18:15 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Bo Liu (Gerrit)

        unread,
        Jun 8, 2026, 10:07:37 PM (5 days ago) Jun 8
        to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
        Attention needed from Avi Drissman and Min Qin

        Bo Liu added 1 comment

        File content/browser/download/mhtml_generation_manager.cc
        Line 357, Patchset 7: std::ignore = DenyExecuteAccessToMHTMLFile(file_path);
        Bo Liu . unresolved

        I mean can you refactor here to not duplicate any code

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Avi Drissman
        • Min Qin
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement 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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
          Gerrit-Change-Number: 7906598
          Gerrit-PatchSet: 8
          Gerrit-Owner: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
          Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
          Gerrit-Reviewer: James Cook <jame...@chromium.org>
          Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Attention: Avi Drissman <a...@chromium.org>
          Gerrit-Attention: Min Qin <qin...@chromium.org>
          Gerrit-Comment-Date: Tue, 09 Jun 2026 02:07:20 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Min Qin (Gerrit)

          unread,
          Jun 8, 2026, 10:18:32 PM (5 days ago) Jun 8
          to Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
          Attention needed from Avi Drissman and Min Qin

          Min Qin added 1 comment

          Commit Message
          Line 9, Patchset 6:MHTML generation previously used base::CreateTemporaryFile() which
          immediately closes the created file descriptor, then open the created
          file path separately. This allows attackers to tamper the file during
          Bo Liu . unresolved

          umm, has anyone evaluated the security concern here? two separate thoughts..

          if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

          a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

          Avi Drissman

          Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

          Bo Liu

          note my take is that this isn't really a security concern; correctness or just general defensive programming, sure

          if attacker can already write to disk, there isn't anything we can do to protect against tampering here

          Min Qin

          I think the security concern is only for MacOS. On macOS, both the browser process and the sandboxed child processes obtain the temporary directory via NSTemporaryDirectory(), so the compromised gpu process can delete the temp file and replace it with a simlink. See POC in the attached bug.

          Min Qin

          This change introduces probably another issue. Previously chrome creates a temp file through makestemp(), this create a file with read | write flag. Then in CreateMHTMLFile(), Chrome reopens that temp file with only append flag to disallow OOPIF reads.

          Now if we create the temp file without opening it again, the temp file will carry the read | write flag, make OOPIF read possible

          So we need another way to create the temp file with only append mode, probably something similar to what windows do: https://source.chromium.org/chromium/chromium/src/+/main:base/files/file_util_win.cc;l=782

          WDYT?

          Gerrit-Comment-Date: Tue, 09 Jun 2026 02:18:13 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Avi Drissman <a...@chromium.org>
          Comment-In-Reply-To: Bo Liu <bo...@chromium.org>
          Comment-In-Reply-To: Min Qin <qin...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Bo Liu (Gerrit)

          unread,
          Jun 8, 2026, 10:23:33 PM (5 days ago) Jun 8
          to Min Qin, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
          Attention needed from Avi Drissman and Min Qin

          Bo Liu added 1 comment

          Commit Message
          Line 9, Patchset 6:MHTML generation previously used base::CreateTemporaryFile() which
          immediately closes the created file descriptor, then open the created
          file path separately. This allows attackers to tamper the file during
          Bo Liu . unresolved

          umm, has anyone evaluated the security concern here? two separate thoughts..

          if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

          a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

          Avi Drissman

          Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

          Bo Liu

          note my take is that this isn't really a security concern; correctness or just general defensive programming, sure

          if attacker can already write to disk, there isn't anything we can do to protect against tampering here

          Min Qin

          I think the security concern is only for MacOS. On macOS, both the browser process and the sandboxed child processes obtain the temporary directory via NSTemporaryDirectory(), so the compromised gpu process can delete the temp file and replace it with a simlink. See POC in the attached bug.

          Min Qin

          This change introduces probably another issue. Previously chrome creates a temp file through makestemp(), this create a file with read | write flag. Then in CreateMHTMLFile(), Chrome reopens that temp file with only append flag to disallow OOPIF reads.

          Now if we create the temp file without opening it again, the temp file will carry the read | write flag, make OOPIF read possible

          So we need another way to create the temp file with only append mode, probably something similar to what windows do: https://source.chromium.org/chromium/chromium/src/+/main:base/files/file_util_win.cc;l=782

          WDYT?

          Bo Liu

          just open with O_NOFOLLOW as the bot suggested? sounds like a fine fix to me

          Gerrit-Comment-Date: Tue, 09 Jun 2026 02:23:18 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Min Qin (Gerrit)

          unread,
          Jun 8, 2026, 10:55:22 PM (5 days ago) Jun 8
          to Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org
          Attention needed from Avi Drissman and Bo Liu

          Min Qin added 1 comment

          Commit Message
          Line 9, Patchset 6:MHTML generation previously used base::CreateTemporaryFile() which
          immediately closes the created file descriptor, then open the created
          file path separately. This allows attackers to tamper the file during
          Bo Liu . unresolved

          umm, has anyone evaluated the security concern here? two separate thoughts..

          if this is a valid security concern, then base::CreateTemporaryFile is simply unsafe?

          a safer version would be to just return the fd, but it's still a named file on the file system, so attacker could still open the file using the file path and do the same attack?

          Avi Drissman

          Ditto; this is what I immediately thought. We shouldn’t allow unsafe primitives.

          Bo Liu

          note my take is that this isn't really a security concern; correctness or just general defensive programming, sure

          if attacker can already write to disk, there isn't anything we can do to protect against tampering here

          Min Qin

          I think the security concern is only for MacOS. On macOS, both the browser process and the sandboxed child processes obtain the temporary directory via NSTemporaryDirectory(), so the compromised gpu process can delete the temp file and replace it with a simlink. See POC in the attached bug.

          Min Qin

          This change introduces probably another issue. Previously chrome creates a temp file through makestemp(), this create a file with read | write flag. Then in CreateMHTMLFile(), Chrome reopens that temp file with only append flag to disallow OOPIF reads.

          Now if we create the temp file without opening it again, the temp file will carry the read | write flag, make OOPIF read possible

          So we need another way to create the temp file with only append mode, probably something similar to what windows do: https://source.chromium.org/chromium/chromium/src/+/main:base/files/file_util_win.cc;l=782

          WDYT?

          Min Qin

          A quick patch will be to add O_NOFOLLOW in CreateMHTMLFile(), so that when reopening the temp file Chrome will not follow a simlink to a sensitive file.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Avi Drissman
          • Bo Liu
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement 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: I667072a04ea228d0ee7e42f113d9aa99b3667b00
          Gerrit-Change-Number: 7906598
          Gerrit-PatchSet: 8
          Gerrit-Owner: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
          Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
          Gerrit-Reviewer: James Cook <jame...@chromium.org>
          Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-Attention: Avi Drissman <a...@chromium.org>
          Gerrit-Attention: Bo Liu <bo...@chromium.org>
          Gerrit-Comment-Date: Tue, 09 Jun 2026 02:55:04 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Min Qin (Gerrit)

          unread,
          Jun 12, 2026, 5:31:51 PM (2 days ago) Jun 12
          to Code Review Nudger, Justin DeWitt, Bo Liu, Avi Drissman, James Cook, Chromium LUCI CQ, chromium...@chromium.org, devtools...@chromium.org, alexmo...@chromium.org, chromium-a...@chromium.org, creis...@chromium.org, dtraino...@chromium.org, extension...@chromium.org, navigation...@chromium.org

          Min Qin abandoned this change.

          View Change

          Abandoned

          Min Qin abandoned this change

          Related details

          Attention set is empty
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          • requirement satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: abandon
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I667072a04ea228d0ee7e42f113d9aa99b3667b00
          Gerrit-Change-Number: 7906598
          Gerrit-PatchSet: 8
          Gerrit-Owner: Min Qin <qin...@chromium.org>
          Gerrit-Reviewer: Avi Drissman <a...@chromium.org>
          Gerrit-Reviewer: Bo Liu <bo...@chromium.org>
          Gerrit-Reviewer: James Cook <jame...@chromium.org>
          Gerrit-Reviewer: Justin DeWitt <dew...@chromium.org>
          Gerrit-Reviewer: Min Qin <qin...@chromium.org>
          Gerrit-CC: Code Review Nudger <android-build...@prod.google.com>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages