Sunshine CTF 2025 - AstroJIT AI (pwn)

This pwn challenge requires playing with the input of weights and biases of an AI chatbot to leak the flag.

Sunshine CTF 2025 - AstroJIT AI (pwn)
Photo by Dario Brönnimann / Unsplash

The Setup:

The challenge description is like an email from the CEO of a company with a few words being [censored]. We are also provided with a netcat server to connect to.

Challenge Description

Upon connecting, we receive the first prompt that asks for an API key to connect with the LLM or to enter as a guest. We enter as a guest and get the following options-

Challenge Prompts

Playing around a bit, we can understand that the bot can perform the following activities-
1. We can input training weights
2. We can talk to the AI, but it breaks the conversation after 3 prompts. Also, we need to first register the weights before talking to the bot
3. We can train the bot on 22 internal emails, while training we can see the email content with some content being censored.
4. View our weights

Using option 1, we see that we can provide weights as numbers and also as strings; thus, when providing malformed strings, we can see the error messages.

Error message for malformed input

One interesting piece of code here is the GetApiToken(). We can use code injection in the weights to view the API token being used. Using the below C# code -

{Weights.GetApiToken().ToString(), "0"}

And then choosing to debug the weights, we can see the API token as -
"Internal-EvilCorp-Api-Key-1337-Take-That-Hackers-This-Is-Not-A-Freebie"
Exiting and reconnecting to the API token, the challenge is accepted.

We can also see that privileged users can run dangerous queries, but asking the bot the flag still proved useless. Again, looking at the error message, we can see that a regex is blocking words like flag, sun, flagpole, etc. We can again use code injection in the weights to change the Regex of the RegexBlocker.

{(dynamic)(Biases.RegexBlocker = "(?!.)"), 0}

While the chatbot accepted the payload, I still couldn’t get it to leak the flag while chatting. I then decided to use option 3-> Train on internal emails, and while training, I realized that it had stopped censoring the emails, and we can see the flag in one of the emails as below
sun{evil-corp-one-uprising-at-a-time-folks-may-be-evil-but-do-not-get-burnt-out-just-burn-the-building-down-before-you-go-we-need-the-insurance-money}