File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
packages/lit-dev-content/src/github Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ if (opener) {
28
28
} else {
29
29
message = { code} ;
30
30
}
31
+ // Note the default postMessage targetOrigin is "/"
32
+ // (https://html.spec.whatwg.org/multipage/web-messaging.html#posting-messages)
33
+ // so by leaving it unspecified we ensure that we will only post codes to our
34
+ // expected same-origin.
31
35
opener . postMessage ( message ) ;
32
36
} else {
33
37
const p = document . createElement ( 'p' ) ;
Original file line number Diff line number Diff line change @@ -122,8 +122,11 @@ const receiveCodeFromPopup = (
122
122
'message' ,
123
123
( event ) => {
124
124
// Note we must check source because our popup might not be the only
125
- // source of "message" events. This is also why we can't set "once".
126
- if ( event . source === popup ) {
125
+ // source of "message" events. This is also why we can't set "once". We
126
+ // also check the origin because we expect GitHub to redirect to the
127
+ // receiver page running on the same origin as this page; any other
128
+ // origin would be suspicious (or a misconfiguration).
129
+ if ( event . source === popup && event . origin === window . location . origin ) {
127
130
resolve ( event . data ) ;
128
131
abort ( ) ;
129
132
}
You can’t perform that action at this time.
0 commit comments