# Https host header attack

**URL:** <https://community.cloudflare.com/t/https-host-header-attack/341842>\
**Category:** SSL / TLS\
**Created:** [January 4, 2022, 10:32am UTC](https://community.cloudflare.com/t/https-host-header-attack/341842 "2022-01-04T10:32:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![user17047](https://avatars.discourse-cdn.com/v4/letter/u/a9a28c/32.png) [@user17047](https://community.cloudflare.com/u/user17047)\
**Post date:** [January 4, 2022, 10:32am UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/1 "2022-01-04T10:32:43Z")

</div>

A couple of days ago I got a report from a security scanner that my domains are vulnerable to a Host Header attack.

lets say that [http://domain.com](http://domain.com) is a domain I have registered in cloudlfare.  
If I then run

`curl -vi --header "Host: bing.com" http://domain.com`

I get the following response

````auto
Date: Tue, 04 Jan 2022 10:28:10 GMT
Content-Length: 0
Connection: keep-alive
location: http://www.bing.com/
x-msedge-ref: Ref A: 49CBCD22861E4A909280D53497F69330 Ref B: LTSEDGE1011 Ref C: 2022-01-04T10:28:10Z
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Qnm%2FmOzytD4200hQPbYNCR0e6c8VwIqyu7KCCfcnDwwAgcqVbUQetzg4YvpWqSwS2y2FW52NkBLNGst9ZXPGm0bvu1TRDsnPlzCsMyPY0oq5s9XY%2BBsKyhF4jhrC9fGt1r5uqKyHHA%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 6c83c74d9c1872e5-LHR
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400```

So I have 2 questions 

1. I have disabled `Always Use HTTPS` in cloudflare but it still appears to be doing the redirect for some reason. Any idea why? I do have hsts enabled and "full (string)" ssl/tls most enabled. I wonder if one of these is causing the https redirect?

2. But more importantly how can I stop this 301 form happening? 
I also wonder if this is a recent internal change as I have been running these scans for almost a year and it only found this problem 3 days ago. (I have changed nothing in my cloudflare account)

Thanks
````

---

<div class="post-metadata">

**Author:** ![fritex](https://sea2.discourse-cdn.com/cloudflare/user_avatar/community.cloudflare.com/fritex/32/173767_2.png) [@fritex](https://community.cloudflare.com/u/fritex)\
**Post date:** [January 4, 2022, 11:56pm UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/2 "2022-01-04T23:56:46Z")

</div>

May I ask which tool/scanner have you used?

You’ve disabled this option, but may I ask:

1. Before moving to Cloudflare, was your Website working over HTTPS connection?
2. ~~Which SSL option have you got selected under the [SSL/TLS tab](https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls) at Cloudflare dashboard for your domain ( _Flexible, Full, Full Strict …_ )?~~

I missread it, it’s good you hare `Full (Strict) SSL` and HSTS, why disabling `Always Use HTTPS` option then?

Why would you want it to stop redirection? And have issues like possible duplicates with even Google Search, visitors may see different content due to HTTP vs HTTPS version, not to mention non-www vs www too.

Furthermore, 301 redirection is a normal thing _I guess_.  
Like, from any HTTP to HTTPS is recommended to have nowadays.

May I suggest looking into below post:

> [@Host Header Poisoning](https://community.cloudflare.com/t/host-header-poisoning/128485/6):
>
> Being able to change the Host header is only a problem when it’s possible on your own reverse proxy and also accepts hostnames that are not normally allowed. But in this case, Cloudflare is the reverse proxy, and Cloudflare has millions of websites that make use of it’s service and reverse proxy, so it’s not a vulnerability in this case that you can just change the Host header to a different Cloudflare domain and that it’ll actually accept and handle it.

Docs:

- [Avoid Web Cache Poisoning · Cloudflare Cache (CDN) docs](https://developers.cloudflare.com/cache/best-practices/avoid-web-poisoning)

From the blog:

> **[How Cloudflare protects customers from cache poisoning](https://blog.cloudflare.com/cache-poisoning-protection/)**
>
> A few days ago, Cloudflare — along with the rest of the world — learned of a "practical" cache poisoning attack. In this post I’ll walk through the attack and explain how Cloudflare mitigated it for our customers.

---

<div class="post-metadata">

**Author:** ![Judge](https://sea2.discourse-cdn.com/cloudflare/user_avatar/community.cloudflare.com/judge/32/22967_2.png) [@Judge](https://community.cloudflare.com/u/Judge)\
**Post date:** [January 5, 2022, 12:15am UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/3 "2022-01-05T00:15:37Z")

</div>

The redirect is actually because someone has set up [bing.com](http://bing.com) in Cloudflare, and Cloudflare is just loading the configuration for that zone when it does stuff. You can do the same for something else like

```auto
curl -v --header "Host: digitalocean.com" http://judge.sh
< HTTP/1.1 301 Moved Permanently
< Location: https://www.digitalocean.com/

```

I suspect this person who added [bing.com](http://bing.com) set up a www redirect in Cloudflare. As for why this happens at all, Cloudflare will respond to HTTP and DNS requests for zones before they’ve confirmed ownership so that, as new records propagate, the website still works. This really doesn’t cause any security issues, or at least, Cloudflare thinks that.

As you can see, testing a different non-CF website does not return a redirect and instead throws an error.

```auto
curl -v --header "Host: github.com" http://judge.sh
< HTTP/1.1 409 Conflict
error code: 1001

```

So this sounds like a non-issue in your case, and the warning in your security scanner can be safely ignored.

---

<div class="post-metadata">

**Author:** ![user17047](https://avatars.discourse-cdn.com/v4/letter/u/a9a28c/32.png) [@user17047](https://community.cloudflare.com/u/user17047)\
**Post date:** [January 5, 2022, 5:36pm UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/4 "2022-01-05T17:36:21Z")

</div>

So normally I have the http-\>https redirect set up but I disabled it when playing around with this to see what was going on.

I have enabled the http-\>https redirection again but my thought was that if I disabled it the 301 would stop happening. But for some reason the redirect still occurs you do not get the same behaviour with the following command

`curl -vi --header "Host: bing.com" https://domain.com`

So I thought it maybe an issue with the forced redirect.

Thanks for the post but I saw that when looking into this. It does not really appear to give an answer though. The accepted answer just says Cloudflare is big so it cant be a problem. But I am not sure I would ever agree with that statement.

---

<div class="post-metadata">

**Author:** ![Judge](https://sea2.discourse-cdn.com/cloudflare/user_avatar/community.cloudflare.com/judge/32/22967_2.png) [@Judge](https://community.cloudflare.com/u/Judge)\
**Post date:** [January 6, 2022, 7:20pm UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/5 "2022-01-06T19:20:23Z")

</div>

The point is that the Host header determines what website Cloudflare should load the configuration for. There is **absolutely zero other information** about the original website (`domain.com`) that Cloudflare receives when the host header is changed in the request. Thus, even if there is some issue with Cloudflare, it wouldn’t affect your website since Cloudflare doesn’t know what the original domain was supposed to be and thus won’t touch it.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/cloudflare/user_avatar/community.cloudflare.com/system/32/66551_2.png) [@system](https://community.cloudflare.com/u/system)\
**Post date:** [January 21, 2022, 7:20pm UTC](https://community.cloudflare.com/t/https-host-header-attack/341842/6 "2022-01-21T19:20:59Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
