Chrome · Forms
CVE-2026-79133
Logic Error in Forms
Overview
Low
Severity
—
CVSS
No
Exploited ITW
Fixed
Fix Status
Changed Functions
| Function | Change | Notes |
|---|---|---|
ifthird_party/blink/renderer/core/html/forms/html_label_element.cc |
modified | |
TEST_Fthird_party/blink/renderer/core/html/forms/html_label_element_test.cc |
modified |
Files Changed
third_party/blink/renderer/core/html/forms/html_label_element.ccthird_party/blink/renderer/core/html/forms/html_label_element_test.cc
Patch
From 451065790761eb16157922ddf51c9b581dcf5ed7 Mon Sep 17 00:00:00 2001
From: David Baron <dbaron@chromium.org>
Date: Sun, 19 Jul 2026 06:47:30 -0700
Subject: [PATCH] Set FocusType more carefully when forwarding clicks from <label>.
Both the fix and the test are AI-authored, though from different AI
tools. (I shortened a verbose code comment in the fix and reduced
overuse of the auto keyword in the test.)
Fixed: 533075126
Change-Id: I289f8f0d7c129776165ea6cfb502498c414cd706
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8115027
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1664455}
---
diff --git a/third_party/blink/renderer/core/html/forms/html_label_element.cc b/third_party/blink/renderer/core/html/forms/html_label_element.cc
index a5a5d07..d1064db 100644
--- a/third_party/blink/renderer/core/html/forms/html_label_element.cc
+++ b/third_party/blink/renderer/core/html/forms/html_label_element.cc
@@ -260,8 +260,13 @@
// In case of double click or triple click, selection will be there,
// so do not focus the control element.
if (!is_label_text_selected) {
+ // Set focus_type so that label.click() from script can't set
+ // WasLastFocusFromUserGesture.
+ const mojom::blink::FocusType focus_type =
+ evt.isTrusted() ? mojom::blink::FocusType::kMouse
+ : mojom::blink::FocusType::kScript;
element->Focus(FocusParams(SelectionBehaviorOnFocus::kRestore,
- mojom::blink::FocusType::kMouse, nullptr,
+ focus_type, nullptr,
FocusOptions::Create()));
}
}
diff --git a/third_party/blink/renderer/core/html/forms/html_label_element_test.cc b/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
index 8565b7da..575f982a 100644
--- a/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
+++ b/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/dom/events/simulated_click_options.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
namespace blink {
@@ -74,4 +75,31 @@
EXPECT_EQ("", label->TextContentExcludingLabelable().StripWhiteSpace());
}
+TEST_F(HTMLLabelElementTest, WasLastFocusFromUserGesture) {
+ SetBodyInnerHTML(R"HTML(
+ <label id=label1 for=input1></label>
+ <input id=input1>
+ <label id=label2 for=input2></label>
+ <input id=input2>
+ )HTML");
+ HTMLLabelElement* label1 = To<HTMLLabelElement>(
+ GetDocument().getElementById(AtomicString("label1")));
+ Element* input1 = GetDocument().getElementById(AtomicString("input1"));
+ Element* label2 = GetDocument().getElementById(AtomicString("label2"));
+ Element* input2 = GetDocument().getElementById(AtomicString("input2"));
+
+ // Untrusted click (such as label.click() from script) should not set
+ // WasLastFocusFromUserGesture().
+ label1->click();
+ EXPECT_EQ(input1, GetDocument().FocusedElement());
+ EXPECT_FALSE(input1->WasLastFocusFromUserGesture());
+
+ // Trusted click (such as user interaction) should set
+ // WasLastFocusFromUserGesture().
+ label2->DispatchSimulatedClick(nullptr,
+ SimulatedClickCreationScope::kFromUserAgent);
+ EXPECT_EQ(input2, GetDocument().FocusedElement());
+ EXPECT_TRUE(input2->WasLastFocusFromUserGesture());
+}
+
} // namespace blink
Loading diff…
Regression Test / PoC
shipped with the fix
diff --git a/third_party/blink/renderer/core/html/forms/html_label_element_test.cc b/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
index 8565b7da..575f982a 100644
--- a/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
+++ b/third_party/blink/renderer/core/html/forms/html_label_element_test.cc
@@ -6,6 +6,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/document.h"
+#include "third_party/blink/renderer/core/dom/events/simulated_click_options.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
namespace blink {
@@ -74,4 +75,31 @@
EXPECT_EQ("", label->TextContentExcludingLabelable().StripWhiteSpace());
}
+TEST_F(HTMLLabelElementTest, WasLastFocusFromUserGesture) {
+ SetBodyInnerHTML(R"HTML(
+ <label id=label1 for=input1></label>
+ <input id=input1>
+ <label id=label2 for=input2></label>
+ <input id=input2>
+ )HTML");
+ HTMLLabelElement* label1 = To<HTMLLabelElement>(
+ GetDocument().getElementById(AtomicString("label1")));
+ Element* input1 = GetDocument().getElementById(AtomicString("input1"));
+ Element* label2 = GetDocument().getElementById(AtomicString("label2"));
+ Element* input2 = GetDocument().getElementById(AtomicString("input2"));
+
+ // Untrusted click (such as label.click() from script) should not set
+ // WasLastFocusFromUserGesture().
+ label1->click();
+ EXPECT_EQ(input1, GetDocument().FocusedElement());
+ EXPECT_FALSE(input1->WasLastFocusFromUserGesture());
+
+ // Trusted click (such as user interaction) should set
+ // WasLastFocusFromUserGesture().
+ label2->DispatchSimulatedClick(nullptr,
+ SimulatedClickCreationScope::kFromUserAgent);
+ EXPECT_EQ(input2, GetDocument().FocusedElement());
+ EXPECT_TRUE(input2->WasLastFocusFromUserGesture());
+}
+
} // namespace blink
Loading diff…
Original Bug Report
The reporter's bug is still restricted on the tracker. Chrome de-restricts security bugs ~30–90 days after the fix ships; a later run will backfill it here.
References
On This Page