Prevent DNS rebinding attacks by checking the Host header. This is not strictly necessary since such attacks should already be mitigated by the Origin header checks. It is good practice to ensure that the Host is correct, if not for the sake of completeness. There may be some situations where Origin is correct but Host is not (I'm having a hard time thinking of an example right now, though, to be honest).
Contrived PoC via CLI
Since the server currently does not check whether the Host header matches its expected value, one can use any domain name that maps to 127.0.0.1.
The solution proposed here is to deny requests that have bad Host headers (i.e., not 127.0.0.1:41416) by returning status code 400, since they are bad requests.
Prevent DNS rebinding attacks by checking the
Host
header. This is not strictly necessary since such attacks should already be mitigated by theOrigin
header checks. It is good practice to ensure that theHost
is correct, if not for the sake of completeness. There may be some situations whereOrigin
is correct butHost
is not (I'm having a hard time thinking of an example right now, though, to be honest).Contrived PoC via CLI
Since the server currently does not check whether the
Host
header matches its expected value, one can use any domain name that maps to127.0.0.1
.The solution proposed here is to deny requests that have bad
Host
headers (i.e., not127.0.0.1:41416
) by returning status code 400, since they are bad requests.