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

Commit b20e3ab

Browse files
committed
feat(security): do not bootstrap from unknown schemes with a different origin
1 parent d1e4f57 commit b20e3ab

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Angular.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1485,12 +1485,14 @@ function allowAutoBootstrap(document) {
14851485
var src = document.currentScript.getAttribute('src');
14861486
var link = document.createElement('a');
14871487
link.href = src;
1488-
var scriptProtocol = link.protocol;
1489-
var docLoadProtocol = document.location.protocol;
1490-
if (docLoadProtocol === scriptProtocol) {
1488+
if (document.location.origin === link.origin) {
1489+
// Same-origin resources are always allowed, even for non-whitelisted schemes.
14911490
return true;
14921491
}
1493-
switch (scriptProtocol) {
1492+
// Disabled bootstrapping unless angular.js was loaded from a known scheme used on the web.
1493+
// This is to prevent angular.js bundled with browser extensions from being used to bypass the
1494+
// content security policy in web pages and other browser extensions.
1495+
switch (link.protocol) {
14941496
case 'http:':
14951497
case 'https:':
14961498
case 'ftp:':

0 commit comments

Comments
 (0)