In this article we will discuss the security concerns over payment gateway at different functional levels and how to perform a security audit on payment gateway to identify security risks at application level.
A payment gateway is an online payment solution which empowers merchants to accept payment online including credit card, debit card, direct debit, bank transfer and real-time bank transfers. Payment gateway protects sensitive customer data like credit card number & CVV, netbanking credentials etc. by encrypting the traffic to ensure that the information is passed securely between customer & merchant.
How Payment Gateway Works
Here are the steps of how payment gateway works in online shopping environment:
- A buyer purchases an item and enters a credit card number, buyer’s name & CVV number in the checkout page.
- Details about the purchase are sent from checkout page to the payment gateway for processing.
- The payment gateway forwards transaction information to merchant’s bank.
- The whole channel between merchant’s website to payment gateway and payment gateway to merchant’s bank is encrypted.
- The merchant’s bank forwards transaction information to the bank that issued the buyer’s credit card to authorize the transaction.
- The bank that issued the buyer’s credit card either approves or denies the transaction and sends that information back to the merchant’s bank.
- If the transaction is approved, the bank will deposit funds on a merchant’s account at a scheduled time.
- The payment gateway sends transaction details and response back to the merchant website.
- The merchant website lets the buyer know if the transaction was approved or denied.
Security Concerns over Payment Gateway
The functionality of payment gateway is segregated across multiple levels of operations. Hence threats to its security can also be segregated based each level:
- Network level: Any security risk present in underlying network infrastructure may lead to the compromise of payment gateway. Therefore ensure that the devices & servers are configured properly and network perimeter is also defended against unauthorized access.
- Transaction level: The security concerns at transaction level include accepting an invalid transaction, for example – ‘0’ amount transaction, negative amount transaction and transaction with invalid details etc. Hence before accepting any transaction for processing, its validity should be checked properly.
- Application level: This level is about the coding standard of payment gateway and subject to application security risks like – SQL injection, XSS, Direct URL Access, CSRF etc. Refer list of OWASP top 10 vulnerabilities for more details.
Identifying Security Risks at Application Level
The payment gateway is integrated with merchant’s website; therefore merchant’s website should also be tested against various application security risks.
Below is a list of test scenarios for an initial understanding. Do not consider it as an exhaustive list as sometimes test scenarios varies based upon the implementation:
- All the issues present in OWASP list (SQL injection, Cross site scripting etc) are applicable on payment gateway also.
- Try to perform a transaction with ‘0’ amount.
- Try to perform a negative value transaction.
- Try to perform a transaction with low account balance.
- Check whether a latest version of SSL is implemented across all payment gateway pages. Verify if strong encryption and hashing algorithms with a fair length key are implemented.
- Another method to test it is enter the credit card details and capture HTTP response in an HTTP interceptor like – burp suite or zap proxy etc. The response will contain a ‘cache-control’ header, ensure that ‘no-cache’ & ‘no-store’ is set in that header.
- Test if idle session timeout is implemented in the application.
- Try to perform HTTP request replay attacks. A sample test can be – complete a transaction and capture the request when payment gateway redirects buyer back to merchant’s website. This request contains the confirmation of the successful payment. Now replay this request before making a payment and try to generate a payment confirmation slip without making any payment.
- Check if any user specific data (example – id, username etc.) is getting transmitted in HTTP requests. If yes, try to perform cross account access by replacing the values of such parameters with other valid user to make payment on other’s behalf.
- Test CSRF issue to identify if it is possible for an attacker to make a transaction on behalf of a legitimate user.
- Verify if audit trail is implemented either at database level or application level.
- Check if a proper password policy implemented in the application.
- Verify if session is destroyed after a successful payment.
Please go through following link to get more detailed approach on payment gateway audit: