Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate crashes under Quirks::advancedPrivacyProtectionSubstituteDataURLForScriptWithFeatures() #21773

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented Dec 14, 2023

1bfda19

Mitigate crashes under Quirks::advancedPrivacyProtectionSubstituteDataURLForScriptWithFeatures()
https://bugs.webkit.org/show_bug.cgi?id=266380
rdar://118479646

Reviewed by Yusuke Suzuki.

Even after the mitigations in 269984@main, we're still sometimes crashing when attempting to
determine whether or not we should apply hard-coded canvas fingerprinting mitigations when advanced
privacy protections are enabled. From discussing with JSC folks, this seems to be due to the way in
which we're currently trying to walk the stack by traversing `callerFrame()`s:

```
while (!codeBlock) {
    callFrame = callFrame->callerFrame();
    if (!callFrame)
        break;
    codeBlock = callFrame->codeBlock();
}
```

Instead of implementing it this way, the JSC team recommended using `StackVisitor::visit` instead to
walk the stack, which is the de-facto mechanism used to perform similar stack traversals elsewhere
in the codebase. In addition, I'm also rearranging this check, so that we only ever attempt this
relatively more expensive stack walk in the case where the `lastDrawnText`, `canvasWidth` and
`canvasHeight` all match their expected values for the quirk.

* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::advancedPrivacyProtectionSubstituteDataURLForScriptWithFeatures const):

In my manual testing, I found that the source code length on some of the affected sites has been
changed slightly; adjust this quirk to match.

Canonical link: https://commits.webkit.org/272093@main

17a8d58

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
🛠 tv-sim
✅ 🛠 🧪 merge ✅ 🛠 watch
✅ 🛠 watch-sim

@whsieh whsieh requested a review from cdumez as a code owner December 14, 2023 00:37
@whsieh whsieh self-assigned this Dec 14, 2023
@whsieh whsieh added the WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit). label Dec 14, 2023
Copy link
Member

@Constellation Constellation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label Dec 15, 2023
@whsieh
Copy link
Member Author

whsieh commented Dec 15, 2023

Thanks for the review!

…aURLForScriptWithFeatures()

https://bugs.webkit.org/show_bug.cgi?id=266380
rdar://118479646

Reviewed by Yusuke Suzuki.

Even after the mitigations in 269984@main, we're still sometimes crashing when attempting to
determine whether or not we should apply hard-coded canvas fingerprinting mitigations when advanced
privacy protections are enabled. From discussing with JSC folks, this seems to be due to the way in
which we're currently trying to walk the stack by traversing `callerFrame()`s:

```
while (!codeBlock) {
    callFrame = callFrame->callerFrame();
    if (!callFrame)
        break;
    codeBlock = callFrame->codeBlock();
}
```

Instead of implementing it this way, the JSC team recommended using `StackVisitor::visit` instead to
walk the stack, which is the de-facto mechanism used to perform similar stack traversals elsewhere
in the codebase. In addition, I'm also rearranging this check, so that we only ever attempt this
relatively more expensive stack walk in the case where the `lastDrawnText`, `canvasWidth` and
`canvasHeight` all match their expected values for the quirk.

* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::advancedPrivacyProtectionSubstituteDataURLForScriptWithFeatures const):

In my manual testing, I found that the source code length on some of the affected sites has been
changed slightly; adjust this quirk to match.

Canonical link: https://commits.webkit.org/272093@main
@webkit-commit-queue
Copy link
Collaborator

Committed 272093@main (1bfda19): https://commits.webkit.org/272093@main

Reviewed commits have been landed. Closing PR #21773 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 1bfda19 into WebKit:main Dec 15, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 15, 2023
@whsieh whsieh deleted the eng/266380 branch December 15, 2023 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebCore Misc. For miscellaneous bugs in the WebCore framework (and not JavaScriptCore or WebKit).
Projects
None yet
4 participants