I am not familiar with PHP and our product is not written in PHP. We use a vendor that creates for our documentation using PHP. Recently we discover XSX attack in the PHP code. The XSS attack was produced when an attacker access to
vendor.php/%22onmouseover=%22alert%281310%29%22
The regular access is like
vendor.php?param1=val1¶m2=val2
After researching of the code I have found the problematic line:
$SelfURL = $_SERVER['PHP_SELF'];
I have fixed it using this great link PHP_SELF and XSS:
$SelfURL = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, "utf-8");
We have send the fix to the vendor and asked to fix PHP. The answer surprised me:
The vendor claims that their PHP is without any problem and that we should enable on our Apache server URL Rewrite rules that will not allow to access to pages like vendor.php/
.
I has tried to explain, that we do not have URL Rewrite rules and only access to his page creates the attack (due to $SelfURL = $_SERVER['PHP_SELF']
)
Since I am not familiar with PHP I want to recheck:
- Is it enough to use
htmlspecialchars
? - Should we create URL Rewrite rules?