phppaypalticket-system

Ticket system in php vulnerabilities


I am building a ticket system for some website from which the user can book tickets for some event. My mechanism of booking goes like that:

  1. User clicks the buy now button.
  2. PayPal handles the payment.
  3. PayPal redirects the user, after successful checkout, to some "generate_ticket.php" page which generates the ticket number.
  4. The user gets redirected to the first page with the ticket number shown to them.

Here is the problem: any malicious user could know the url to which the successful checkout gets redirected, by observing the network tap in the developer tools, and send requests to this page "generate_ticket.php" and get free tickets.

Here is what I thought of to fix this problem:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

This variable can be modified. So, it is not reliable, at least not alone.

So, does anybody have any solution to fix these vulnerabilities or prevent the user from requesting free tickets?


Solution

  • Paypal has a feature called IPN, basically you will not directly send tickets to user once u get data on generate_ticket.php, Once a transaction is created u might inserting a record in db with Pending state and update it on response of paypal, here IPN comes into play, after the transaction gets completed paypal will send a post request you provide as notify_url where you will handle the script of sending user his tickets.