HTTP Host Header Attacks
HTTP Host Header Attacks
if we put arbitary value in the HOST header and send to the web server (ip) and
it’s seems that value not obvious to him it will open or redirect it or the response
with his first virtual name on that web server
conf file of apache in linux : /etc/apache2/apache2.conf
conf file that you will find the host headers name : /etc/apache2/sites-
enabled/000+TAP ——>> and that is the default
virtual Hosting
distinct websites will have a different domain name, they all share a common IP
address with the server. Websites hosted in this way on a single server are
known as "virtual hosts".
Routing-based SSRF
in other cases when u inject arbitrary value it could response to u with Invalid
Host Header this mean that the target domain accessed via CDN (Content
Delivery Network) so we could other bypass techniques outlined below
some web site applications have robust validation on the domain name and
don’t validate the port number if we have the ability to inject non-numeric port
number so we could inject the payload via the port
Other sites will try to apply matching logic to allow for arbitrary subdomains. In
this case, you may be able to bypass the validation entirely by registering an
arbitrary domain name that ends with the same sequence of characters as a
whitelisted one
or we could use some bypassing techniques listed in SSRF vulnerability if the
the application white list some domain names we could something like @ , #
character (recommended to search for it )
we could duplicate the host header and the response from the server will be
differ from the system to a system but it is common for one of the two headers
X-Host
X-Forwarded-Server
X-HTTP-Host-Override
Forwarded
X-Forwarded-Host
there is many useful headers that we could use to change the host header
value or to change the ip we could found on this link
https://book.hacktricks.xyz/network-services-pentesting/pentesting-
web/special-http-headers
اولا الفكره اصال انك ان انت لما بتعمل فورجت باسورد وتبعت تحط الايميل او اليوزر بتاعك
بيجيلك ميل بالهوست هايدر اللي كان موجود ف الريكوست مع التوكن وانت بتدوس ع
اللينك ده ويدخلك تخش تغير الباسورد
احنا كل اللي يهمنا ان احنا ازاي نجيب التوكن اللي هو جاي من السيرفر اصال ف حاله تغير
اليورز للباسورد بتاعه لانه كمان بيتبعتله ع الميل بتاعه هو ويارب تكون وصلت
طيب اول حاجه اللينك اللي جيه ده موجود ف قلبه الهوست هايدر فالو اللي كانت موجوده
ف الريكوست
Request :
ف اول لاب هو مش عامل اي فاليداشن ف انت ممكن تروح تغير الهوست هايدر فاليو
عالطول وهيبقلها عادي الفكره هنا ان احنا نحط دومين تابع لينا احنا وبنقدر نخش ع اللوجز
بتاعته عشان نشوف مين اللي اكسس للدومين بتاعنا وده ممكن يتم عن طريق انك
تستخدم البرب كولبورتور ف البرب سويت برو او انك تعمل كونفرجير لسيرفر اباتشي من
علي لينكس عادي والكالم ده ف الواقع لكن هو هنا ف الابات مدينا السيرفر جاهز واحنا
نشتغل عليه
طيب احنا لما نغير ف الهوست فاليو دي ونحط دومين او سيرفر احنا متحكمين ف لما يجي
اللينك يتبعت لاي يوزر احنا نكتبه يعني مثال بدل ما نكتب الايميل بتاعنا لا نكتب ايميل
if the user clicks that link the log of that action will appear in the access logs of
the server and with that click will compromise the token of changing password
so we take that token and go to the page which change the password and put
that token which belongs to victim
tip: this token is used only one time or could have period of time like and then
expired
lab2 : is the same idea of lab1 the only difference that the server validate the
host header value but we mentioned techniques we can use above i append
the X-Host value and it worked you can also duplicate the host header or use
another headers the important thing is to inject the host to point the server we
control
makefileCopy code
Host: example.com:evilport
5. Impact: Host header attacks can have severe consequences, including data
breaches, unauthorized access to sensitive information, manipulation of
user sessions, and compromise of the entire web application or server.
this the normal link arrived with password when click the link it will redirect us
to the login page to login with the new password sent
<a href='https://0ae9005503942a7084c11d0200d60098.web-security
click here</a>
web cache poisoning is another vulnerability and we will explain it letter the but
all we need to know that web cache poisoning mean that we could cache
request with malicious payload we send to the web server to be cached in the
server and any one will ask for that page the malicious code will fire (we send
this malicious page we cached in the web server to our victim)
1- request will be like normal request as shown below :
GET / HTTP/1.1
Host: Vulnerable-site.com
X-Cache: hit
Cache-Control: max-age=30
...
...
....
....
..
..
<body>
<script type="text/javascript" src="//Vulnerable-site.com/reso
</script>
</body>
2-then the second thing we will notice in this lab that the Host header value is
reflected to in server response with javascript loads an image or icon from the
server
3-so we could add our exploit server link with the file path ——>> ( the file )
create javascript file with the same name and path founded in the response and
that javascript file we put any javascript payload we want
4-if you are blocked you could use of any techniques we mentioned above like
double Host Header or Using the useful header (X-Forwarded-For,,etc..)
GET / HTTP/1.1
Host: Vulnerable-site.com
Host: server_we_control.com
5-send that request multiple times until the server response to you with hit
value of X-Cache:hit
back to you home / which you cached the malicious payload on it by using the
host header which is reflected in the server response
Routing-based SSRF
relies on exploiting the intermediary components that are prevalent in many
cloud-based architectures. This includes in-house load balancers and reverse
proxies.
fundamentally, these systems receive requests and forward them to the
appropriate back-end. If they are insecurely configured to forward requests
based on an unvalidated Host header, they can be manipulated into misrouting
requests to an arbitrary system of the attacker's choice.
how we know if this specific vulnerability arise ?
You can use Burp Collaborator to help identify these vulnerabilities. If you
supply the domain of your Collaborator server in the Host header, and
subsequently receive a DNS lookup from the target server or another in-path
system, this indicates that you may be able to route requests to arbitrary
domains
then every thing well and as we explained the second step is to have private IP
.
1- observe that when we change the host header value it response with 504
bad gateway
2- open burp collaborator client and copy the host and put it in the host header
then send the request if the collaborator DNS lookup that means that we could
high the vulnerability to SSRF
3- send the request to intruder then replace the burp collaborator link with
private ip’s ( in real world scenario we could get that private ip’s in the recon
phase when we trying to knows the CDN the application is hosted on it )
lab7:
lab7 the same solution of the lab6 the only trick we said it above we could put
the all URL in the first line of the Request like
lab8
3. Send the request. Observe that you are simply redirected to the homepage.
6. Using the drop-down menu next to the Send button, change the send mode
to Send group in sequence (single connection).
8. Send the sequence and check the responses. Observe that the second
request has successfully accessed the admin panel.
9. Study the response and observe that the admin panel contains an HTML
form for deleting a given user. Make a note of the following details:
10. On the second tab in your group, use these details to replicate the request
that would be issued when submitting the form. The result should look
something like this: POST /admin/delete HTTP/1.1
Host: 192.168.0.1
Cookie: _lab=YOUR-LAB-COOKIE; session=YOUR-SESSION-COOKIE
Content-Type: x-www-form-urlencoded
Content-Length: CORRECT
csrf=YOUR-CSRF-TOKEN&username=carlos
11. Send the requests in sequence down a single connection to solve the lab.
Custom proxies sometimes fail to validate the request line properly, which can
allow you to supply unusual, malformed input with unfortunate results.
For example, a reverse proxy might take the path from the request line, prefix it
with http://backend-server , and route the request to that upstream URL. This
works fine if the path starts with a / character, but what if starts with
an @ character instead?