I just wanted to run this by other heads to make sure I wasn't missing something obvious. I am using Payflow Link, which handles all the credit card nastiness of ecommerce transactions. However, you pass the total amount of the transaction to PayPal over POST variables - which seems like a potential security hole:
- A malicious user could load up his cart and proceed to checkout
- By reading the hidden input fields, he could spoof the POST to PayPal with a total amount of 1 cent.
- Paypal would executes the transaction, calls my order logging script, which would log the transaction and mark his items for shipment.
I could check total amount against his cart by accessing the database, pulling his cart items, and re-totaling their prices plus shipping and tax. But that is a lot of heavy lifting just to check for tampering (multiple DB queries, plus 2 web service calls per item to get shipping and tax).
My idea:
- PayPal is sent the normal POST variables for the amount
- But then, in the user defined variables (which get forwarded to my logging script), store a sha1 hash of the total amount, plus some private key
- On the other side, the logging script rehashes the dollar amount, plus the same private key, and compares to the hash sent through.
- Differences between the sent hash and computed hash would indicate tampering, and the order would be red-flagged for human review.
Does this make sense? Am I missing something?
edit (for clarification):
Apparently I wasn't making my point clear, based on the first several responses. I realize this isn't an ideal setup. I know other companies offer similar or possibly even better services. I know I have to check the variables and I can't simply trust them. Please, if you are going to reply, all I am looking for in an answer is this:
Can anyone demonstrate a single vulnerability with my proposal that would allow a malicious user to alter the PayPal variables and go undetected?
It is a very straightforward question. That is all I am looking for. To anyone who can answer that, thank you in advance for you time and help!