Skip to content

Commit 8564770

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
Normalize URLs first before checking for UNC path
[email protected] Fixed: 468027781 Change-Id: I8d7c602657e45a8110e695ab4a91b9c4ef6f62aa Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7255782 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]> Auto-Submit: Simon Zünd <[email protected]>
1 parent 722e1f9 commit 8564770

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

front_end/core/host/ResourceLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async function fetchToString(url: string): Promise<string> {
206206

207207
function canBeRemoteFilePath(url: string): boolean {
208208
try {
209-
const urlObject = new URL(url);
209+
const urlObject = new URL(new URL(url).toString()); // Normalize first.
210210
return urlObject.protocol === 'file:' && urlObject.host !== '';
211211
} catch {
212212
return false;

front_end/core/sdk/PageResourceLoader.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ describe('PageResourceLoader', () => {
204204
assert.include(message, 'remote file');
205205
});
206206

207+
it('blocks UNC file paths with path traversal on Windows with the default setting', async () => {
208+
if (!Host.Platform.isWin()) {
209+
return;
210+
}
211+
212+
const {loader} = setup({maxConcurrentLoads: 1});
213+
214+
const message =
215+
await loader.loadResource(urlString`file:///abc\\..//smb-server/share/source-map.js.map'`, initiator)
216+
.catch(e => e.message);
217+
218+
assert.include(message, 'remote file');
219+
});
220+
207221
it('allows remote file paths with the setting enabled', async () => {
208222
const {loader, settings} = setup({maxConcurrentLoads: 1});
209223
sinon.stub(Host.InspectorFrontendHost.InspectorFrontendHostInstance, 'loadNetworkResource')

0 commit comments

Comments
 (0)