Skip to content
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

window.opener should be set to null to protect against malicious code #601

Closed
jayspadie opened this issue Oct 10, 2017 · 5 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@jayspadie
Copy link
Member

jayspadie commented Oct 10, 2017

monaco-editor version: 0.10.0
Browser: Any
OS: Any

Ctrl + clicking a recognized URL in Monaco opens it in a new tab using window.open() in OpenerService. To protect against malicious code in the linked site, particularly phishing attempts, the window.opener should be set to null to prevent the linked site from having access to change the location of the current page hosting Monaco.

Instead of:

window.open(resource.toString(true));

It should use something like:

var newTab = window.open();
if (newTab) {
    newTab.opener = null;
    newTab.location.href = resource.toString(true);
}

For additional information, see https://mathiasbynens.github.io/rel-noopener/ and add a link in Monaco to https://mathiasbynens.github.io/rel-noopener/malicious.html and observe that it redirects the page hosting Monaco.

@jayspadie
Copy link
Member Author

Hi @alexandrudima , many would consider this a security bug with a relatively easy fix. They will be asking me when it will be fixed, so I thought I would preemptively ask you if there's any plan for another Monaco release anytime soon, and if perhaps this could be included. Thanks.

@alexdima alexdima self-assigned this Oct 16, 2017
@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Oct 16, 2017
@alexdima alexdima added this to the On Deck milestone Oct 16, 2017
alexdima added a commit to microsoft/vscode that referenced this issue Oct 16, 2017
@alexdima
Copy link
Member

Thank you @jayspadie

Published monaco-editor@0.10.1 with the suggested fix.

alexdima added a commit to microsoft/vscode that referenced this issue Oct 24, 2017
@hawkerm
Copy link

hawkerm commented Nov 13, 2017

I'm running Monaco in a x-ms-webview, so 10.1.0 broke that as I wouldn't get the uri in the new window request anymore (only about:blank).

Saw there were some updates for this code path in the vscode tree to detect if it was a 'native' platform. Not sure if that'll detect the x-ms-webview case as well, but want to make sure this scenario can be covered too.

@alexdima
Copy link
Member

@hawkerm I've extracted your comment to #628

@hawkerm
Copy link

hawkerm commented Nov 14, 2017

@alexandrudima thanks a bunch!

jonas added a commit to scalameta/metabrowse that referenced this issue Feb 6, 2018
Fixes microsoft/monaco-editor#601
 - window.opener should be set to null to protect against malicious code
jonas added a commit to scalameta/metabrowse that referenced this issue Feb 6, 2018
Fixes microsoft/monaco-editor#601
 - window.opener should be set to null to protect against malicious code
@alexdima alexdima removed this from the On Deck milestone Apr 27, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants