Skip to content

Commit

Permalink
[iOS] Remove sandbox extension of Frontboard XPC service
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264969
rdar://118521486

Reviewed by Brent Fulgham.

We currently create a sandbox extension for this service when uploading files and enabling
Accessibility. Local testing has found no regressions when blocking this service.

* Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.WebContent.sb.in:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

Canonical link: https://commits.webkit.org/270982@main
  • Loading branch information
pvollan committed Nov 20, 2023
1 parent 5a94eb2 commit 1f69465
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@
"com.apple.preferences.sounds")

(deny mach-lookup
(global-name "com.apple.frontboard.systemappservices") ; -[UIViewServiceInterface _createProcessAssertion] -> SBSProcessIDForDisplayIdentifier()
)
(global-name "com.apple.frontboard.systemappservices")) ; -[UIViewServiceInterface _createProcessAssertion] -> SBSProcessIDForDisplayIdentifier()

#if !ENABLE(CARENDERSERVER_BLOCKING_IN_WEBCONTENT)
(with-filter (require-not (state-flag "EnableExperimentalSandbox"))
Expand Down Expand Up @@ -932,7 +931,6 @@

(define (mach-extension-list)
(global-name
"com.apple.frontboard.systemappservices"
"com.apple.iconservices"
"com.apple.mobileassetd.v2"
"com.apple.mobilegestalt.xpc"))
Expand Down
6 changes: 1 addition & 5 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8484,14 +8484,10 @@ void WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vect
SandboxExtension::Handle frontboardServicesSandboxExtension, iconServicesSandboxExtension;
auto auditToken = m_process->auditToken();
auto machBootstrapHandle = SandboxExtension::createHandleForMachBootstrapExtension();
#if HAVE(FRONTBOARD_SYSTEM_APP_SERVICES)
if (auto handle = SandboxExtension::createHandleForMachLookup("com.apple.frontboard.systemappservices"_s, auditToken))
frontboardServicesSandboxExtension = WTFMove(*handle);
#endif
if (auto handle = SandboxExtension::createHandleForMachLookup("com.apple.iconservices"_s, auditToken))
iconServicesSandboxExtension = WTFMove(*handle);

send(Messages::WebPage::DidChooseFilesForOpenPanelWithDisplayStringAndIcon(fileURLs, displayString, iconData ? iconData->dataReference() : IPC::DataReference(), WTFMove(machBootstrapHandle), WTFMove(frontboardServicesSandboxExtension), WTFMove(iconServicesSandboxExtension)));
send(Messages::WebPage::DidChooseFilesForOpenPanelWithDisplayStringAndIcon(fileURLs, displayString, iconData ? iconData->dataReference() : IPC::DataReference(), WTFMove(machBootstrapHandle), WTFMove(iconServicesSandboxExtension)));

RefPtr openPanelResultListener = std::exchange(m_openPanelResultListener, nullptr);
openPanelResultListener->invalidate();
Expand Down
18 changes: 1 addition & 17 deletions Source/WebKit/WebProcess/WebPage/WebPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5427,7 +5427,7 @@ void WebPage::changeSelectedIndex(int32_t index)
}

#if PLATFORM(IOS_FAMILY)
void WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>& files, const String& displayString, const IPC::DataReference& iconData, WebKit::SandboxExtension::Handle&& machBootstrapHandle, SandboxExtension::Handle&& frontboardServicesSandboxExtensionHandle, SandboxExtension::Handle&& iconServicesSandboxExtensionHandle)
void WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>& files, const String& displayString, const IPC::DataReference& iconData, WebKit::SandboxExtension::Handle&& machBootstrapHandle, SandboxExtension::Handle&& iconServicesSandboxExtensionHandle)
{
if (!m_activeOpenPanelResultListener)
return;
Expand All @@ -5438,15 +5438,6 @@ void WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<St
ASSERT_UNUSED(consumed, consumed);
}

#if HAVE(FRONTBOARD_SYSTEM_APP_SERVICES)
auto frontboardServicesSandboxExtension = SandboxExtension::create(WTFMove(frontboardServicesSandboxExtensionHandle));
if (frontboardServicesSandboxExtension) {
bool consumed = frontboardServicesSandboxExtension->consume();
ASSERT_UNUSED(consumed, consumed);
}
RELEASE_ASSERT(!sandbox_check(getpid(), "mach-lookup", static_cast<enum sandbox_filter_type>(SANDBOX_FILTER_GLOBAL_NAME | SANDBOX_CHECK_NO_REPORT), "com.apple.frontboard.systemappservices"));
#endif

auto iconServicesSandboxExtension = SandboxExtension::create(WTFMove(iconServicesSandboxExtensionHandle));
if (iconServicesSandboxExtension) {
bool consumed = iconServicesSandboxExtension->consume();
Expand All @@ -5466,13 +5457,6 @@ void WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<St
m_activeOpenPanelResultListener->didChooseFilesWithDisplayStringAndIcon(files, displayString, icon.get());
m_activeOpenPanelResultListener = nullptr;

#if HAVE(FRONTBOARD_SYSTEM_APP_SERVICES)
if (frontboardServicesSandboxExtension) {
bool revoked = frontboardServicesSandboxExtension->revoke();
ASSERT_UNUSED(revoked, revoked);
}
#endif

if (iconServicesSandboxExtension) {
bool revoked = iconServicesSandboxExtension->revoke();
ASSERT_UNUSED(revoked, revoked);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/WebPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public IP
void didCancelForOpenPanel();

#if PLATFORM(IOS_FAMILY)
void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData, WebKit::SandboxExtension::Handle&&, WebKit::SandboxExtension::Handle&&, WebKit::SandboxExtension::Handle&&);
void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData, WebKit::SandboxExtension::Handle&&, WebKit::SandboxExtension::Handle&&);
#endif

#if ENABLE(SANDBOX_EXTENSIONS)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType

# Open panel.
#if PLATFORM(IOS_FAMILY)
DidChooseFilesForOpenPanelWithDisplayStringAndIcon(Vector<String> fileURLs, String displayString, IPC::DataReference iconData, WebKit::SandboxExtension::Handle machBootstrapHandle, WebKit::SandboxExtension::Handle frontboardServicesSandboxExtension, WebKit::SandboxExtension::Handle iconServicesSandboxExtension)
DidChooseFilesForOpenPanelWithDisplayStringAndIcon(Vector<String> fileURLs, String displayString, IPC::DataReference iconData, WebKit::SandboxExtension::Handle machBootstrapHandle, WebKit::SandboxExtension::Handle iconServicesSandboxExtension)
#endif
DidChooseFilesForOpenPanel(Vector<String> fileURLs, Vector<String> replacementURLs)
DidCancelForOpenPanel()
Expand Down

0 comments on commit 1f69465

Please sign in to comment.