Everyone is panicking about ARTEX, but have you asked it nicely to go hack itself?

For those who have not had the pleasure, ARTEX is one of those fully autonomous "AI pentesting" panels. You seed it with a domain, wire up an LLM, and it happily plans and executes an entire attack chain all by itself. No human in the loop. What could possibly go wrong.

In a recent development, the scenario is as close to the real world as possible. A threat actor fires ARTEX towards your organization. In our case it is baldur.dk. (Related: Introducing the latest Microsoft IQ: Putting your organ...)

The goal is to get root on the threat actors machine and pwn ARTEX before it pwns us.

This is to showcase how fragile these scanners are and how simple misconceptions can make them hack themselves, and get a shell. (Related: Simple considerations for simple people building fancy ...)

For the first part we're going to focus on scope drift. This is when the scanner thinks something is in scope but in reality it is a completely different asset.

In normal authorized pentests you might test company A and company A has a stale DNS record that now points to a different company. If you run ARTEX or similar tools on a wildcard domain there is a very high chance that you hit a case like this and now you are actively not abiding to the rules of engagement. In our testing we saw how quickly it tried to reason about companies that looked like the target but was completely out of scope.

This is something we can abuse and simply make fake dns records, because surely they will sanity check for 127.0.0.1 right?

now a little bait in our index.html.

The domain we seed the campaign with.

After a bit, ARTEX starts enumerating domains and stumbles upon admin.baldur.dk and starts building tooling for scanning it.

Now ARTEX is attacking itself and the precious tokens are wasted, which is a good thing if it were a threat actor.

And while that is definitely funny, what we would like instead is to see if we can get a reverse shell on this pesky threat actor's ARTEX instance.

Recent findings suggest that turns out this is rather easy using some prompt injection trickery. Since ARTEX runs with a ton of tooling available for the agent, we can very easily abuse this.

So lets put out some bait at baldur.dk that the threat actors ARTEX instance will stumble upon:.

We planted this right in the top of baldur.dk/index.html:.

Everything about this is designed to look like a developer having a very bad day. Accidentally leaked keys but encrypted so it needs to run some code for decryption. Even an urgent reminder that the internal script server should never be public. The contents of ssh_key_decryption.sh is a reverse shell at first.

Now when we look at the tasks inside ARTEX we can see that it picks up the bait and starts a task for the bait:.

And we can also see that it fetches our payload:.

Sadly our research page is so great that ARTEX uses it as a reference for the attack we're attempting to do.

And also it does not fall for our trickery as it checks the payload before running it:.

"Is this a trap?" - You're goddamn right it is.

The model correctly concluded that piping a remote script straight into bash is a bad idea, and refused.

This however is easily bypassed by modifying our code a bit.

A lot of things to unfold in the above example. So here instead of serving the payload immediately, we provide a error message describing that you have to set an environment header first, and that header is timing bound and has to be piped to sh. Then we have a counter where we serve random error messages on the first couple of requests in the hopes that the LLM notes "fuck it, let's run the script".

Everything in the above example such as ERR_PIPE_SH_NOT_USED_SLOW_ERROR is ofcourse invented by us humans to make the model believe the case, and steer it towards our goal, without being too obvious.

And after some time, it does exactly what we predicted with the message actually let me just try the flow.

And here it attempts to run our payload:.

Congratulations threat actor. I now have a reverse shell on your machine.

But surely the scanner module is sandboxed away from the panel right?...

A quick look around the filesystem we just landed in:.

Nope. Everything is in the same container and we can just kill the panel, read secrets, exfiltrate data. We can also forge login tokens using the jwt signing key. Sandboxing is a basic 101 when you are doing offensive operations, which seems to be missing from ARTEX.

A few things worth writing down before you point an autonomous agent at anything:.

ARTEX is extremely immature as a proper tooling for pentests that follow a rule of engagement. If you do this, you will enter grey areas. Threat actors does not have these limitations which makes it great for them.

Sources indicate that ARTEX offers no sandboxing and everything is mashed together. There is many open source projects that are much more mature and implements this correctly. Strix is a good example.

If you have an agent that has hundreds of tools and use it to offensively target something I control (such as baldur.dk), rce is possible. There is a million other variants to these attacks. Sandbox, sandbox sandbox.

Disclaimer: no threat actor was harmed in the making of this post and everything was made in a controlled environment.

The "Pause task" is really wonky and the traffic will sometimes just continue with no clue on why and how, which is also a big no-no for engagements.

→ Read original article