We all know that it is possible to manipulate some information during a request, I never had to use anything like $_SERVER[HTTP_HOST]
, $_SERVER[REQUEST_URI]
or $_SERVER['REMOTE_ADDR']
because I know it has security implications.
But I want to log some errors on my system, and I thought of using those variables to add details in my log if a URL can not be correctly validated, that is, if it contains characters that do not fit in the% / p>
Here's an explanation of how logic works.
if (!filter_var( $url, FILTER_VALIDATE_URL))
{
$detalhes = array (
'HTTP_HOST' => "http://$_SERVER[HTTP_HOST]",
'REQUEST_URI' => "$_SERVER[REQUEST_URI]",
'REMOTE_ADDR' => "$_SERVER[REMOTE_ADDR]"
'HTTP_X_FORWARDED_FOR' => "$_SERVER['HTTP_X_FORWARDED_FOR']"
);
$erro->gerar('20x0010', $detalhes);
}
This FILTER_VALIDATE_URL
string is the internal error code we use in the documentation to describe system errors, each [prefix] x [suffix] represents an error in a particular part of the system and the description , respectively.
In this function of 20x0010
, the system would check the gerar()
object and determine if the debug is active.
If the debug is active, a screen for the developer will be displayed with all output information, error code description and additional descriptions, which are config
variables, otherwise the user would be redirected to the index. In both cases errors are logged in a file.
I thought it was important to log this information because the most basic attacks could be logged. But I do not know if it would be safe to use these variables to add more detail to the error log.