LibWeb+LibWebView+WebContent: Begin implementing simple site islotation

Site isolation is a common technique to reduce the chance that malicious
sites can access data from other sites. When the user navigates, we now
check if the target site is the same as the current site. If not, we
instruct the UI to perform the navigation in a new WebContent process.

The phrase "site" here is defined as the public suffix of the URL plus
one level. This means that navigating from "www.example.com" to
"sub.example.com" remains in the same process.

There's plenty of room for optimization around this. For example, we can
create a spare WebContent process ahead of time to hot-swap the target
site. We can also create a policy to keep the navigated-from process
around, in case the user quickly navigates back.
This commit is contained in:
Timothy Flynn 2025-03-09 11:40:34 -04:00 committed by Jelle Raaijmakers
parent a34f7a5bd1
commit 5810c8073e
Notes: github-actions[bot] 2025-03-11 11:11:49 +00:00
12 changed files with 94 additions and 0 deletions

View file

@ -62,6 +62,12 @@ void WebContentClient::did_paint(u64 page_id, Gfx::IntRect rect, i32 bitmap_id)
view->server_did_paint({}, bitmap_id, rect.size());
}
void WebContentClient::did_request_new_process_for_navigation(u64 page_id, URL::URL url)
{
if (auto view = view_for_page_id(page_id); view.has_value())
view->create_new_process_for_cross_site_navigation(url);
}
void WebContentClient::did_start_loading(u64 page_id, URL::URL url, bool is_redirect)
{
if (auto process = WebView::Application::the().find_process(m_process_handle.pid); process.has_value())