Critical PCI Violation: Full Credit Card Numbers Exposed in Payment API Response
A critical security vulnerability has exposed full, unmasked credit card numbers in a payment processing API response. The flaw directly violates core PCI DSS requirements by transmitting sensitive cardholder data without protection, creating a severe risk of data exposure and potential financial fraud.
The vulnerability resides in the `src/routes/payments.js` file, where the endpoint's code explicitly returns the complete Primary Account Number (PAN) within the JSON response. The current implementation, `res.json({ transactionId: result.insertId, cardNumber: cardNumber, ... })`, sends the full card number in plaintext. This failure to mask data at the application layer means the PAN is exposed during transmission and could be logged or displayed in error messages, breaching PCI Requirement 3 for protecting stored cardholder data.
The immediate fix requires implementing robust data masking before any data leaves the secure processing environment. The recommendation is to return only the last four digits, replacing all preceding digits with asterisks (e.g., '****1234'). This masking function must be applied universally—to all API responses, logs, and system messages—to ensure the full PAN is never displayed or transmitted unless under explicitly authorized and encrypted conditions. This exposure places the organization under immediate scrutiny for compliance failures and data handling practices.