Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4edd2d9

Browse files
mprobstpetebacondarwin
authored andcommitted
feat(security): explicitly whitelist URL schemes for bootstrap. (#15427)
Many browsers have some extension URL scheme. It is unclear how many of those have the security issue of allowing parser-inserted loads of extension URLs. To be conservative, this code whitelists the URL schemes that are known to be subject to CSP, i.e. the ones that are expected and safe.
1 parent 353e3a6 commit 4edd2d9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Angular.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,20 @@ function allowAutoBootstrap(document) {
14481448
link.href = src;
14491449
var scriptProtocol = link.protocol;
14501450
var docLoadProtocol = document.location.protocol;
1451-
if ((scriptProtocol === 'resource:' ||
1452-
scriptProtocol === 'chrome-extension:') &&
1453-
docLoadProtocol !== scriptProtocol) {
1454-
return false;
1451+
if (docLoadProtocol === scriptProtocol) {
1452+
return true;
1453+
}
1454+
switch (scriptProtocol) {
1455+
case 'http:':
1456+
case 'https:':
1457+
case 'ftp:':
1458+
case 'blob:':
1459+
case 'file:':
1460+
case 'data:':
1461+
return true;
1462+
default:
1463+
return false;
14551464
}
1456-
return true;
14571465
}
14581466

14591467
// Cached as it has to run during loading so that document.currentScript is available.

0 commit comments

Comments
 (0)