CodeQL 文档

禁用 Electron webSecurity

ID: js/disabling-electron-websecurity
Kind: problem
Security severity: 6.1
Severity: error
Precision: very-high
Tags:
   - security
   - frameworks/electron
   - external/cwe/cwe-79
Query suites:
   - javascript-code-scanning.qls
   - javascript-security-extended.qls
   - javascript-security-and-quality.qls

点击查看 CodeQL 仓库中的查询

Electron 默认情况下是安全的,通过同源策略,要求所有 JavaScript 和 CSS 代码都源自运行 Electron 应用程序的机器。将 webPreferences 对象的 webSecurity 属性设置为 false 将禁用同源策略。

强烈建议不要禁用同源策略。

建议

不要禁用 webSecurity

示例

以下示例显示了禁用 webSecurity 的情况。

const mainWindow = new BrowserWindow({
  webPreferences: {
    webSecurity: false
  }
})

这存在问题,因为它允许从其他域执行不安全的代码。

参考资料

  • ©GitHub, Inc.
  • 条款
  • 隐私