How To Avoid $_SERVER["PHP_SELF"] Exploits?
How To Avoid $_SERVER["PHP_SELF"] Exploits?
3035
20-Jul-2018
Updated on 10-Oct-2018
Francesca Molly
10-Oct-2018Pratik Srivastav
18-Sep-2018Pratik Srivastav
18-Sep-2018Pratik Srivastav
18-Sep-2018Pratik Srivastav
18-Sep-2018Pratik Srivastav
18-Sep-2018Pratik Srivastav
18-Sep-2018kayle willson
25-Aug-2018Ralson Toorkey
24-Jul-2018Prakash nidhi Verma
20-Jul-2018$_SERVER["PHP_SELF"] Exploits:
$_SERVER["PHP_SELF"] exploits can be avoided by using the htmlspecialchars() function.
The htmlspecialchars() function converts special characters to HTML entities.Now, if the user tries to exploit the PHP_SELF variable.
<form method="post"action="test_form.php/"><script>alert('hacked')</script>">Validate Form Data With PHP :
<script>location.href('http://www.hacked.com')</script>Example:
$_SERVER["REQUEST_METHOD"]. If the REQUEST_METHOD is POST, then the form has been submitted - and it should be validated.