Web Challenge: ExpressionalRebel
Write up for the HackTheBox web challenge called ExpressionalRebel
Last updated
Was this helpful?
Write up for the HackTheBox web challenge called ExpressionalRebel
Last updated
Was this helpful?
Expressional Rebel was a very entertaining medium web challenge, the solution involved exploiting a url Uconfusion vulnerability along with a regex injection, something I believe most have not tinkered with (at least it wasn't the case for me!)
The vulnerable application was written in NodeJS, in this case we are provided the source code, which was crucial for this kind of challenge or it would've been pretty insane to solve!
Let's dig through some of the code of the challenge and identify vulnerabilities.
There are two interesting endpoints in this application, the first one in api.js
:
which performs the main action for this vulnerable application, evaluating a CSP.
The second endpoint is found in index.js
This endpoint validates the secret which in this case is the flag. We can see that this endpint has a isLocal
middleware, this checks that the request is coming from localhost with the following function:
The checkReportUri
is called using whatever url we provide in the reportUri
section of the CSP:
However if we want to use this SSRF to reach the /deactivate
endpoint, we must bypass the isLocalhost
filter on line 6
URL confusion is a vulnerability which arises from the non-standardized implementations of url parsing functions. In this case we want to make sure that isLocalhost
does not resolve our URL to have a localhost hostname, however that the httpGet
functionality actually reaches 127.0.0.1
Finally I landed on the following:
If we print the object which is returned when the mentioned sting is passed to parse
we get:
hostname
is null! We have bypassed the isLocalhost
, additionally this is treated as a valid URL by http.get
, letting us acheive our SSRF
The way the secret is validated is using the following function:
Is there a way we can get information about env.FLAG
while controlling only secret
?
Using this technique we can bruteforce the flag character by character, using our SSRF to call the endpoint.
Here is the script I ended up using, mostly by modifying a PoC from the aforementioned blog post.
I'm sure you could optimize this script quite a bit, however after some time I got the flag!
This was a really nice challenge that touched on some vulnerabilities which were pretty unknown to me. I hope you enjoyed it as much as I did and I hope you found this blogpost useful!
The csp provided to the application is evaluated using the node dependency, my first thought was to check for CVEs, but no luck there.
However something else caught my eye
After reading this about it, I started playing around with the parse
function to try and bypass the check.
It turns out we can use complex regexes and the response time give us information about whether we got partial of the secret correctly. If you wanna learn more about this vulnerability I suggest you read: . It explains this in great detail.
Keep hacking!