Ada Indonesia Coy
Description
'Ada Indonesia Coy' just made an Electron web app with their logo on it. It has anti-pwn protection, but can you still pwn it?
Solution


Returns Payload submitted successfully!
So.. there's only 2 routes that are disclosed on frontend. Let's see what's going on in source code.
Dockerfile:
Dockerfile seems to be emulating screen? (wtf?) I guess it's expected since we were told it's Electron application.
Ada Indonesia Coy/ui/src/app/api/payload/route.ts is using subprocess to run our payload.
To clarify thing I wanted to see what the hell was happening, so I just compiled the electron app itself.

Hmm... nodeIntegration is set to false meaning no code execution via NodeJS (I think)

Our payload which we passed in frontend is getting passed to Electron as embed and then it ends up inside Electron App as HTML code.

We ideally want to get code execution, because challenge has a (SUID) binary /readflag which reads the flag for us.

Okkk.... we can inject any arbitrary html code we want
Note:
fullscreen: falseproperty was changed fromtruetofalseto make debug easier.
Seems promising! https://x.com/XssPayloads/status/1794627101892759809

Disabling nodeintegration can be bypassed by loading remote scripts in Preload #5173
webview tag is disabled by default and it's not enabled in config; https://www.electronjs.org/docs/latest/api/webview-tag
Not sure if this will be helpful or not, but if we redirect outside localhost (file://) we are able to access createNoteFrame function 🤔

While reading HackTricks: Electron Desktop Apps I noticed there's Tools section, so why not run a security check for more information?

The only access to electron object is via ipc called api

We can getConfig and setConfig. setConfig only allows accessing keys which exist inside config object; we can access embed, but not some imaginary x.

Another thing we have access to is __proto__, but JS isn't playing nice and I'm not able to influence it so far.
Prototype Pollution is effected on some degree, but that's all... no assignment yet.

Good talk: Silent Spring: Prototype Pollution Leads to Remote Code Execution in Node.js
I somewhat gave up on this route, because access seems not possible in this scenario. My idea behind this was to maybe hijack preload location and replace with rogue preload for RCE.
Black Hat USA 2022 -> ElectroVolt: Pwning Popular Desktop Apps While Uncovering New Attack Surface on Electron
First scenario described fits our case; sandbox is should have been disabled, but scratch that.
From Docs: Starting from Electron 20, the sandbox is enabled for renderer processes without any further configuration. If you want to disable the sandbox for a process, see the Disabling the sandbox for a single process section.

Source code for this path can be found in open source github repo: https://github1s.com/electron/electron/blob/main/lib/common/api/shell.ts
Unfortunately for us __webpack_require__ doesn't exist right out of the box.
Shown PoC to acquire this object fails
Btw https://www.ctfiot.com/72313.html goes over the presentation but in text format.
PDF: https://i.blackhat.com/USA-22/Thursday/US-22-Purani-ElectroVolt-Pwning-Popular-Desktop-Apps.pdf
X Et Et Challenge Writeup (TETCTF 2024) has a similar approach to exploit and what do you know, it's the author of the challenge.

At this point competition is done and there's only 2 PoC, no writeups. Above is from creator and second from another player.

The exploit seems to revolve around this piece of code:

Whenever we redirect we pop this note frame, and in there we can pass second XSS payload and gain RCE by disabling sandbox. That's the high level overview at least; I wanted to dive deeper, but not enough time.
Previously hint was dropped about setInterval being safe or not

TIL, there are not...: Are setTimeout and setInterval secure? #shorts

Anyway let's test the PoC:
For local testing (Windows) I used calc for better visual

The hosted application is served by Docker on Linux, so let's adjust payload like given by author.
Payload decompiled~
Not sure what
cid:stands for inhref, but it's almost same asjavascript:
Just my luck, resources are no longer able to be spawned.

RIP Flag
Last updated