Tags: python mongodb 


# mongo-foo

mongo-foo was a tiny cli key-value store written in python, backed by a mongodb.
It offered the commands `encrypt`, `decrypt`, `store` and `retrieve`, where `decrypt` was broken and only `store` and `retrieve` were being used.

After a successful `store`, you received a random id, which you could supply in `retrieve`.

There were no vulnerabilities in the service, only the mongodb was not binding to localhost only. Many teams did not notice, because the vulnbox had an unintended mongodb which was listening on only:


Since the host file of the vulnbox had two entries for localhost, one being, the other one being a different machine, the service used the mongodb on the different server for some teams. Since our mongo server's ip was one below our vulnbox' ip, we made an educated guess that this was the case for many teams, and started exploiting.

Exploiting this vulnerability was trivial - dump the database, decode the flag, submit.

Fixing this vulnerability was trivial - restrict connections to the mongodb.

Original writeup (https://github.com/ENOFLAG/writeups/blob/master/cinsectsctf2019/mongo-foo.md).