Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(history): block sandboxed traversal of ancestor entries

ldm093c1a3422083
diff --git a/moli-renderer-v8/src/context_bootstrap/location_navigation.rs b/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
index 8aa564beb..bd0ac6016 100644
--- a/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
@@ -643,6 +643,14 @@ fn sandbox_blocks_ancestor_or_top_location_navigation<'s>(
else {
return false;
};
+ sandbox_blocks_ancestor_or_top_navigation_from_source(scope, source_handle, owner)
+}
+
+pub(super) fn sandbox_blocks_ancestor_or_top_navigation_from_source<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ source_handle: crate::document_runtime::DomHandle,
+ owner: v8::Local<'s, v8::Object>,
+) -> bool {
let Some(host_ptr) = context_host_ptr_for_navigation_owner(scope, owner)
.or_else(|| context_host_ptr_from_global_bridge(scope))
else {
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_traversal.rs b/moli-renderer-v8/src/context_bootstrap/navigation_traversal.rs
index 1f9abd047..65cfb8c8c 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_traversal.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_traversal.rs
@@ -504,6 +504,22 @@ fn history_traverse<'s>(
queue_browser_owned_top_level_history_traversal(scope, history, delta);
return;
};
+ let source_owner = runtime_window_owner(scope, history);
+ if let Some(source_handle) =
+ super::navigation_window::child_browsing_context_handle_for_runtime_owner(
+ scope,
+ source_owner,
+ )
+ && plan.targets.iter().any(|target| {
+ super::location_navigation::sandbox_blocks_ancestor_or_top_navigation_from_source(
+ scope,
+ source_handle,
+ target.owner,
+ )
+ })
+ {
+ return;
+ }
super::navigation_traversal_coordinator::queue_plan(scope, plan);
}