Prevent custom elements from being considered formatting elements in HTML parser. [chromium/src : main]

0 views
Skip to first unread message

David Baron (Gerrit)

unread,
Mar 30, 2026, 3:17:54 PM (4 days ago) Mar 30
to David Baron, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Mason Freed

David Baron added 1 comment

Commit Message
Line 27, Patchset 1 (Latest):
Thanks to Arthur Sonzogni for the tests, originally from
https://crrev.com/c/7706938
David Baron . unresolved

@arthurs...@chromium.org, I'm noticing that without this change I'm only seeing two of the tests fail: `adoption_agency_shift.html` with a `DCHECK failed: Contains(old_element)` and `adoption_agency_uaf.html` with a SEGV. I'm curious if some of the other tests were failing for you in a different configuration?

Open in Gerrit

Related details

Attention is currently required from:
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
Gerrit-Change-Number: 7712232
Gerrit-PatchSet: 1
Gerrit-Owner: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Mon, 30 Mar 2026 19:17:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Mar 31, 2026, 1:10:51 PM (3 days ago) Mar 31
to David Baron, Michał Bentkowski, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from David Baron and Michał Bentkowski

Mason Freed added 4 comments

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Mason Freed . resolved

The code looks good, and I agree it'll fix the bug. Just some questions.

+securitymb@ for the mXSS question

File third_party/blink/renderer/core/html/parser/html_construction_site.cc
Line 1068, Patchset 1 (Latest): // Disallow custom elements from being on the stack of active formatting
// elements.
Mason Freed . unresolved

You might consider also saying that this isn't per-spec, but is a corner case we're willing to live with? Or something to that effect?

Line 1070, Patchset 1 (Latest): if (token->GetAttributeItem(html_names::kIsAttr) &&
Mason Freed . unresolved

Per my offline comment, my concern is that this might (?) introduce mXSS concerns? I.e. the behavior within trees of nested formatting elements will be different, depending on whether the formatting element has `is=something`. So if a sanitizer is stripping out `is` attributes, and then serializing the resulting tree, the resulting HTML will be parsed into a different tree because of the lack of `is`.

@securitymb for comments.

File third_party/blink/web_tests/external/wpt/html/syntax/parsing/reconstruct_active_formatting_elements_uaf.html
File-level comment, Patchset 1 (Latest):
Mason Freed . unresolved

Perhaps just `-crash.html` rather than `_uaf.html`? This test doesn't actually make real use of `testharness`. (Also replace "use after free" with "crash" in the content of the test?)

This comment applies to a few tests above. Perhaps all of them.

Open in Gerrit

Related details

Attention is currently required from:
  • David Baron
  • Michał Bentkowski
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
Gerrit-Change-Number: 7712232
Gerrit-PatchSet: 1
Gerrit-Owner: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Reviewer: Michał Bentkowski <secur...@google.com>
Gerrit-Attention: David Baron <dba...@chromium.org>
Gerrit-Attention: Michał Bentkowski <secur...@google.com>
Gerrit-Comment-Date: Tue, 31 Mar 2026 17:10:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Michał Bentkowski (Gerrit)

unread,
Apr 1, 2026, 8:04:51 AM (3 days ago) Apr 1
to David Baron, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from David Baron and Mason Freed

Michał Bentkowski added 2 comments

Patchset-level comments
Michał Bentkowski . resolved

Removing myself from reviewers as I don't actually have permission to vote.

File third_party/blink/renderer/core/html/parser/html_construction_site.cc
Line 1070, Patchset 1 (Latest): if (token->GetAttributeItem(html_names::kIsAttr) &&
Mason Freed . resolved

Per my offline comment, my concern is that this might (?) introduce mXSS concerns? I.e. the behavior within trees of nested formatting elements will be different, depending on whether the formatting element has `is=something`. So if a sanitizer is stripping out `is` attributes, and then serializing the resulting tree, the resulting HTML will be parsed into a different tree because of the lack of `is`.

@securitymb for comments.

Michał Bentkowski

I think this should be fine. The list of active formatting elements is meant to handle mis-nested tags. So the sanitizer should create a valid HTML structure (i.e. no mis-nested tags) and on re-parsing this algorithm shouldn't kick in.

Open in Gerrit

Related details

Attention is currently required from:
  • David Baron
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
Gerrit-Change-Number: 7712232
Gerrit-PatchSet: 1
Gerrit-Owner: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Attention: David Baron <dba...@chromium.org>
Gerrit-Comment-Date: Wed, 01 Apr 2026 12:04:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

David Baron (Gerrit)

unread,
Apr 1, 2026, 12:47:39 PM (2 days ago) Apr 1
to David Baron, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from Mason Freed

David Baron added 2 comments

File third_party/blink/renderer/core/html/parser/html_construction_site.cc
Line 1068, Patchset 1: // Disallow custom elements from being on the stack of active formatting
// elements.
Mason Freed . resolved

You might consider also saying that this isn't per-spec, but is a corner case we're willing to live with? Or something to that effect?

David Baron

Better, I filed https://github.com/whatwg/html/issues/12327 and I'll link to it.

File third_party/blink/web_tests/external/wpt/html/syntax/parsing/reconstruct_active_formatting_elements_uaf.html
File-level comment, Patchset 1:
Mason Freed . resolved

Perhaps just `-crash.html` rather than `_uaf.html`? This test doesn't actually make real use of `testharness`. (Also replace "use after free" with "crash" in the content of the test?)

This comment applies to a few tests above. Perhaps all of them.

David Baron

Moved to `crashtests` subdirectory, renamed, changed them to use crashtest infrastructure (`class="test-wait"` and `TestRendered` event).

Open in Gerrit

Related details

Attention is currently required from:
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
Gerrit-Change-Number: 7712232
Gerrit-PatchSet: 2
Gerrit-Owner: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Wed, 01 Apr 2026 16:47:27 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Apr 1, 2026, 8:06:04 PM (2 days ago) Apr 1
to David Baron, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org
Attention needed from David Baron

Mason Freed voted and added 3 comments

Votes added by Mason Freed

Code-Review+1

3 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mason Freed . resolved

LGTM!

File third_party/blink/renderer/core/html/parser/html_construction_site.cc
Line 1068, Patchset 1: // Disallow custom elements from being on the stack of active formatting
// elements.
Mason Freed . resolved

You might consider also saying that this isn't per-spec, but is a corner case we're willing to live with? Or something to that effect?

David Baron

Better, I filed https://github.com/whatwg/html/issues/12327 and I'll link to it.

Mason Freed

even better

Line 1070, Patchset 1: if (token->GetAttributeItem(html_names::kIsAttr) &&
Mason Freed . resolved

Per my offline comment, my concern is that this might (?) introduce mXSS concerns? I.e. the behavior within trees of nested formatting elements will be different, depending on whether the formatting element has `is=something`. So if a sanitizer is stripping out `is` attributes, and then serializing the resulting tree, the resulting HTML will be parsed into a different tree because of the lack of `is`.

@securitymb for comments.

Michał Bentkowski

I think this should be fine. The list of active formatting elements is meant to handle mis-nested tags. So the sanitizer should create a valid HTML structure (i.e. no mis-nested tags) and on re-parsing this algorithm shouldn't kick in.

Mason Freed

Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • David Baron
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
    Gerrit-Change-Number: 7712232
    Gerrit-PatchSet: 2
    Gerrit-Owner: David Baron <dba...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Attention: David Baron <dba...@chromium.org>
    Gerrit-Comment-Date: Thu, 02 Apr 2026 00:05:52 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    Comment-In-Reply-To: David Baron <dba...@chromium.org>
    Comment-In-Reply-To: Michał Bentkowski <secur...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    David Baron (Gerrit)

    unread,
    Apr 2, 2026, 9:34:25 AM (yesterday) Apr 2
    to David Baron, Arthur Sonzogni, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

    David Baron voted and added 1 comment

    Votes added by David Baron

    Commit-Queue+2

    1 comment

    Commit Message

    Thanks to Arthur Sonzogni for the tests, originally from
    https://crrev.com/c/7706938
    David Baron . resolved

    @arthurs...@chromium.org, I'm noticing that without this change I'm only seeing two of the tests fail: `adoption_agency_shift.html` with a `DCHECK failed: Contains(old_element)` and `adoption_agency_uaf.html` with a SEGV. I'm curious if some of the other tests were failing for you in a different configuration?

    David Baron

    I'm going to go ahead and submit, but I'd still be interested in further feedback from @arthurs...@chromium.org if he has a chance.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
      Gerrit-Change-Number: 7712232
      Gerrit-PatchSet: 2
      Gerrit-Owner: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 13:34:18 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: David Baron <dba...@chromium.org>
      satisfied_requirement
      open
      diffy

      Blink W3C Test Autoroller (Gerrit)

      unread,
      Apr 2, 2026, 10:00:59 AM (yesterday) Apr 2
      to David Baron, Chromium LUCI CQ, Arthur Sonzogni, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

      Message from Blink W3C Test Autoroller

      Exportable changes to web-platform-tests were detected in this CL and a pull request in the upstream repo has been made: https://github.com/web-platform-tests/wpt/pull/58949.

      When this CL lands, the bot will automatically merge the PR on GitHub if the required GitHub checks pass; otherwise, ecosystem-infra@ team will triage the failures and may contact you.

      WPT Export docs:
      https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md#Automatic-export-process

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
      Gerrit-Change-Number: 7712232
      Gerrit-PatchSet: 2
      Gerrit-Owner: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-CC: Blink W3C Test Autoroller <blink-w3c-te...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 14:00:40 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Apr 2, 2026, 10:40:33 AM (yesterday) Apr 2
      to David Baron, Blink W3C Test Autoroller, Arthur Sonzogni, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      Prevent custom elements from being considered formatting elements in HTML parser.

      The HTML parser (in spec and implementations) has algorithms for
      backwards compatibility with pre-tree implementations of HTML. One of
      these deals with the concept of "active formatting elements", which are
      elements which we attempt to faithfully represent mismatched end tags
      for formatting purposes. This gives behavior that is compatible with
      HTML implementations that predate in-memory tree representations of
      the DOM.

      This change forbids elements with an is= attribute from being considered
      formatting elements, and thus being reopened as part of this
      compatibility behavior.

      This avoids needing to fix the algorithm to "reconstruct the active
      formatting elements" in both the spec at
      https://html.spec.whatwg.org/multipage/parsing.html#reconstruct-the-active-formatting-elements
      and in the code, to deal with the possibility that custom element
      constructors will run in the middle of the algorithm and mess with the
      algorithm's internal state.


      Thanks to Arthur Sonzogni for the tests, originally from
      https://crrev.com/c/7706938 (with some small tweaks by me).
      Fixed: 496298136
      Co-authored-by: Arthur Sonzogni <arthurs...@chromium.org>
      Change-Id: I91a62c9afa45889b19d3f4dd356cc18996902504
      Reviewed-by: Mason Freed <mas...@chromium.org>
      Commit-Queue: David Baron <dba...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1609201}
      Files:
      • M third_party/blink/renderer/core/html/parser/html_construction_site.cc
      • M third_party/blink/renderer/platform/runtime_enabled_features.json5
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/adoption-agency-001.html
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/adoption-agency-002.html
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/adoption-agency-bailout-001.html
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/adoption-agency-shift-001.html
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/adoption-agency-swap-empty-list-001.html
      • A third_party/blink/web_tests/external/wpt/html/syntax/parsing/crashtests/reconstruct-active-formatting-elements-001.html
      Change size: M
      Delta: 8 files changed, 214 insertions(+), 0 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mason Freed
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I91a62c9afa45889b19d3f4dd356cc18996902504
      Gerrit-Change-Number: 7712232
      Gerrit-PatchSet: 3
      Gerrit-Owner: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-CC: Blink W3C Test Autoroller <blink-w3c-te...@chromium.org>
      open
      diffy
      satisfied_requirement

      Blink W3C Test Autoroller (Gerrit)

      unread,
      Apr 2, 2026, 11:38:07 AM (yesterday) Apr 2
      to Chromium LUCI CQ, David Baron, Arthur Sonzogni, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org, loading-rev...@chromium.org

      Message from Blink W3C Test Autoroller

      The WPT PR for this CL has been merged upstream! https://github.com/web-platform-tests/wpt/pull/58949

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: I91a62c9afa45889b19d3f4dd356cc18996902504
      Gerrit-Change-Number: 7712232
      Gerrit-PatchSet: 3
      Gerrit-Owner: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      Gerrit-CC: Arthur Sonzogni <arthurs...@chromium.org>
      Gerrit-CC: Blink W3C Test Autoroller <blink-w3c-te...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 15:37:59 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: No
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages