Webview 漏洞修復
·2 分鐘閱讀
已發現一個漏洞,允許在某些停用 Node.js 整合的 Electron 應用程式中重新啟用它。此漏洞已分配 CVE 識別碼 CVE-2018-1000136。
受影響的應用程式
如果所有下列條件都成立,則應用程式會受影響
- 在 Electron 1.7、1.8 或 2.0.0-beta 上執行
- 允許執行任意遠端程式碼
- 停用 Node.js 整合
- 未在其 webPreferences 中明確宣告
webviewTag: false
- 未啟用
nativeWindowOption
選項 - 未攔截
new-window
事件,並且未使用提供的選項標籤手動覆寫event.newGuest
雖然這似乎是少數的 Electron 應用程式,我們仍鼓勵所有應用程式升級以作為預防措施。
緩解措施
此漏洞已在今天的 1.7.13、1.8.4 和 2.0.0-beta.5 版本中修復。
無法升級其應用程式 Electron 版本的開發人員可以使用下列程式碼來緩解此漏洞
app.on('web-contents-created', (event, win) => {
win.on(
'new-window',
(event, newURL, frameName, disposition, options, additionalFeatures) => {
if (!options.webPreferences) options.webPreferences = {};
options.webPreferences.nodeIntegration = false;
options.webPreferences.nodeIntegrationInWorker = false;
options.webPreferences.webviewTag = false;
delete options.webPreferences.preload;
},
);
});
// and *IF* you don't use WebViews at all,
// you might also want
app.on('web-contents-created', (event, win) => {
win.on('will-attach-webview', (event, webPreferences, params) => {
event.preventDefault();
});
});
更多資訊
此漏洞由 Trustwave SpiderLabs 的 Brendan Scarvell 發現並負責任地回報給 Electron 專案。
若要瞭解更多關於確保 Electron 應用程式安全的最佳實務,請參閱我們的安全教學。
若要回報 Electron 中的漏洞,請發送電子郵件至 security@electronjs.org。
請加入我們的電子郵件清單以接收關於發行版本和安全性更新的資訊。