-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: insecure iframe messaging #297
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,7 +28,8 @@ class PostMessageIframeTransport extends Transport { | |||||
}); | ||||||
} | ||||||
private messageHandler = (ev: MessageEvent) => { | ||||||
this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); | ||||||
if (ev.origin === this.uri) | ||||||
this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); | ||||||
} | ||||||
public connect(): Promise<any> { | ||||||
const urlRegex = /^(http|https):\/\/.*$/; | ||||||
|
@@ -46,7 +47,7 @@ class PostMessageIframeTransport extends Transport { | |||||
const prom = this.transportRequestManager.addRequest(data, null); | ||||||
const notifications = getNotifications(data); | ||||||
if (this.frame) { | ||||||
this.frame.postMessage((data as IJSONRPCData).request, "*"); | ||||||
this.frame.postMessage((data as IJSONRPCData).request, this.uri); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the origin can easily be derived as new URL(this.uri).origin |
||||||
this.transportRequestManager.settlePendingRequest(notifications); | ||||||
} | ||||||
return prom; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -36,7 +36,8 @@ class PostMessageTransport extends Transport { | |||||
} | ||||||
|
||||||
private messageHandler = (ev: MessageEvent) => { | ||||||
this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); | ||||||
if (ev.origin === this.uri) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.transportRequestManager.resolveResponse(JSON.stringify(ev.data)); | ||||||
} | ||||||
|
||||||
public connect(): Promise<any> { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.