Prevent XSS attack in Paypal html form

Multi tool use
Multi tool use


Prevent XSS attack in Paypal html form



I have some problem with XSS scan on sitelock. They said that some of URL from html input form is vulnerable. They said each parameters which I sent through the form was vulnerable. In this case the vulnerability is from Paypal input form. I build my website with Paypal redirect so the user will input their own data into the form and the system will send it to paypal. This is the example of my form code:



" readonly="readonly">


<input type="hidden" name="billing_first_name" value="<?=$_POST['billing_first_name']?>">
<input type="hidden" name="billing_last_name" value="<?=$_POST['billing_last_name']?>">
<input type="hidden" name="billing_email" value="<?=$_POST['billing_email']?>">
<input type="hidden" name="billing_phone" value="<?=$_POST['billing_phone']?>">
<input type="hidden" name="billing_address" value="<?=$_POST['billing_address']?>">
<input type="hidden" name="billing_city" value="<?=$_POST['billing_city']?>">
<input type="hidden" name="billing_postcode" value="<?=$_POST['billing_postcode']?>">
<input type="hidden" name="billing_state" value="<?=$_POST['billing_state']?>">



That is some part of my form. What I want to know is whats wrong with that form and how to prevent Sitelock to scan XSS vulnerability ? Please anyone knows could help me.




2 Answers
2



I would also recommend using the HTTP header.


X-XSS-Protection: 1; mode=block



https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection





If I have xss attack the page will not load right ?
– Antonio
Jul 3 at 6:03





This method Block pages from loading when they detect reflected XSS attacks.
– SithLee
Jul 3 at 7:41



you probably dont check/nullify the data you are getting in the input fields



and by typing alert('hacked') in billing_address field


alert('hacked')



on next page where you print the billing_address you will get a popup window calling hacked



On the page that process your form you should validate that input fields doesn't have any javascript code.



for example


<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$website = test_input($_POST["website"]);
$comment = test_input($_POST["comment"]);
$gender = test_input($_POST["gender"]);
}

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>



you need to create a function like test_input and run for all your input fields






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

7SDw pDv,yZx9zP9T2 fM0,A0 rDWD3 jQdl98SqIgvT,TqG,bmJFFTN,1,d,yGr9y8j gXzMT7gqR9eDuQr,aR1FfrYu,KnSb2WMc q81,2f8R8J
b9mQyxRKIh20Fke o 8HqaKz0mB8m7rBaHgv c,KHN8Ym S3WKJnBTL,VBn6LWweBS

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications