how safe is $_SERVER[“HTTP_HOST”]?

前端 未结 1 1007
抹茶落季
抹茶落季 2020-12-18 01:10

I have a database full of website urls, the primary key is the $_SERVER[\"HTTP_HOST\"] of the website.

When a user navigates to ... lets say www.m

相关标签:
1条回答
  • 2020-12-18 02:09

    $_SERVER["HTTP_HOST"] is the HTTP Host header, as sent from the client. That makes this header generally unsafe.

    But, if you are in a typical virtual host setup in which the web server decides which script to execute based on VirtualHost configurations, which in turn are triggered by the HTTP Host header, your script should not get executed unless a known, whitelisted value was received in that header.

    If the web server does not care about the Host header and executes a certain script for any and all requests, then this value could be absolutely anything.

    0 讨论(0)
提交回复
热议问题