Web - ProxyAsAService¶
The web is proxying requests to Reddit.
Importantly, there is also a debug endpoint /debug/environment that dumps the ENV. Which is good, as the flag is there (I know it from Dockerfile).
However, the problem is that the endpoint can be only invoked from localhost (is_from_localhost guard function). So, I need to get around it. Perhaps the proxy will help as it is local to itself.
Open Redirect¶
First, I need to call the proxy and not Reddit. By looking at the code I see the hardcoded url as follows:
This is vulnerable to open redirect due to the missing tailing slash.
So if i call the proxy in the following way I can proxy anywhere:
The @ makes all the prewious recogined as credentials.
But, trying the following returns 403:
Note that the used port is the local port it got from Dockerfile and build-docker.sh.
Bypassing blacklist¶
The application have some restricted urls.
That blocked the 127.0.0.1.
According to code the request and response cannot be on the blacklisted urls:
So I need to call the localhost somewhat differently. I can use 0.0.0.0. See: https://unix.stackexchange.com/questions/419880/connecting-to-ip-0-0-0-0-succeeds-how-why/419881#419881 and https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Server%20Side%20Request%20Forgery#payloads-with-localhost
Exploit¶
So, the final exploit is:
And that will dump the ENV, flag included