The global namespace play a vital role in application security and vice versa.The namespace holds importance in the context in which it is defined.It means the global setting and calling of variable.It is critical from security point of view.The namespace in which a variable is used can act as a infection vector if not properly defined.The exploitation of namespaces and declarations are specific now a days.The major problem occurs due to coding error.This cant be circumvented because of human factor.The rogue initialisation of variable in the function creates a security hole in the application.Lets look at the underlined example:
function authorisation()
{
if ( $access == "" )
{
echo("No Access Check Can Be Performed!");
return;
}
}
In the above example $access is checked for null parameter but if you look than the variable is
not properly initialised in the global namespace.As a result of which when the script is called in the
browser the attacker can inject any wrong value in it and let the script to execute.This is the
major security hole now a days.This point is very critical to understand.If we declare the value as
underlined as:
$access=2
function authorisation()
{
if ( $access == "" )
{
echo("No Access Check Can Be Performed!");
return;
}
}
Most of the coders think that by initilaising the $access in the global namespace the processing
will be right.But this is not a case with php.The core problem in the above present code is the
variable is defined globally but when $access is called in the function context no global specifier is
used. The result of this layout is cross referencing of the variables.The references are passed in a
wrong manner from global to local.This makes the function to return result of any kind which is
not predictable.The attackers are high on this and try to play with global specifier.The attacker
inject different initalisation parameter through the URL.The error generation can not be controlled
if right injection occurs and information will be leveraged out of the application.
Rather the proper code will be under mentioned as:
$access=2
function authorisation()
{
if ( global $access == "" )
{
echo("No Access Check Can Be Performed!");
return;
}
}
The global reference is passed in a right sequential manner.The same case happen with static
variables.If static variable is not initialised well then security flaw is hard to deny.A minor mistake
in the code makes the attacker to inject parameter of its own choice and allowing them to exploit
the application.The trimmed URL:This means the [iNewsid] and [month] are the two arguments whose parameteric values are to be passed to the PHP based functions.The limits of these parameters are restricted to locally or globally if programmed in a right sequential manner.But if the initialisation is not set right , the XSS will occur.This we are going to analyze.
newsdetails.php?iNewsid=137 newsdetails.php?month=11

iNewsid='<h2>XSS I am In.</h2> iNewsid='<p>XSS I am Strangling In.</p>



