Allow tainted scripts to extract text from some fields#52705
Conversation
|
EWS run on previous version of this PR (hash 25aae35) Details |
25aae35 to
0ecd3e6
Compare
|
EWS run on previous version of this PR (hash 0ecd3e6) Details |
| @@ -155,6 +155,7 @@ void HTMLTextFormControlElement::didEditInnerTextValue(bool wasUserEdit) | |||
| LOG(Editing, "HTMLTextFormControlElement %p didEditInnerTextValue", this); | |||
|
|
|||
| m_lastChangeWasUserEdit = wasUserEdit; | |||
| m_wasChangeEverUserEdit |= wasUserEdit; | |||
There was a problem hiding this comment.
| m_wasChangeEverUserEdit |= wasUserEdit; | |
| m_wasEverChangedByUserEdit |= wasUserEdit; |
Maybe m_wasEverChangedByUserEdit or m_wasEverUserEdited might read a bit more nicely?
| return protectedDocument()->requiresScriptTrackingPrivacyProtection(ScriptTrackingPrivacyCategory::FormControls) | ||
| && (wasChangeEverUserEdit() || !wasCreatedByTaintedScript()); |
There was a problem hiding this comment.
I think if you make this (wasChangeEverUserEdit() || !wasCreatedByTaintedScript()) && …, we might be able to avoid the (potentially more expensive) script tracking privacy check.
| @@ -66,6 +66,7 @@ HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc | |||
| , m_isRequired(false) | |||
| , m_valueMatchesRenderer(false) | |||
| , m_wasChangedSinceLastFormControlChangeEvent(false) | |||
| , m_wasCreatedByTaintedScript(document.requiresScriptTrackingPrivacyProtection(ScriptTrackingPrivacyCategory::FormControls)) | |||
There was a problem hiding this comment.
Might be worth adding a new argument flag to requiresScriptTrackingPrivacyProtection, which would prevent us from adding a console log message in the case where it's tainted (or perhaps, a different message, that would make it clear that returning true here doesn't, by itself, block form access).
0ecd3e6 to
ec2e341
Compare
|
EWS run on current version of this PR (hash ec2e341) Details
|
https://bugs.webkit.org/show_bug.cgi?id=301157 rdar://161669359 Reviewed by Wenson Hsieh. The form control protection prevents tainted scripts from accessing the value of all text form fields. That protection causes some web compatibility issues that we can fix by slightly relaxing the restriction which is what I'm doing in this patch. We can let tainted scripts extract the value if that element was created by a tainted script and it wasn't modified by user input. Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/ScriptTrackingPrivacyTests.mm * Source/WebCore/html/HTMLFormControlElement.cpp: (WebCore::m_wasCreatedByTaintedScript): (WebCore::m_wasChangedSinceLastFormControlChangeEvent): Deleted. * Source/WebCore/html/HTMLFormControlElement.h: (WebCore::HTMLFormControlElement::wasCreatedByTaintedScript const): * Source/WebCore/html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::value const): * Source/WebCore/html/HTMLTextAreaElement.cpp: (WebCore::HTMLTextAreaElement::value const): * Source/WebCore/html/HTMLTextFormControlElement.cpp: (WebCore::HTMLTextFormControlElement::didEditInnerTextValue): (WebCore::HTMLTextFormControlElement::wasChangeEverUserEdit const): (WebCore::HTMLTextFormControlElement::shouldApplyScriptTrackingPrivacyProtection const): * Source/WebCore/html/HTMLTextFormControlElement.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/ScriptTrackingPrivacyTests.mm: (TestWebKitAPI::(ScriptTrackingPrivacyTests, DirectFormFieldAccess)): Canonical link: https://commits.webkit.org/302031@main
ec2e341 to
614b6dc
Compare
|
Committed 302031@main (614b6dc): https://commits.webkit.org/302031@main Reviewed commits have been landed. Closing PR #52705 and removing active labels. |
614b6dc
ec2e341