Overview

Low
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
ImpactInsufficient data validation in DevTools
DescriptionInsufficient data validation in DevTools
ComponentDevTools
Bug ClassLogic Error
Tracker406631048
Fix commit5381a527929f (devtools/devtools-frontend) +29/-1
CISA KEVNot listed
CreditedAmeen Basha M K
Disclosed2025-06-24

Files Changed

  • front_end/panels/network/NetworkLogView.test.ts
  • front_end/panels/network/NetworkLogView.ts
From 5381a527929f5a5842d00a57830950a195ba2488 Mon Sep 17 00:00:00 2001
From: Danil Somsikov <[email protected]>
Date: Wed, 21 May 2025 01:44:06 -0700
Subject: [PATCH] Also handle sole carriage return character (CR) when escaping curl command.

Bug: 406631048
Change-Id: I947dbf54d290ada4424bfbfcc817e1e7244bf438
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6573473
Auto-Submit: Danil Somsikov <[email protected]>
Commit-Queue: Danil Somsikov <[email protected]>
Reviewed-by: Benedikt Meurer <[email protected]>
Commit-Queue: Benedikt Meurer <[email protected]>
---

diff --git a/front_end/panels/network/NetworkLogView.test.ts b/front_end/panels/network/NetworkLogView.test.ts
index 614e5b7..b0d653e 100644
--- a/front_end/panels/network/NetworkLogView.test.ts
+++ b/front_end/panels/network/NetworkLogView.test.ts
@@ -181,6 +181,34 @@
     );
   });
 
+  it('generates a valid curl command when header values contain CRLF', async () => {
+    const request = createNetworkRequest(urlString`http://localhost`, {
+      requestHeaders: [{name: 'cookie', value: 'query=evil\r\n & cmd /c calc.exe \n\n'}],
+    });
+    assert.strictEqual(
+        await Network.NetworkLogView.NetworkLogView.generateCurlCommand(request, 'unix'),
+        'curl \'http://localhost\' -b $\'query=evil\\r\\n & cmd /c calc.exe \\n\\n\'',
+    );
+    assert.strictEqual(
+        await Network.NetworkLogView.NetworkLogView.generateCurlCommand(request, 'win'),
+        'curl ^\"http://localhost^\" -b ^\"query=evil^\n\n ^& cmd /c calc.exe ^\n\n^\n\n^\"',
+    );
+  });
+
+  it('generates a valid curl command when header values contain CR only', async () => {
+    const request = createNetworkRequest(urlString`http://localhost`, {
+      requestHeaders: [{name: 'cookie', value: 'query=evil\r & cmd /c calc.exe'}],
+    });
+    assert.strictEqual(
+        await Network.NetworkLogView.NetworkLogView.generateCurlCommand(request, 'unix'),
+        'curl \'http://localhost\' -b $\'query=evil\\r & cmd /c calc.exe\'',
+    );
+    assert.strictEqual(
+        await Network.NetworkLogView.NetworkLogView.generateCurlCommand(request, 'win'),
+        'curl ^\"http://localhost^\" -b ^\"query=evil^\n\n ^& cmd /c calc.exe^\"',
+    );
+  });
+
   const tests = (inScope: boolean) => () => {
     beforeEach(() => {
       networkLogView = createNetworkLogView();
diff --git a/front_end/panels/network/NetworkLogView.ts b/front_end/panels/network/NetworkLogView.ts
index 903695e..7e89058 100644
--- a/front_end/panels/network/NetworkLogView.ts
+++ b/front_end/panels/network/NetworkLogView.ts
@@ -2354,7 +2354,7 @@
               .replace(/"/g, '\\"')
               .replace(/[^a-zA-Z0-9\s_\-:=+~'\/.',?;()*`]/g, '^$&')
               .replace(/%(?=[a-zA-Z0-9_])/g, '%^')
-              .replace(/\r?\n/g, '^\n\n') +
+              .replace(/\r?\n|\r/g, '^\n\n') +
           encapsChars;
     }
 
Loading diff…

Original Bug Report

reported by [email protected]

Copy as Curl (CMD) Leads to code execution on windows

Steps to reproduce the problem

  1. Copy and run the payload in console (we can achieve it via html page too)
  2. Copy the request with copy as curl (windows)
  3. Paste on the windows cmd you can see calc triggers

Problem Description

HI Team, chrome latest on windows is vulnerable for code execution using copy as curl(cmd) which allows attacker to excute arbitrary code on victims (windows) machine

Issue ref: https://issues.chromium.org/issues/352651673 Similar issue was already reported to chrome and fixed (ref above) but now it was bypassed with my attached payload

Payload: fetch(“https://example.com/postit", { “credentials”: “omit”, “headers”: { “Accept-Language”: “en-US”, “Content-Type”: “text/plain”, }, “body”: “query=evil\n\ncmd /c calc1.exe\t\r\t calc2.exe \t calc3.exe \rcalc.exe\rcalc.exe\r calc7.exe \rt\r\t calc2.exe \t calc3.exe \r”, “method”: “POST”, });

I have attached the poc video for reference

Summary

Copy as Curl (CMD) Leads to code execution on windows

Custom Questions

Reporter credit:

Ameen Basha M K

Additional Data

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

View on issue tracker