Swamp CTF 2025
Hey, fellow hackers! 🏴☠️
Droppin' some fresh writeups from Swamp CTF 2025! 🐊💥 Teamed up with my crew, sh3lldon3, and we dove deep into the swampy madness. Let’s get straight into the hacks and hijinks—no fluff, just flags. 🚀
Web
Contamination

Analysing the source code provided, we get to know that
Application has reverse proxy build using Ruby and has endpoint /api?action='getInfo'.
Backend is build using Python which has two endpoints "/api?action='getFlag'" and "/api?action='getInfo'".
We have to send POST requests with some json data.


Now, in order to get flag we have to:
Hit the "/api?action='getFlag'" endpoint at backend, so somehow pass action='getFlag' as Reverse Proxy accepts only action='getInfo' and gives error otherwise.
Cause error in parsing json data so that environment variables containing flag get exposed.
Exploit
Since the backend and reverse proxy is build using different languages, so there is difference in the handling parameters. Hence, we can do Parameter Pollution.
http://chals.swampctf.com:41234/api?action=getFlag&action=getInfo
This payload is able to bypass because whenever there are duplicate variables then Ruby will consider the last one while Python considers the first one.
Again, due to difference in the method of parsing JSON data, there are characters that are treated differently in two languages.
{ "data":"\q" }
Now, "\q" is not a valid special character.
When Ruby encounters it, then it simply consider it as two characters '\' and 'q' and therefore, pass it to the backend and gives no error.
Since, it is not a valid escape sequence, therefore it will cause parsing error in backend (JSONcode error by Python).
In this way, We successfully expose the environment variables and get the Flag.
Last updated