Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7ab26d3bede6533ba602077c94c76b6b8070dce3
https://github.com/WebKit/WebKit/commit/7ab26d3bede6533ba602077c94c76b6b8070dce3
Author: Brady Eidson <[email protected]>
Date: 2026-05-25 (Mon, 25 May 2026)
Changed paths:
M Source/WTF/wtf/WallTime.cpp
M Source/WTF/wtf/WallTime.h
M Source/WebCore/Modules/notifications/Notification.cpp
M Source/WebCore/Modules/notifications/Notification.h
M Source/WebCore/Modules/notifications/NotificationData.h
M Source/WebCore/Modules/notifications/NotificationDataCocoa.mm
M Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Source/WebKit/Shared/WebProcessCreationParameters.h
M Source/WebKit/Shared/WebProcessCreationParameters.serialization.in
M Source/WebKit/Shared/WebPushDaemonConstants.h
M Source/WebKit/Shared/WebPushMessage.cpp
M Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp
M Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h
M Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h
M Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm
M Source/WebKit/UIProcess/WebProcessPool.cpp
M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h
M Source/WebKit/WebProcess/WebProcess.cpp
M Source/WebKit/webpushd/WebPushDaemon.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/PushAPI.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WebPushDaemon.mm
M Tools/WebKitTestRunner/TestController.cpp
M Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Log Message:
-----------
Don't let ServiceWorkers handling push events call showNotification but then
immediately close that notification
rdar://170734287
https://bugs.webkit.org/show_bug.cgi?id=309940
Reviewed by Ben Nham.
We have "silent push" protection, where we require service workers handling a
push event to post a user visible notification.
However, a website that wants to use push messages to get silent background
runtime can get "user visible" credit
by showing the notification but then immediately close it.
This patch adds behavior such that a persistent notification has a minimum
lifetime before script can call close() on it.
This lifetime lines up with the maximum "push event handler" lifetime, such
that an attacker that sends a second push
message to try to close notifications from the first push message needs to
wait, and that second handler will itself
need to show a new notification for the push subscription to remain valid.
Notifications already had a "creation time" member, but the member wasn't
properly kept up to date as it was passed
around through various processes and delegate calls. This patch makes it so
that value is accurate and maintained.
We also pipe through explicit overriding of the "required lifetime" value to
something shorter for testing purposes.
Tests: Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
* Source/WTF/wtf/WallTime.cpp:
(WTF::WallTime::fromSecondsSinceEpoch):
(WTF::WallTime::secondsSinceEpoch const):
* Source/WTF/wtf/WallTime.h:
* Source/WebCore/Modules/notifications/Notification.cpp:
(WebCore::Notification::setOverridePersistentNotificationMinimumLifetime):
(WebCore::Notification::create):
(WebCore::Notification::Notification):
(WebCore::Notification::close):
(WebCore::Notification::data const):
* Source/WebCore/Modules/notifications/Notification.h:
* Source/WebCore/Modules/notifications/NotificationData.h:
* Source/WebCore/Modules/notifications/NotificationDataCocoa.mm:
(WebCore::NotificationData::fromDictionary):
(WebCore::NotificationData::dictionaryRepresentation const):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebProcessCreationParameters.h:
* Source/WebKit/Shared/WebProcessCreationParameters.serialization.in:
* Source/WebKit/Shared/WebPushDaemonConstants.h:
(): Deleted.
* Source/WebKit/Shared/WebPushMessage.cpp:
(WebKit::WebPushMessage::notificationPayloadToCoreData const):
* Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp:
(WKWebsiteDataStoreConfigurationOverridePersistentNotificationMinimumLifetimeForTesting):
(WKWebsiteDataStoreConfigurationSetOverridePersistentNotificationMinimumLifetimeForTesting):
* Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration
overridePersistentNotificationMinimumLifetimeForTesting]):
(-[_WKWebsiteDataStoreConfiguration
setOverridePersistentNotificationMinimumLifetimeForTesting:]):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::initializeNewWebProcess):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::overridePersistentNotificationMinimumLifetimeForTesting
const):
(WebKit::WebsiteDataStoreConfiguration::setOverridePersistentNotificationMinimumLifetimeForTesting):
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
* Source/WebKit/webpushd/WebPushDaemon.mm:
(WebPushD::WebPushDaemon::silentPushTimeout const):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PushAPI.mm:
((PushAPI, callNotificationClose)):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
(TestWebKitAPI::(WebPushDBuiltInTest, ShowAndGetNotifications)):
(TestWebKitAPI::(WebPushDBuiltInTest,
PushNotificationCloseImmediatelyAfterShowShouldFail)):
(TestWebKitAPI::(WebPushDBuiltInTest,
ImplicitSilentPushTimerCancelledOnShowingNotification)):
(TestWebKitAPI::(WebPushDBuiltInTest,
ImplicitSilentPushTimerIgnoredForInspectedContexts)):
(TestWebKitAPI::(WebPushDPushNotificationEventTest, Basic)):
* Tools/WebKitTestRunner/TestController.cpp:
(WTR::TestController::defaultWebsiteDataStore):
(WTR::TestController::grantNotificationPermission):
* Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformInitializeDataStore):
Originally-landed-as: 305413.488@rapid/safari-7624.2.5.110-branch
(46110060bb2a). rdar://176062762
Canonical link: https://commits.webkit.org/313831@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications