What is Host Header Injection?

ByFelez

Uzman üye
9 Tem 2013
1,818
1,774

ntrt2kz.png


What is Host Header Injection?

Host Header Injection, also known as Host Header Attack, is a type of attack carried out by manipulating the "Host" header, one of the HTTP headers. When making requests to web applications, situations such as account takeover may occur if the Host header used is changed to an address belonging to the attacker.


host-header-attacks.jpg


How to Detect Host Header Injection Vulnerability?

To detect the host header injection vulnerability in a web application, you can try the following steps in OWASP:

If the phrase "Host: domain.com" in the submitted request is manipulated as "Host: evil.com" and the web application returns 200 OK, there is a vulnerability. To explain with an example;


uR0jPF.png

Normal Request:


Kod:
 POST /page[/SIZE][/COLOR][/B][/I][/CENTER]
[I][B][COLOR=rgb(255, 255, 255)][SIZE=5][CENTER]
Host: www.website.com

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Accept: */*

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate, br

Referer: https://www.website.com

Origin: https://www.website.com

Alt-Used: www.google.com

Connection: keep-alive

Cookie: 1P_JAR=2021-07-29-20; NID=220=M5Mq4asdasdkA1F3NYIjbczSAD-huTx6zcB0SttHt0Z8Xasdagadsgdsfadasdi4dWaG_Y1e6t2hoJgCbZ37shEeXYK6cAWNZiymLAGa66XjGkOXyJ8ZuV-aL2rwpmoRJqmDsUzL9LSXDq_5k0de-Ns

Sec-Fetch-Dest: empty

Sec-Fetch-Mode: no-cors

Sec-Fetch-Site: same-origin

Content-Length: 0


Manipulated Request:


Kod:
 POST /page[/SIZE][/COLOR][/B][/I][/CENTER]
[I][B][COLOR=rgb(255, 255, 255)][SIZE=5][CENTER]
Host: www.evil.com

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Accept: */*

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate, br

Referer: https://www.website.com

Origin: https://www.website.com

Alt-Used: www.google.com

Connection: keep-alive

Cookie: 1P_JAR=2021-07-29-20; NID=220=M5Mq4asdasdkA1F3NYIjbczSAD-huTx6zcB0SttHt0Z8Xasdagadsgdsfadasdi4dWaG_Y1e6t2hoJgCbZ37shEeXYK6cAWNZiymLAGa66XjGkOXyJ8ZuV-aL2rwpmoRJqmDsUzL9LSXDq_5k0de-Ns

Sec-Fetch-Dest: empty

Sec-Fetch-Mode: no-cors

Sec-Fetch-Site: same-origin

Content-Length: 0


If the web application returns 200 OK when "X-Forwarded-Host: evil.com" is added to the sent request, there is a Host Header Injection vulnerability.


uR0jPF.png

Normal Request:


Kod:
 POST /page[/B][/I][/SIZE][/COLOR][/CENTER]
[COLOR=rgb(255, 255, 255)][SIZE=5][I][B][CENTER]
Host: www.website.com

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Accept: */*

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate, br

Referer: https://www.website.com

Origin: https://www.website.com

Alt-Used: www.google.com

Connection: keep-alive

Cookie: 1P_JAR=2021-07-29-20; NID=220=M5Mq4asdasdkA1F3NYIjbczSAD-huTx6zcB0SttHt0Z8Xasdagadsgdsfadasdi4dWaG_Y1e6t2hoJgCbZ37shEeXYK6cAWNZiymLAGa66XjGkOXyJ8ZuV-aL2rwpmoRJqmDsUzL9LSXDq_5k0de-Ns

Sec-Fetch-Dest: empty

Sec-Fetch-Mode: no-cors

Sec-Fetch-Site: same-origin

Content-Length: 0

Manipulated Request:


Kod:
 POST /page[/SIZE][/COLOR][/B][/I][/CENTER]
[I][B][COLOR=rgb(255, 255, 255)][SIZE=5][CENTER]
Host: www.website.com

X-Forwarded-Host: www.evil.com

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0

Accept: */*

Accept-Language: en-US,en;q=0.5

Accept-Encoding: gzip, deflate, br

Referer: https://www.website.com

Origin: https://www.website.com

Alt-Used: www.google.com

Connection: keep-alive

Cookie: 1P_JAR=2021-07-29-20; NID=220=M5Mq4asdasdkA1F3NYIjbczSAD-huTx6zcB0SttHt0Z8Xasdagadsgdsfadasdi4dWaG_Y1e6t2hoJgCbZ37shEeXYK6cAWNZiymLAGa66XjGkOXyJ8ZuV-aL2rwpmoRJqmDsUzL9LSXDq_5k0de-Ns

Sec-Fetch-Dest: empty

Sec-Fetch-Mode: no-cors

Sec-Fetch-Site: same-origin

Content-Length: 0

How to Fix Host Header Injection Vulnerability? – Precautions

For Nginx and Apache, the request to the page must be checked on a virtual host without being directly ingested into the system. Host and X-Forwarded-Host should ensure that the headers are reliable sources.
Entries from the user must be filtered.

uR0jPF.png

What Can Be the Effects of Host Header Injection Vulnerability?

As I mentioned at the beginning of our article, Host Header Injection vulnerability is a security vulnerability that can progress to account acquisition. If an attacker raises a server and manages to manipulate the Host HTTP header it sends to the target application, it can intercept other users' password reset tokens.

In addition to this vulnerability, the Insecure Direct Object Reference (IDOR) vulnerability is a high-level security vulnerability that can lead to account takeover.

iUBacd.gif
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.