firebase / firebase/firebase-js-sdk
iframe tag missing allow-same-origin, prevents loading SDK in iframe
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: Windows 10
* Browser version: Edge 90.0.818.51
* Firebase SDK version: 8.2.1
* Firebase Product: database
### [REQUIRED] Describe the problem
iframing a cross-domain page that invokes the firebase js sdk seems to result in an error.
```
BrowserPollConnection.ts:503 Sandbox access violation: Blocked a frame at "https://overlays.rtirl.com" from accessing a frame at "null". Both frames are sandboxed and lack the "allow-same-origin" flag.
BrowserPollConnection.ts:518 Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
at Function.ji.createIFrame_ (https://overlays.rtirl.com/__/firebase/8.2.9/firebase-database.js:1:110223)
at new ji (https://overlays.rtirl.com/__/firebase/8.2.9/firebase-database.js:1:112331)
at n (https://overlays.rtirl.com/__/firebase/8.2.9/firebase-database.js:1:105983)
at Qi.open (https://overlays.rtirl.com/__/firebase/8.2.9/firebase-database.js:1:107180)
at https://overlays.rtirl.com/__/firebase/8.2.9/firebase-database.js:1:117875
```
The relevant failure line is here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/database/src/realtime/BrowserPollConnection.ts#L500
#### Steps to reproduce:
Domain foo.com:
```
```
Domain bar.com:
```
firebase.initializeApp(...);
firebase.database()...
```
Should result in the above exception.
If I understand same-origin policies correctly, I believe the sdk just needs to add the `sandbox="allow-same-origin"` attr to the created iframe element?
Contributor guide
Assessment
This issue has not been assessed yet.