Page 1 of 1

Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sat Apr 17, 2010 7:03 pm
by markerick
I'm a developer working on a site now that uses a PayPal PayNow button. My machine is Ubuntu 9.10 with Firefox 3.5.9 and NoScript 1.9.9.63.

At first NoScript was flat out blocked the PayPal button with an XSS warning. I searched and found a post where it was recommended to change the POST to a GET. I did that and now have problems with NoScript corrupting the data being sent to PayPal. Here is what happens...

I'm using PayPal's encrypted website payments so the price, and purchase information cannot be seen or manipulated.
https://cms.paypal.com/us/cgi-bin/?cmd= ... 8A3I0P017Q

This is what the PayPal button/form looks like on my page:
NOTE: The actual encrypted text is dynamically generated based on the purchase information and will vary from one use to the next.

Code: Select all

<!-- buy now button -->
<form action="https://www.paypal.com/us/cgi-bin/webscr" method="get">
  <input type="hidden" name="cmd" value="_s-xclick" />
  <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----
MIIIAwYJKoZIhvcNAQcDoIIH9DCCB/ACAQAxggEwMIIBLAIBADCBlDCBjjELMAkG
A1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQw
EgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UE
AxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJ
KoZIhvcNAQEBBQAEgYCp5O/sZi3Q8yAyWCCZcFCnP1BjWajKdtZyQjdajqZv1uDV
p0js6FrrGxsHnL2AXyvMSl9PBlfVlYt8YVPlKSrvpKjW8NrAoREht6vMH2gDBJLe
mOnFBaPmq/6cSi65cEYjCN4mYH36Zg4wSJAxI8z+Wzh1j2CX1SVbR8qsx6wM6DCC
BrUGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIONN6kF0t6w6AggaQTDCYC9iaW0oc
yaGMrEeU8yFzC0T3a2Wz5MVrm6OWJ/KPLZKKlp2NmG4NjbYiGx8w4Um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ekLe9x6jApmVcXultVD97TQYKE10TSi1UU
-----END PKCS7-----
" />
  <input type="image" src="/images/btn_paynowCC_LG.gif" class="paypal_paynow" name="submit" alt="Pay with PayPal" title="Pay through PayPal" />
</form>
Notice I changed the form method to GET instead of the original POST.

When the link is clicked, it should go to PayPal and get decrypted so the integrity of the data is preserved. However, what happens is that the browser slows waaaay down (like 10 seconds and is unresponsive) before it starts to register the click and pull up PayPal.

When the browser pulls up PayPal, it is an error page with the message:
Error Detected
We were unable to decrypt the certificate id.
In the Console, this message appears:
[NoScript XSS] Sanitized suspicious request. Original URL [https://www.paypal.com/us/cgi-bin/websc ... ubmit.y=14] requested from [http://localhost:9040/checkout]. Sanitized URL: [https://www.paypal.com/us/cgi-bin/websc ... 0657495332].
What's happening, is that NoScript is modifying the encrypted portion and corrupting the data. When I pulled the message apart in a text editor to look at the parts, I found that the content was dramatically altered. Regardless, any alteration corrupts the data.

This seems to happen most of the time with my tests. On a few occasions it worked as expected. I presume that the variable encrypted text will sometimes match NS patterns and not in others.

Please look into this and correct the problem as this will likely affect all encrypted PayPal buttons and cause problems for small businesses.

Thanks,
-Mark E.

BTW> I really like the NS plugin and recommend it to people. :)

Re: Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sat Apr 17, 2010 7:46 pm
by Giorgio Maone
It is actually a bug, since NoScript has already a specific work-around in place for these button.
It will be fixed in next release.
In the meanwhile, just change the "/us/" part of your action URL with "/ca/":

Code: Select all

https://www.paypal.com/ca/cgi-bin/webscr
It will work and won't change anything in your button behavior.

Re: Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sat Apr 17, 2010 8:05 pm
by markerick
Giorgio Maone wrote:It is actually a bug, since NoScript has already a specific work-around in place for these button.
It will be fixed in next release.
In the meanwhile, just change the "/us/" part of your action URL with "/ca/":

Code: Select all

https://www.paypal.com/ca/cgi-bin/webscr
It will work and won't change anything in your button behavior.
Thanks! The work-around URL change works perfectly. I'm glad to hear this will be fixed in the next release. Thanks for the prompt response. :)

-Mark E.

Re: Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sun Apr 18, 2010 3:41 pm
by Giorgio Maone
Fixed in 1.9.9.64

Re: Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sun Apr 18, 2010 5:30 pm
by dhouwn
So you basically improved the hard-coded workaround.
1.9.9.63 wrote:/^https:\/\/www\.paypal\.com\/(?:ca\/)?cgi-bin\/webscr\b/
1.9.9.64 wrote:/^https:\/\/www\.paypal\.com\/(?:[\w\-]+\/)?cgi-bin\/webscr\b/
But are there any plans for moving such workarounds into the XSS settings? That is making fine-grained per-site XSS settings possible?

Re: Bug: NS corrupts PayPal PayNow encrypted buttons

Posted: Sun Apr 18, 2010 8:40 pm
by Giorgio Maone
dhouwn wrote:So you basically improved the hard-coded workaround.
Mmm, not only. I also improved the speed of Base64 checks (which was the underlying problem: in facts, you'll see the button would work also without the hard-coded work-around, but you'd get a 1 second delay or so) and implemented a framework to skip checks for specific request parameters.
dhouwn wrote:But are there any plans for moving such workarounds into the XSS settings? That is making fine-grained per-site XSS settings possible?
What do you mean, exactly? You already have XSS exceptions. A generally available work-around for this issue would have been adding the above regular expression to the NoScript Options|Advanced|XSS exceptions box.