File tree 4 files changed +15
-2
lines changed
auth/src/platform_browser
4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,10 @@ _setExternalJSProvider({
124
124
// TODO: consider adding timeout support & cancellation
125
125
return new Promise ( ( resolve , reject ) => {
126
126
const el = document . createElement ( 'script' ) ;
127
+ // Do not use setAttribute, since it can lead to XSS. Instead, use the safevalues library to
128
+ // safely set an attribute for a sanitized trustedResourceUrl. Since the trustedResourceUrl
129
+ // must be initialized from a template string literal, this could involve some heavy
130
+ // refactoring.
127
131
el . setAttribute ( 'src' , url ) ;
128
132
el . onload = resolve ;
129
133
el . onerror = e => {
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ describe('platform-browser/load_js', () => {
44
44
loadJS ( url : string ) : Promise < Event > {
45
45
return new Promise ( ( resolve , reject ) => {
46
46
const el = document . createElement ( 'script' ) ;
47
+ // FIXME: Do not use setAttribute, as this can lead to XSS. Instead, use the safevalues
48
+ // library, or get an exception for tests.
47
49
el . setAttribute ( 'src' , url ) ;
48
50
el . onload = resolve ;
49
51
el . onerror = e => {
@@ -65,6 +67,8 @@ describe('platform-browser/load_js', () => {
65
67
66
68
// eslint-disable-next-line @typescript-eslint/no-floating-promises
67
69
_loadJS ( 'http://localhost/url' ) ;
70
+ // FIXME: Do not use setAttribute, as this can lead to XSS. Instead, use the safevalues
71
+ // library, or get an exception for tests.
68
72
expect ( el . setAttribute ) . to . have . been . calledWith (
69
73
'src' ,
70
74
'http://localhost/url'
Original file line number Diff line number Diff line change @@ -475,7 +475,8 @@ export class FirebaseIFrameScriptHolder {
475
475
const iframeContents = '<html><body>' + script + '</body></html>' ;
476
476
try {
477
477
this . myIFrame . doc . open ( ) ;
478
- // FIXME: Use the safevalues library to sanitize this
478
+ // FIXME: Do not use document.write, since it can lead to XSS. Instead, use the safevalues
479
+ // library to sanitize the HTML in the iframeContents.
479
480
this . myIFrame . doc . write ( iframeContents ) ;
480
481
this . myIFrame . doc . close ( ) ;
481
482
} catch ( e ) {
@@ -718,6 +719,10 @@ export class FirebaseIFrameScriptHolder {
718
719
const newScript = this . myIFrame . doc . createElement ( 'script' ) ;
719
720
newScript . type = 'text/javascript' ;
720
721
newScript . async = true ;
722
+ // FIXME: We cannot assign an arbitrary URL to a script attached to the DOM, since it is
723
+ // at risk of XSS. We should use the safevalues library to create a safeScriptEl, and
724
+ // assign a sanitized trustedResourceURL to it. Since the URL must be a template string
725
+ // literal, this could require some heavy refactoring.
721
726
newScript . src = url ;
722
727
// eslint-disable-next-line @typescript-eslint/no-explicit-any
723
728
newScript . onload = ( newScript as any ) . onreadystatechange =
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export async function registerDefaultSw(
24
24
messaging : MessagingService
25
25
) : Promise < void > {
26
26
try {
27
- // FIXME: Use safevalues to register the service worker with a sanitized URL .
27
+ // FIXME: Use safevalues to register the service worker with a sanitized trustedResourceUrl .
28
28
messaging . swRegistration = await navigator . serviceWorker . register (
29
29
DEFAULT_SW_PATH ,
30
30
{
You can’t perform that action at this time.
0 commit comments