🌐 Baby Injection
A detailed write-up of the Web challenge 'Baby Injection' from KnightCTF - 2025
Challenge Description
Initial Analysis
The site appears as follows:
The first thing that immediately stands out is the site’s URL:
|
|
In fact, that looks like a base64 encoding. Let’s try to decode it:
|
|
Decoding it, I got the following:
|
|
So, the decoded base64 seems to be reflected on the page, as we can see from the previous screenshot. It seems that since it mentions YAML, this could be a case of YAML insecure deserialization. In fact, looking at the request header, we can tell that everything is being executed with Python. Since Python has a library called PyYAML, we can exploit the deserialization process to achieve Remote Code Execution (RCE).
Exploit
I personally used this payload:
|
|
But many other payloads could have been used, such as:
|
|
Other payloads can be found on PayloadsAllTheThings. So, I simply encoded it in base64:
|
|
And that’s how I formed the URL for injecting the “ls -al” command:
|
|
By opening the URL, the command was executed on the server, listing the directories, and in doing so, I found the flag:
Automated Exploit
I also created an automated Python exploit for extracting the flag:
|
|