php - Safely get the URL using $_SERVER -
i'm creating web app has many domains pointing same app, content displayed depend on domain used reach app.
i using
$_server['http_host']
to the domain , pull in correct content.
i read not safe, because
the client can set http_host arbitrary value wants
from get full url in php
how possible , how can protect against this?
using http_host in comparison statement such if fine. start run problems if use http_host data directly method requires sanitized data such sql query string, user malform header perform sql injection
if user malforms host header, , have if comparison such if($_server['http_host'] == 'www.google.com') changing not useful malicious user. if controlled context through header, not print anything
Comments
Post a Comment