Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #53 from saiya/openExternal-security-fix
Browse files Browse the repository at this point in the history
Reject non http(s) to open with shell
  • Loading branch information
blue0513 authored Jul 16, 2019
2 parents e9c54b9 + 7d5c276 commit 7093042
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ function registerToOpenUrl(webview, shell) {
webview.addEventListener('new-window', openExternalUrl);
}
function openExternalUrl(event){
shell.openExternal(event.url);
const url = event.url;
// https://electronjs.org/docs/tutorial/security#14-do-not-use-openexternal-with-untrusted-content
// Page 20 of https://www.blackhat.com/docs/us-17/thursday/us-17-Carettoni-Electronegativity-A-Study-Of-Electron-Security-wp.pdf
if (url.startsWith('http://') || url.startsWith('https://')) {
shell.openExternal(url);
}
};
function getChannelUrl(baseUrl, channel) {
const url = 'messages/' + channel;
Expand Down

0 comments on commit 7093042

Please sign in to comment.