1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 13:37:10 +09:00

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

@ -14,6 +14,7 @@
#include <LibWeb/Infra/Strings.h>
#include <LibWebView/Application.h>
#include <LibWebView/HelperProcess.h>
#include <LibWebView/SiteIsolation.h>
#include <LibWebView/UserAgent.h>
#include <LibWebView/ViewImplementation.h>
@ -89,6 +90,21 @@ u64 ViewImplementation::page_id() const
return m_client_state.page_index;
}
void ViewImplementation::create_new_process_for_cross_site_navigation(URL::URL const& url)
{
if (m_client_state.client)
client().async_close_server();
initialize_client();
VERIFY(m_client_state.client);
// Don't keep a stale backup bitmap around.
m_backup_bitmap = nullptr;
handle_resize();
load(url);
}
void ViewImplementation::server_did_paint(Badge<WebContentClient>, i32 bitmap_id, Gfx::IntSize size)
{
if (m_client_state.back_bitmap.id == bitmap_id) {