Medium chrome Logic Error 📄 Reporter bug report 🔧 Commit mapped

Overview

Medium
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
ImpactInsufficient data validation in Extensions
DescriptionInsufficient data validation in Extensions
ComponentExtensions
Bug ClassLogic Error
Tracker376625003
Fix commitb50c1dbc6b70 (devtools/devtools-frontend) +9/-1
CISA KEVNot listed
CreditedAnonymous
Disclosed2025-01-14

Changed Functions

FunctionChangeNotes
if
front_end/models/extensions/ExtensionAPI.ts
modified

Files Changed

  • front_end/models/extensions/ExtensionAPI.ts
From b50c1dbc6b709196064bb26ee75b1ed6cee4f974 Mon Sep 17 00:00:00 2001
From: Danil Somsikov <[email protected]>
Date: Mon, 04 Nov 2024 12:09:10 +0000
Subject: [PATCH] Protect canAccessResource in DevTools API form prototype pollution

Bug: 376625003
Change-Id: Ib07a65da8f342c4727bceb6afcbd920bcfd07b81
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5987430
Reviewed-by: Philip Pfaffe <[email protected]>
Commit-Queue: Danil Somsikov <[email protected]>
---

diff --git a/front_end/models/extensions/ExtensionAPI.ts b/front_end/models/extensions/ExtensionAPI.ts
index 54afa52..a346408 100644
--- a/front_end/models/extensions/ExtensionAPI.ts
+++ b/front_end/models/extensions/ExtensionAPI.ts
@@ -1146,9 +1146,17 @@
     },
   };
 
+  const protocolGet = Object.getOwnPropertyDescriptor(URL.prototype, 'protocol')?.get;
+  function getProtocol(url: string): string {
+    if (!protocolGet) {
+      throw new Error('URL.protocol is not available');
+    }
+    return protocolGet.call(new URL(url));
+  }
+
   function canAccessResource(resource: APIImpl.ResourceData): boolean {
     try {
-      return extensionInfo.allowFileAccess || (new URL(resource.url)).protocol !== 'file:';
+      return extensionInfo.allowFileAccess || getProtocol(resource.url) !== 'file:';
     } catch (e) {
       return false;
     }
Loading diff…

Original Bug Report

reported by [email protected]

Local file access restrictions in chrome.devtools can be bypassed through prototype manipulation.

Steps to reproduce the problem

  1. Install the attached extension on macOS, and disable “Allow access to file URLs”.
  2. Open devtools on the new tab opened by the extension.
  3. Edit the /etc/hosts file highlighted in the sources panel, and save the changes.
  4. Observe that extension pops up an alert with the new contents of this file.

Problem Description

Various APIs under chrome.devtools use the canAccessResource function (https://chromium.googlesource.com/devtools/devtools-frontend/+/refs/heads/main/front_end/models/extensions/ExtensionAPI.ts#1149) for checking if local resources should be accessible to a given extension. However, the checks in this function can currently be entirely bypassed by overriding URL.prototype’s protocol getter as is done in the attached POC. Since there are no additional checks on the ExtensionServer side when adding event listeners through chrome.devtools.inspectedWindow.onResourceContentCommitted.addListener, an extension can gain access to local resources this way if the user interacts with such resources in the sources panel.

Additional Comments

Previous issues relating to this include:

Summary

Local file access restrictions in chrome.devtools can be bypassed through prototype manipulation.

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A

View on issue tracker