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

Webview does not set a content security policy #393

Open
mjbvz opened this issue Aug 16, 2019 · 3 comments · Fixed by #394
Open

Webview does not set a content security policy #393

mjbvz opened this issue Aug 16, 2019 · 3 comments · Fixed by #394
Labels
bug Something isn't working
Milestone

Comments

@mjbvz
Copy link

mjbvz commented Aug 16, 2019

Hi, I'm the developer of VS Code's webview API. I noticed that your extension seems to create a webview that does not set a content security policy. All webviews (even very simple ones) should set a content security policy. This helps limit the potential impact of content injections and is generally a good measure for defense in depth.

We've documented how to add a content security policy to VS Code webviews here. Please add the most restrictive content security policy possible to your webview. I am not aware of any immediate security issues with your extension but having a restrictive content security policy is important to help protect users of your extension.


Also note that in development mode, in VS Code 1.38 you should also see a warning if you create a webview that does not set a content security policy: microsoft/vscode#79248

@jdneo
Copy link
Member

jdneo commented Sep 5, 2019

Reopen it since we can have better way to fix this issue.

@jdneo jdneo reopened this Sep 5, 2019
@jdneo jdneo modified the milestones: 0.15.3, 0.15.4 Sep 5, 2019
@TantumErgo
Copy link

@jdneo Do you have details on the bug that needs fixing?

@jdneo
Copy link
Member

jdneo commented Sep 10, 2019

Hi @TantumErgo,

We now have three kinds of pages using webview to render: https://github.com/jdneo/vscode-leetcode/tree/master/src/webview.(Those named with xxxProvider) So far, we have the CSP meta-data, but it's not good enough since they all have content="default-src 'none';.

To better fix it, we can introduce the nonce attribute. One example is here: https://github.com/microsoft/vscode-extension-samples/blob/master/webview-sample/src/extension.ts#L184

Would you mind to take a look and make a contribution for this?

@jdneo jdneo modified the milestones: 0.15.4, backlog Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants