Skip to content

Commit 87e3e73

Browse files
lozy219Anu Aliyas
authored andcommitted
[Backport] CVE-2025-5281: Inappropriate implementation in BFCache
Manual cherry-pick of patch originally reviewed on https://chromium-review.googlesource.com/c/chromium/src/+/6550761: CCNS: make sure the cookie listener is added for prerendered document Previously the cookie listen is not added for the prerendered document because we only check IsInPrimaryMainFrame(), this will lead to serious security problem since we won't be notified when the cookie changes throughout the life time of that document. This CL fixes the check and update the browser test with prerendering case. Only a subset of the tests are updated but that should provide enough coverage for the scenarios we are caring about. Change-Id: Ia538f6f9e72c1096f1d0b4ed5ade7e2bd56e5523 Bug: 417215501 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6550761 Reviewed-by: Rakina Zata Amni <[email protected]> Commit-Queue: Mingyu Lei <[email protected]> Cr-Commit-Position: refs/heads/main@{#1462580} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/648697 Reviewed-by: Anu Aliyas <[email protected]> (cherry picked from commit eb9837f) Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/649947 Reviewed-by: Moss Heim <[email protected]>
1 parent 175615a commit 87e3e73

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

chromium/content/browser/renderer_host/navigation_request.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,19 +2783,21 @@ bool NavigationRequest::ShouldAddCookieChangeListener() {
27832783
// The `CookieChangeListener` will only be set up if all of these are true:
27842784
// (1) the navigation's protocol is HTTP(s).
27852785
// (2) we allow a document with `Cache-control: no-store` header to
2786-
// enter BFCache.
2786+
// enter back/forward.
27872787
// (3) the navigation is neither a same-document navigation nor a page
27882788
// activation, since in these cases, an existing `RenderFrameHost` will be
27892789
// used, and it would already have an existing listener, so we should skip the
27902790
// initialization.
2791-
// (4) the navigation is a primary main frame navigation, as the cookie
2792-
// change information will only be used in the inactive document control
2793-
// logic.
2791+
// (4) the navigation is a primary main frame navigation or it's for
2792+
// prerendering a main frame, as the cookie change information will only be
2793+
// used to determined if a page can be restored from back/forward cache, so
2794+
// subframe navigation can be ignored.
27942795
return frame_tree_node_->navigator()
27952796
.controller()
27962797
.GetBackForwardCache()
27972798
.should_allow_storing_pages_with_cache_control_no_store() &&
2798-
!IsPageActivation() && !IsSameDocument() && IsInPrimaryMainFrame() &&
2799+
!IsPageActivation() && !IsSameDocument() &&
2800+
(IsInPrimaryMainFrame() || IsInPrerenderedMainFrame()) &&
27992801
common_params_->url.SchemeIsHTTPOrHTTPS();
28002802
}
28012803

0 commit comments

Comments
 (0)