How I was able to take over any users account with host header injection

This article is about a vulnerability I was able to find in the BugCrowd private program.

At around midnight I got an alert message that said that I had been invited to pentest a new private program. Taking in regard the scope and reward range of the web application, I thought I would give it a try. However, it was midnight and I did not come across any vulnerabilities and it was quite late so I decided to go to sleep.

The next day was like every other with running important errands but I had some free time before office, so I decided to have a look and do some research about that new private program as of the night before.

Since I was already familiar with the web application working methodology, I tested for IDOR’s but I did not have much luck with it at that time. Also, if I had found any IDOR then the severity category would not have gotten any high severity vulnerability in a way because they were using MongoDB default encrypted ID which is hard to decrypt. However, I thought there might be some loopholes where they might have leaked their userId.

As I moved on, I found few stored XSS but I was very sure that I would get response of duplicate of those vulnerabilities but still, I reported these vulnerabilities and as I had thought got the response of them as duplicate.

Moving further in pentest I got a vulnerability where I was able to steal other user’s passwords reset token or email verification token via Host-Header Injection.

What is Host-Header Injection?

Host-Header Injection is a vulnerability where a remote attacker can exploit a HTTP Host header sent by sending a fake host instead of original.

According to Tenable “When creating URI for links in web applications, developers often resort to the HTTP Host header available in HTTP request sent by client-side. A remote attacker can exploit this by sending a fake header with a domain name under his control allowing him to poison web-cache or password reset emails for example.”

There appeared a form that helps in resetting passwords. The form looked like this:

Password reset form
Password reset form

When the URL is typed then it sends a password reset token to the email that has been entered.

Image for post
Image for post
Email Verification Token

The Email Verification Token looks like as shown.

I have made this system personalized in my own local machine for providing this article. We can have a deep look into the URL, the URL is Http://{token}.

Reset password Link
Reset password Link

So, when the HOST name is changed from the password reset, there appears a request like this.

Image for post
Image for post

Since we have changed the host to from, there we might observe changes in our password reset token URL.

Image for post
Image for post

As stated above, the reset password URL changed and the URL looks like as shown.{token} from{token}

Here the host can be manipulated. So, if we add our own malicious host in request and send it then we can capture the password reset token. In order for this attack to be successful, the victim needs to click the password reset link sent to his/her inbox.

When the victim clicks the link then the attacker will get the password reset token of the victim’s, since the victim is clicking the malicious server link instead of the original one.

Token Leakage

As it can be seen here, the token has been leaked as soon as the victim clicks the link.

I successfully submitted this vulnerability with full proof of concept and finally this bug earned me 900$ in the Bugcrowd private program.

Image for post
Image for post

Editor’s Note — We are publishing write-ups related to cyber security every week. We are looking to grow our community. If you are interested in writing about cyber security, please email at or DM at

Head of Security at NASSec

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store