LibWeb: Make frames nesting-aware and disallow deep nesting

A Frame now knows about its nesting-level.

The FrameLoader checks whether the recursion level of the current
frame allows it to be displayed and if not doesn't even load the
requested resource.

The nesting-check is done on a per-URL-basis, so there can be many many
nested Frames as long as they have different URLs.
If there are however Frames with the same URL nested inside each other
we only allow this to happen 3 times.

This mitigates infinetely recursing <iframe>s in an HTML-document
crashing the browser with an OOM.
This commit is contained in:
Tobias Christiansen 2021-04-19 14:30:08 +02:00 committed by Andreas Kling
parent 9e49895bbf
commit 1b6824d296
Notes: sideshowbarker 2024-07-18 18:34:28 +09:00
4 changed files with 27 additions and 1 deletions

View file

@ -26,8 +26,11 @@ void FrameHostElement::inserted()
HTMLElement::inserted();
if (!is_connected())
return;
if (auto* frame = document().frame())
if (auto* frame = document().frame()) {
m_content_frame = Frame::create_subframe(*this, frame->main_frame());
m_content_frame->set_frame_nesting_levels(frame->frame_nesting_levels());
m_content_frame->register_frame_nesting(document().url());
}
}
Origin FrameHostElement::content_origin() const