Skip to content

Commit 85fdb4c

Browse files
committed
reintroduce security check on receiving message between frames.
1 parent a7b1a32 commit 85fdb4c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sim/webxdc.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class DevServerTransport implements Transport {
7575
request.onsuccess = (ev) => resolve(ev);
7676
request.onerror = (ev) => reject(ev);
7777
});
78-
}),
78+
})
7979
);
8080

8181
// we want to reload the window otherwise we won't take the
@@ -130,9 +130,13 @@ window.addEventListener("load", () => alterUi(getWebXdc().selfName, transport));
130130

131131
// listen to messages coming into iframe
132132
window.addEventListener("message", (event) => {
133-
// if (event.origin.indexOf("localhost:") === -1) {
134-
// return;
135-
// }
133+
const isAllowed =
134+
event.origin.indexOf("localhost:") !== -1 ||
135+
(location.host.endsWith(".webcontainer.io") &&
136+
event.origin.indexOf(".webcontainer.io") !== -1);
137+
if (!isAllowed) {
138+
return;
139+
}
136140
if (event.data === "reload") {
137141
window.location.reload();
138142
}

0 commit comments

Comments
 (0)