Skip to content

Ensure Enhanced Security handles HTTPFirst correctly#62980

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ronan-apple:eng/173934437-https-first-es-issue
Apr 30, 2026
Merged

Ensure Enhanced Security handles HTTPFirst correctly#62980
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
ronan-apple:eng/173934437-https-first-es-issue

Conversation

@ronan-apple
Copy link
Copy Markdown
Contributor

@ronan-apple ronan-apple commented Apr 17, 2026

68ec5f3

Ensure Enhanced Security handles HTTPFirst correctly
https://bugs.webkit.org/show_bug.cgi?id=312578
rdar://173934437

Reviewed by Matthew Finkel.

Currently, when a http:// URL is received with the HTTPSFirst network
policy set, we opt in to Enhanced Security. However, WebContent will
attempt to upgrade this to HTTPS on seeing the set policy automatically
and never pass the decision back through WebPageProxy if the upgrade
succeeds.

To address this, we determine if a HTTPS upgrade is going to be
attempted and, in this case, do not opt into Enhanced Security. If the
upgrade later fails, this will pass through didFailProvisionalLoad and
revisit the Enhanced Security decision in WebPageProxy.

Two new tests are added which confirm the expected behaviour for
HTTPSFirst in the success case, and ensure that when HTTPSFirst fails
that Enhanced Security is still enabled.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/EnhancedSecurityPolicies.mm

* Source/WebKit/UIProcess/EnhancedSecurityTracking.cpp:
(WebKit::shouldExpectHTTPSUpgrade):
(WebKit::EnhancedSecurityTracking::enableIfRequired):
(WebKit::EnhancedSecurityTracking::trackNavigation):
* Source/WebKit/UIProcess/EnhancedSecurityTracking.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/EnhancedSecurityPolicies.mm:
(runHttpsFirstUpgradeDisablesEnhancedSecurity):
(runHttpsFirstFailureEnablesEnhancedSecurity):

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

5be4ff5

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ✅ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests ✅ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe loading 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@ronan-apple ronan-apple self-assigned this Apr 17, 2026
@ronan-apple ronan-apple added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Apr 17, 2026
@ronan-apple ronan-apple requested a review from sysrqb April 28, 2026 09:00
@ronan-apple ronan-apple marked this pull request as ready for review April 29, 2026 15:11
@ronan-apple ronan-apple requested a review from cdumez as a code owner April 29, 2026 15:11
@ronan-apple ronan-apple added the merge-queue Applied to send a pull request to merge-queue label Apr 30, 2026
https://bugs.webkit.org/show_bug.cgi?id=312578
rdar://173934437

Reviewed by Matthew Finkel.

Currently, when a http:// URL is received with the HTTPSFirst network
policy set, we opt in to Enhanced Security. However, WebContent will
attempt to upgrade this to HTTPS on seeing the set policy automatically
and never pass the decision back through WebPageProxy if the upgrade
succeeds.

To address this, we determine if a HTTPS upgrade is going to be
attempted and, in this case, do not opt into Enhanced Security. If the
upgrade later fails, this will pass through didFailProvisionalLoad and
revisit the Enhanced Security decision in WebPageProxy.

Two new tests are added which confirm the expected behaviour for
HTTPSFirst in the success case, and ensure that when HTTPSFirst fails
that Enhanced Security is still enabled.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/EnhancedSecurityPolicies.mm

* Source/WebKit/UIProcess/EnhancedSecurityTracking.cpp:
(WebKit::shouldExpectHTTPSUpgrade):
(WebKit::EnhancedSecurityTracking::enableIfRequired):
(WebKit::EnhancedSecurityTracking::trackNavigation):
* Source/WebKit/UIProcess/EnhancedSecurityTracking.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/EnhancedSecurityPolicies.mm:
(runHttpsFirstUpgradeDisablesEnhancedSecurity):
(runHttpsFirstFailureEnablesEnhancedSecurity):

Canonical link: https://commits.webkit.org/312342@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/173934437-https-first-es-issue branch from 5be4ff5 to 68ec5f3 Compare April 30, 2026 07:55
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 312342@main (68ec5f3): https://commits.webkit.org/312342@main

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

@webkit-commit-queue webkit-commit-queue merged commit 68ec5f3 into WebKit:main Apr 30, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Bugs Unclassified bugs are placed in this component until the correct component can be determined.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants