cef icon indicating copy to clipboard operation
cef copied to clipboard

Redirected request trigger Access denied error

Open emmanuel-jorge opened this issue 1 year ago • 5 comments

Describe the bug Redirected request lose sec-ch-ua headers and trigger Access denied error

To Reproduce Steps to reproduce the behavior:

  1. Go to https://www.mouser.com/
  2. Enter a text in the search field
  3. Click on the icon loop or hit the enter key
  4. See the Access denied error

Expected behavior The redirected url may not trigger an error

Screenshots

Image

Versions:

  • OS: Ubuntu 22.04
  • CEF Version: 134.3.2 (134.0.6998.89)

Additional context The problem doesn't occur with Chromium native

emmanuel-jorge avatar Apr 17 '25 11:04 emmanuel-jorge

According to the Chromium implmentation, see content/browser/loader/navigation_url_loader_impl.cc and net/url_request/redirect_util.cc , removed headers may be set before merging modified headers. Actually, the following code may fix the issue:

diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc
index 09a4cf929..feb57a0b5 100644
--- a/libcef/browser/net_service/proxy_url_loader_factory.cc
+++ b/libcef/browser/net_service/proxy_url_loader_factory.cc
@@ -1147,10 +1147,10 @@ void InterceptedRequest::OnProcessRequestHeaders(
       id_, request_, redirect_url, modified_headers, removed_headers);
 
   if (!modified_headers->IsEmpty() || !removed_headers->empty()) {
-    request_.headers.MergeFrom(*modified_headers);
     for (const std::string& name : *removed_headers) {
       request_.headers.RemoveHeader(name);
     }
+    request_.headers.MergeFrom(*modified_headers);
   }
 }

See https://bitbucket.org/chromiumembedded/cef/pull-requests/895/

emmanuel-jorge avatar Apr 17 '25 12:04 emmanuel-jorge

I'm not able to reproduce this issue on Windows with M135 or M136.

Did you test a CEF build with your change and verify that it fixes the issue for you?

magreenblatt avatar Apr 17 '25 20:04 magreenblatt

I've just tested cefclient (windows build) downloaded from https://cef-builds.spotifycdn.com/cef_binary_135.0.21%2Bgd008a99%2Bchromium-135.0.7049.96_windows32_client.tar.bz2 and got the same result:

Image

emmanuel-jorge avatar Apr 18 '25 07:04 emmanuel-jorge

@emmanuel-jorge Please test a CEF build with your PR change and report if it fixes the issue for you.

magreenblatt avatar Apr 21 '25 19:04 magreenblatt

@emmanuel-jorge Ping

magreenblatt avatar Jul 24 '25 19:07 magreenblatt