Skip to content

Commit 99eae21

Browse files
committed
Add FIXMEs for tsec violations
1 parent be0bb23 commit 99eae21

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

packages/auth/src/platform_browser/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ _setExternalJSProvider({
124124
// TODO: consider adding timeout support & cancellation
125125
return new Promise((resolve, reject) => {
126126
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.
127131
el.setAttribute('src', url);
128132
el.onload = resolve;
129133
el.onerror = e => {

packages/auth/src/platform_browser/load_js.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ describe('platform-browser/load_js', () => {
4444
loadJS(url: string): Promise<Event> {
4545
return new Promise((resolve, reject) => {
4646
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.
4749
el.setAttribute('src', url);
4850
el.onload = resolve;
4951
el.onerror = e => {
@@ -65,6 +67,8 @@ describe('platform-browser/load_js', () => {
6567

6668
// eslint-disable-next-line @typescript-eslint/no-floating-promises
6769
_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.
6872
expect(el.setAttribute).to.have.been.calledWith(
6973
'src',
7074
'http://localhost/url'

packages/database/src/realtime/BrowserPollConnection.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ export class FirebaseIFrameScriptHolder {
475475
const iframeContents = '<html><body>' + script + '</body></html>';
476476
try {
477477
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.
479480
this.myIFrame.doc.write(iframeContents);
480481
this.myIFrame.doc.close();
481482
} catch (e) {
@@ -718,6 +719,10 @@ export class FirebaseIFrameScriptHolder {
718719
const newScript = this.myIFrame.doc.createElement('script');
719720
newScript.type = 'text/javascript';
720721
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.
721726
newScript.src = url;
722727
// eslint-disable-next-line @typescript-eslint/no-explicit-any
723728
newScript.onload = (newScript as any).onreadystatechange =

packages/messaging/src/helpers/registerDefaultSw.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export async function registerDefaultSw(
2424
messaging: MessagingService
2525
): Promise<void> {
2626
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.
2828
messaging.swRegistration = await navigator.serviceWorker.register(
2929
DEFAULT_SW_PATH,
3030
{

0 commit comments

Comments
 (0)