From 986c171d3fef5c5c060be77138d73e8c6aa32e77 Mon Sep 17 00:00:00 2001 From: failathon Date: Fri, 4 May 2018 01:54:29 -0400 Subject: [PATCH] First pass at addressing #1044 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: i. Only display secure (https) content ii. Enable context isolation in all renderers that display remote content v. Override and disable eval, which allows strings to be executed as code (…maybe. need someone to verify this work.) Also resolves: 1. allowRunningInsecureContent was set to true in WebView.js, against the recommendations of https://github.com/electron/electron/blob/master/docs/tutorial/security. md --- app/store/ServicesList.js | 4 ++-- app/ux/WebView.js | 2 +- app/view/add/Add.js | 6 +++--- app/view/main/Main.js | 2 +- electron/main.js | 3 +-- index.html | 4 ++++ resources/js/loadscreen.js | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index a9fb0405..6c7dcc28 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -125,7 +125,7 @@ Ext.define('Rambox.store.ServicesList', { ,logo: 'inbox.png' ,name: 'Inbox' ,description: locale['services[10]'] - ,url: 'http://inbox.google.com/?cid=imp' + ,url: 'https://inbox.google.com/?cid=imp' ,type: 'email' ,manual_notifications: true ,js_unread: 'function checkUnread(){updateBadge(document.getElementsByClassName("ss").length)}function updateBadge(a){a>=1?document.title="("+a+") "+originalTitle:document.title=originalTitle}var originalTitle=document.title;setInterval(checkUnread,3e3);' @@ -877,7 +877,7 @@ Ext.define('Rambox.store.ServicesList', { ,logo: 'mailru.png' ,name: 'Mail.Ru' ,description: 'Free voice and video calls, ICQ support, Odnoklassniki, VKontakte, Facebook, online games, free SMS.' - ,url: 'http://webagent.mail.ru/webim/agent/popup.html' + ,url: 'https://webagent.mail.ru/webim/agent/popup.html' ,type: 'email' }, { diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 51af59cf..241947c7 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -174,7 +174,7 @@ Ext.define('Rambox.ux.WebView',{ ,plugins: 'true' ,allowtransparency: 'on' ,autosize: 'on' - ,webpreferences: 'allowRunningInsecureContent=yes' //,nativeWindowOpen=yes + ,webpreferences: { contextIsolation:true } //,nativeWindowOpen=yes //,disablewebsecurity: 'on' // Disabled because some services (Like Google Drive) dont work with this enabled ,useragent: Ext.getStore('ServicesList').getById(me.record.get('type')).get('userAgent') ,preload: './resources/js/rambox-service-api.js' diff --git a/app/view/add/Add.js b/app/view/add/Add.js index 9c9730cc..fee06298 100644 --- a/app/view/add/Add.js +++ b/app/view/add/Add.js @@ -65,7 +65,7 @@ Ext.define('Rambox.view.add.Add',{ ,readOnly: me.edit ? (me.service.get('custom_domain') && me.service.get('url') === me.record.get('url') ? true : me.service.get('url').indexOf('___') === -1 && !me.service.get('custom_domain')) : me.record.get('url').indexOf('___') === -1 && me.record.get('custom_domain') ,allowBlank: false ,submitEmptyText: false - ,emptyText: me.record.get('url') === '___' ? 'http://' : '' + ,emptyText: me.record.get('url') === '___' ? 'https://' : '' ,vtype: me.record.get('url') === '___' ? 'url' : '' ,listeners: { specialkey: 'onEnter' } ,flex: 1 @@ -97,7 +97,7 @@ Ext.define('Rambox.view.add.Add',{ } ,changeHandler: function(cycleBtn, activeItem) { Ext.apply(cycleBtn.previousSibling(), { - emptyText: activeItem.custom ? 'http://' : ' ' + emptyText: activeItem.custom ? 'https://' : ' ' ,vtype: activeItem.custom ? 'url' : '' }); cycleBtn.previousSibling().applyEmptyText(); @@ -127,7 +127,7 @@ Ext.define('Rambox.view.add.Add',{ ,{ xtype: 'textfield' ,fieldLabel: locale['app.window[18]'] - ,emptyText: 'http://url.com/image.png' + ,emptyText: 'https://url.com/image.png' ,name: 'logo' ,vtype: me.record.get('type') === 'custom' ? 'url' : '' ,value: me.record.get('type') === 'custom' ? (me.edit ? me.record.get('logo') : '') : me.record.get('logo') diff --git a/app/view/main/Main.js b/app/view/main/Main.js index 34d9d1c3..7d4e323f 100644 --- a/app/view/main/Main.js +++ b/app/view/main/Main.js @@ -313,7 +313,7 @@ Ext.define('Rambox.view.main.Main', { text: locale['app.main[22]'] ,icon: 'resources/auth0.png' ,id: 'loginBtn' - ,tooltip: locale['app.main[23]']+'

'+locale['app.main[24]']+' Auth0 (http://auth0.com)' + ,tooltip: locale['app.main[23]']+'

'+locale['app.main[24]']+' Auth0 (https://auth0.com)' ,bind: { hidden: '{username}' } diff --git a/electron/main.js b/electron/main.js index d1d1620c..fe4c3317 100644 --- a/electron/main.js +++ b/electron/main.js @@ -156,8 +156,7 @@ function createWindow () { ,show: !config.get('start_minimized') ,acceptFirstMouse: true ,webPreferences: { - webSecurity: false - ,nodeIntegration: true + nodeIntegration: true ,plugins: true ,partition: 'persist:rambox' } diff --git a/index.html b/index.html index 1e96df1c..e519e77f 100644 --- a/index.html +++ b/index.html @@ -29,6 +29,10 @@ } } } + + window.eval = global.eval = function () { + throw new Error(`Sorry, this app does not support window.eval().`) + } diff --git a/resources/js/loadscreen.js b/resources/js/loadscreen.js index 049d2675..43a9e03e 100644 --- a/resources/js/loadscreen.js +++ b/resources/js/loadscreen.js @@ -1,6 +1,6 @@ /*! modernizr 3.2.0 (Custom Build) | MIT * * http://modernizr.com/download/?-csstransitions-prefixedcss !*/ -!function(e,n,t){function r(e,n){return typeof e===n}function o(){var e,n,t,o,i,s,a;for(var f in C)if(C.hasOwnProperty(f)){if(e=[],n=C[f],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;td;d++)if(v=e[d],h=N.style[v],f(v,"-")&&(v=a(v)),N.style[v]!==t){if(i||r(o,"undefined"))return s(),"pfx"==n?v:!0;try{N.style[v]=o}catch(g){}if(N.style[v]!=h)return s(),"pfx"==n?v:!0}return s(),!1}function h(e,n,t,o,i){var s=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+b.join(s+" ")+s).split(" ");return r(n,"string")||r(n,"undefined")?v(a,n,o,i):(a=(e+" "+P.join(s+" ")+s).split(" "),p(a,n,t))}function y(e,n,r){return h(e,t,t,n,r)}var g=[],C=[],x={_version:"3.2.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){C.push({name:e,fn:n,options:t})},addAsyncTest:function(e){C.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=x,Modernizr=new Modernizr;var _=n.documentElement,w="svg"===_.nodeName.toLowerCase(),S="Moz O ms Webkit",b=x._config.usePrefixes?S.split(" "):[];x._cssomPrefixes=b;var E=function(n){var r,o=prefixes.length,i=e.CSSRule;if("undefined"==typeof i)return t;if(!n)return!1;if(n=n.replace(/^@/,""),r=n.replace(/-/g,"_").toUpperCase()+"_RULE",r in i)return"@"+n;for(var s=0;o>s;s++){var a=prefixes[s],f=a.toUpperCase()+"_"+r;if(f in i)return"@-"+a.toLowerCase()+"-"+n}return!1};x.atRule=E;var P=x._config.usePrefixes?S.toLowerCase().split(" "):[];x._domPrefixes=P;var z={elem:l("modernizr")};Modernizr._q.push(function(){delete z.elem});var N={style:z.elem.style};Modernizr._q.unshift(function(){delete N.style}),x.testAllProps=h;var T=x.prefixed=function(e,n,t){return 0===e.indexOf("@")?E(e):(-1!=e.indexOf("-")&&(e=a(e)),n?h(e,n,t):h(e,"pfx"))};x.prefixedCSS=function(e){var n=T(e);return n&&s(n)};x.testAllProps=y,Modernizr.addTest("csstransitions",y("transition","all",!0)),o(),i(g),delete x.addTest,delete x.addAsyncTest;for(var j=0;jd;d++)if(v=e[d],h=N.style[v],f(v,"-")&&(v=a(v)),N.style[v]!==t){if(i||r(o,"undefined"))return s(),"pfx"==n?v:!0;try{N.style[v]=o}catch(g){}if(N.style[v]!=h)return s(),"pfx"==n?v:!0}return s(),!1}function h(e,n,t,o,i){var s=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+b.join(s+" ")+s).split(" ");return r(n,"string")||r(n,"undefined")?v(a,n,o,i):(a=(e+" "+P.join(s+" ")+s).split(" "),p(a,n,t))}function y(e,n,r){return h(e,t,t,n,r)}var g=[],C=[],x={_version:"3.2.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){C.push({name:e,fn:n,options:t})},addAsyncTest:function(e){C.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=x,Modernizr=new Modernizr;var _=n.documentElement,w="svg"===_.nodeName.toLowerCase(),S="Moz O ms Webkit",b=x._config.usePrefixes?S.split(" "):[];x._cssomPrefixes=b;var E=function(n){var r,o=prefixes.length,i=e.CSSRule;if("undefined"==typeof i)return t;if(!n)return!1;if(n=n.replace(/^@/,""),r=n.replace(/-/g,"_").toUpperCase()+"_RULE",r in i)return"@"+n;for(var s=0;o>s;s++){var a=prefixes[s],f=a.toUpperCase()+"_"+r;if(f in i)return"@-"+a.toLowerCase()+"-"+n}return!1};x.atRule=E;var P=x._config.usePrefixes?S.toLowerCase().split(" "):[];x._domPrefixes=P;var z={elem:l("modernizr")};Modernizr._q.push(function(){delete z.elem});var N={style:z.elem.style};Modernizr._q.unshift(function(){delete N.style}),x.testAllProps=h;var T=x.prefixed=function(e,n,t){return 0===e.indexOf("@")?E(e):(-1!=e.indexOf("-")&&(e=a(e)),n?h(e,n,t):h(e,"pfx"))};x.prefixedCSS=function(e){var n=T(e);return n&&s(n)};x.testAllProps=y,Modernizr.addTest("csstransitions",y("transition","all",!0)),o(),i(g),delete x.addTest,delete x.addAsyncTest;for(var j=0;j