
Electronegativity는 Electron 애플리케이션에서 잘못된 설정과 보안 안티패턴을 식별하는 도구입니다.
⚠️ 이 프로젝트는 아카이브되었습니다 ⚠️
대신 ElectroNG를 사용하세요!
Electronegativity는 Electron 기반 애플리케이션의 잘못된 구성과 보안 안티패턴을 식별하는 도구입니다.
AST 및 DOM 파싱을 활용하여 "Electron Security Checklist - A Guide for Developers and Auditors" 백서에 설명된 보안 관련 구성 요소를 찾습니다.
소프트웨어 개발자와 보안 감사자는 이 도구를 사용하여 Electron을 사용하는 애플리케이션을 개발할 때 잠재적인 취약점과 구현 버그를 탐지하고 완화할 수 있습니다. Electronegativity를 사용할 때는 여전히 Electron (비)보안에 대한 충분한 이해가 필요합니다. 도구가 탐지하는 일부 잠재적 문제는 수동 조사가 필요하기 때문입니다.
Electron 보안에 관심이 있다면 BlackHat 2017 연구 Electronegativity - A Study of Electron Security를 살펴보고 Doyensec의 블로그를 주목해 주세요.

주요 릴리스는 NPM에 푸시되며 다음을 사용하여 간단히 설치할 수 있습니다:
$ npm install @doyensec/electronegativity -g
$ electronegativity -h
| 옵션 | 설명 |
|---|---|
| -V | 버전 번호 출력 |
| -i, --input | 입력 (디렉터리, .js, .html, .asar) |
| -l, --checks | 지정된 검사만 실행, csv 형식으로 전달 |
| -x, --exclude-checks | 지정된 검사 목록 건너뛰기, csv 형식으로 전달 |
| -s, --severity | 지정된 심각도 이상의 결과만 반환 |
| -c, --confidence | 지정된 신뢰도 이상의 결과만 반환 |
| -o, --output <filename[.csv or .sarif]> | 결과를 csv 또는 sarif 형식의 파일로 저장 |
| -r, --relative | 파일에 대해 상대 경로 표시 |
| -v, --verbose | 결과에 대한 설명 표시, 기본값은 true |
| -u, --upgrade | Electron 업그레이드 검사 실행, 예: -u 7..8은 Electron 7에서 8로의 업그레이드 검사 |
| -e, --electron-version | 감지된 버전을 재정의하여 설정된 Electron 버전을 가정, 예: -e 7.0.0은 Electron 7을 사용하는 것으로 처리 |
| -p, --parser-plugins | 사용할 추가 파서 플러그인을 쉼표로 구분하여 지정, 예: -p optionalChaining |
| -h, --help | 사용 정보 출력 |
Electron 앱이 포함된 디렉터리에서 electronegativity를 사용하여 문제를 찾기:
$ electronegativity -i /path/to/electron/app
asar 아카이브의 문제를 찾기 위해 electronegativity를 사용하고 결과를 csv 파일에 저장:
$ electronegativity -i /path/to/asar/archive -o result.csv
Electron의 한 버전에서 다른 버전으로 업그레이드할 때 전기음성도를 사용하여 호환성 깨지는 변경 사항을 찾는 방법:
$ electronegativity -i /path/to/electron/app -v -u 7..8
참고: "JavaScript heap out of memory" 치명적 오류가 발생하는 경우, node --max-old-space-size=4096 electronegativity -i /path/to/asar/archive -o result.csv를 사용하여 node를 실행할 수 있습니다.
Electronegativity를 사용하면 eng-disable 주석을 통해 개별 검사를 비활성화할 수 있습니다. 예를 들어, 특정 검사가 코드의 한 줄을 무시하도록 하려면 다음과 같이 비활성화할 수 있습니다:
const res = eval(safeVariable); /* eng-disable DANGEROUS_FUNCTIONS_JS_CHECK */
<webview src="https://doyensec.com/" enableblinkfeatures="DangerousFeature"></webview> <!-- eng-disable BLINK_FEATURES_HTML_CHECK -->
eng-disable 인라인 주석(// eng-disable, /* eng-disable */, <!-- eng-disable -->)은 해당 줄에 대해서만 지정된 검사를 비활성화합니다. 또한 snake case ID(DANGEROUS_FUNCTIONS_JS_CHECK) 또는 construct 이름(dangerousFunctionsJSCheck)을 사용하여 여러 검사 이름을 지정할 수도 있습니다:
shell.openExternal(eval(safeVar)); /* eng-disable OPEN_EXTERNAL_JS_CHECK DANGEROUS_FUNCTIONS_JS_CHECK */
.js 또는 .html 파일 상단의 코드 앞에 eng-disable 지시문을 넣으면 해당 파일 전체에 대해 전달된 검사가 비활성화됩니다.
eng-disable 주석에 관한 참고 사항v1.9.0 이전에는 코드 주석을 사용하여 전역 검사를 비활성화할 수 없었습니다. 여전히 구 버전을 사용 중이라면 -x CLI 인수를 사용하여 검사 목록을 수동으로 비활성화하십시오(예: -x LimitNavigationJsCheck,PermissionRequestHandlerJsCheck,CSPGlobalCheck).
주석 사용은 CSP_GLOBAL_CHECK 또는 AVAILABLE_SECURITY_FIXES_GLOBAL_CHECK와 같은 일부 상위 수준 검사에는 적용되지 않을 수 있습니다. 이러한 경우에는 -x 플래그를 사용하여 스캔에서 특정 검사를 제외할 수 있습니다.
Electronegativity Action은 GitHub CI/CD 파이프라인의 일부로 실행되어 "코드 스캐닝 경고"를 받을 수 있습니다:

CLI와 유사한 옵션을 사용하여 프로그래밍 방식으로 electronegativity를 사용할 수도 있습니다:
const run = require('@doyensec/electronegativity')
// or: import run from '@doyensec/electronegativity';
run({
// input (directory, .js, .html, .asar)
input: '/path/to/electron/app',
// save the results to a file in csv or sarif format (optional)
output: '/path/for/output/file',
// true to save output as sarif, false to save as csv (optional)
isSarif: false,
// only run the specified checks (optional)
customScan: ['dangerousfunctionsjscheck', 'remotemodulejscheck'],
// only return findings with the specified level of severity or above (optional)
severitySet: 'high',
// only return findings with the specified level of confidence or above (optional)
confidenceSet: 'certain',
// show relative path for files (optional)
isRelative: false,
// run Electron upgrade checks, eg -u 7..8 to check upgrade from Electron 7 to 8 (optional)
electronUpgrade: '7..8',
// assume the set Electron version, overriding the detected one
electronVersion: '5.0.0',
// use additional parser plugins
parserPlugins: ['optionalChaining']
})
.then(result => console.log(result))
.catch(err => console.error(err));
결과에는 전역 및 원자적 검사의 개수, 파싱 중 발생한 오류, 그리고 발견된 이슈 배열이 포함되며, 다음과 같습니다:
{
globalChecks: 6,
atomicChecks: 36,
errors: [
{
file: 'ts/main/main.ts',
sample: 'shell.openExternal(url);',
location: { line: 328, column: 4 },
id: 'OPEN_EXTERNAL_JS_CHECK',
description: 'Review the use of openExternal',
properties: undefined,
severity: { value: 2, name: 'MEDIUM', format: [Function: format] },
confidence: { value: 0, name: 'TENTATIVE', format: [Function: format] },
manualReview: true,
shortenedURL: 'https://git.io/JeuMC'
},
{
file: 'ts/main/main.ts',
sample: 'const popup = new BrowserWindow(options);',
location: { line: 340, column: 18 },
id: 'CONTEXT_ISOLATION_JS_CHECK',
description: 'Review the use of the contextIsolation option',
properties: undefined,
severity: { value: 3, name: 'HIGH', format: [Function: format] },
confidence: { value: 1, name: 'FIRM', format: [Function: format] },
manualReview: false,
shortenedURL: 'https://git.io/Jeu1p'
}
]
}
이 프로젝트에 기여할 계획이 있으시다면 CONTRIBUTING.md를 확인해 주세요.
Electronegativity는 많은 기여자들의 노력 덕분에 만들어질 수 있었습니다.
이 프로젝트는 Doyensec LLC의 후원을 받았습니다.
저희에게 의뢰하여 여러분의 Electron.js 애플리케이션을 공격해 보세요!