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?

Source: https://master-platform-bucket.s3.amazonaws.com/challenges/c368573e-38ba-4dcd-b8e7-e1ac349f6170/public.ziparrow-up-right

Solution

Ada.png
Ada-1.png

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.

Ada-2.png

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

Ada-3.png

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.

Ada-4.png

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

Ada-5.png

Okkk.... we can inject any arbitrary html code we want

Note: fullscreen: false property was changed from true to false to make debug easier.

Seems promising! https://x.com/XssPayloads/status/1794627101892759809arrow-up-right

Ada-6.png

Disabling nodeintegration can be bypassed by loading remote scripts in Preload #5173arrow-up-right

webview tag is disabled by default and it's not enabled in config; https://www.electronjs.org/docs/latest/api/webview-tagarrow-up-right

Not sure if this will be helpful or not, but if we redirect outside localhost (file://) we are able to access createNoteFrame function 🤔

Ada Indonesia Coy.png

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

Ada Indonesia Coy-1.png

The only access to electron object is via ipc called api

Ada Indonesia Coy-2.png

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

Ada Indonesia Coy-3.png

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.

Ada Indonesia Coy-4.png

Good talk: Silent Spring: Prototype Pollution Leads to Remote Code Execution in Node.jsarrow-up-right

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 2022arrow-up-right -> ElectroVolt: Pwning Popular Desktop Apps While Uncovering New Attack Surface on Electronarrow-up-right

First scenario described fits our case; sandbox is should have been disabled, but scratch that.

From Docsarrow-up-right: 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 processarrow-up-right section.

Ada Indonesia Coy-5.png

Source code for this path can be found in open source github repo: https://github1s.com/electron/electron/blob/main/lib/common/api/shell.tsarrow-up-right

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.htmlarrow-up-right goes over the presentation but in text format.

PDF: https://i.blackhat.com/USA-22/Thursday/US-22-Purani-ElectroVolt-Pwning-Popular-Desktop-Apps.pdfarrow-up-right

X Et Et Challenge Writeup (TETCTF 2024)arrow-up-right has a similar approach to exploit and what do you know, it's the author of the challenge.

Ada Indonesia Coy-6.png

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

Ada Indonesia Coy-7.png

The exploit seems to revolve around this piece of code:

Ada Indonesia Coy-8.png

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

Ada Indonesia Coy-9.png

TIL, there are not...: Are setTimeout and setInterval secure? #shortsarrow-up-right

Ada Indonesia Coy-10.png

Anyway let's test the PoC:

For local testing (Windows) I used calc for better visual

Ada Indonesia Coy-11.png

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 in href, but it's almost same as javascript:

Just my luck, resources are no longer able to be spawned.

Ada Indonesia Coy-12.png

RIP Flag

Last updated