Project 5: Mini Payment Gateway with PCI-Compliant Architecture

Project 5: Mini Payment Gateway with PCI-Compliant Architecture

Project Overview

Attribute Value
Difficulty Level 3: Advanced
Time Estimate 3-4 weeks
Programming Language Java or C# (production languages for gateways)
Knowledge Area Payment Security / Compliance
Key Technologies PCI DSS, Network Segmentation, Audit Logging
Coolness Level Level 1: Pure Corporate Snoozefest (but deeply educational)
Business Potential 4. The โ€œOpen Coreโ€ Infrastructure

Learning Objectives

By completing this project, you will:

  1. Understand PCI DSS requirements - Learn why each security control exists by implementing them
  2. Design Card Data Environment (CDE) isolation - Implement network segmentation
  3. Build comprehensive audit logging - Immutable logs with tamper-evident hashing
  4. Implement role-based access control - Least-privilege principle for card data
  5. Handle data retention and purging - Know what can be stored and for how long
  6. Apply key management with split knowledge - Dual control principles

The Core Question Youโ€™re Answering

โ€œHow do you build a system that handles credit card data while meeting compliance requirements?โ€

PCI DSS (Payment Card Industry Data Security Standard) isnโ€™t just bureaucracyโ€”each requirement exists because of real breaches. Building a compliant gateway teaches you why security controls matter.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    THE PAYMENT GATEWAY'S ROLE                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”‚
โ”‚  โ”‚ Merchant โ”‚โ”€โ”€โ”€โ–บโ”‚ Payment  โ”‚โ”€โ”€โ”€โ–บโ”‚   Card   โ”‚โ”€โ”€โ”€โ–บโ”‚ Issuing  โ”‚          โ”‚
โ”‚  โ”‚ Website  โ”‚    โ”‚ Gateway  โ”‚    โ”‚ Network  โ”‚    โ”‚   Bank   โ”‚          โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚
โ”‚                       โ”‚                                                  โ”‚
โ”‚                       โ”‚                                                  โ”‚
โ”‚                       โ–ผ                                                  โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                     โ”‚
โ”‚              โ”‚      GATEWAY RESPONSIBILITIES       โ”‚                     โ”‚
โ”‚              โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค                     โ”‚
โ”‚              โ”‚                                    โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Accept card data from merchant  โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Validate and format data        โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Route to correct network        โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Handle responses                โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Store transaction records       โ”‚                     โ”‚
โ”‚              โ”‚                                    โ”‚                     โ”‚
โ”‚              โ”‚  SECURITY REQUIREMENTS:            โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Never store CVV/CVV2            โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Encrypt PAN at rest             โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Log all access                  โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Segment network                 โ”‚                     โ”‚
โ”‚              โ”‚  โ€ข Control who sees data           โ”‚                     โ”‚
โ”‚              โ”‚                                    โ”‚                     โ”‚
โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                     โ”‚
โ”‚                                                                          โ”‚
โ”‚  THE GATEWAY IS THE MOST SENSITIVE COMPONENT                            โ”‚
โ”‚  It touches EVERY card number that flows through                        โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Deep Theoretical Foundation

1. PCI DSS Requirements Overview

PCI DSS 4.0 has 12 top-level requirements grouped into 6 goals:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PCI DSS 4.0 REQUIREMENTS                              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  BUILD AND MAINTAIN SECURE NETWORK                                       โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                       โ”‚
โ”‚  1. Install and maintain network security controls                      โ”‚
โ”‚  2. Apply secure configurations to all system components                โ”‚
โ”‚                                                                          โ”‚
โ”‚  PROTECT ACCOUNT DATA                                                    โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                                    โ”‚
โ”‚  3. Protect stored account data โ† CRITICAL FOR THIS PROJECT             โ”‚
โ”‚  4. Protect cardholder data with strong cryptography during             โ”‚
โ”‚     transmission over open, public networks                             โ”‚
โ”‚                                                                          โ”‚
โ”‚  MAINTAIN A VULNERABILITY MANAGEMENT PROGRAM                             โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                            โ”‚
โ”‚  5. Protect all systems and networks from malicious software            โ”‚
โ”‚  6. Develop and maintain secure systems and software                    โ”‚
โ”‚                                                                          โ”‚
โ”‚  IMPLEMENT STRONG ACCESS CONTROL MEASURES                                โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                               โ”‚
โ”‚  7. Restrict access to cardholder data by business need-to-know         โ”‚
โ”‚  8. Identify users and authenticate access to system components         โ”‚
โ”‚  9. Restrict physical access to cardholder data                         โ”‚
โ”‚                                                                          โ”‚
โ”‚  REGULARLY MONITOR AND TEST NETWORKS                                     โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                     โ”‚
โ”‚  10. Log and monitor all access to system components and                โ”‚
โ”‚      cardholder data โ† CRITICAL FOR THIS PROJECT                        โ”‚
โ”‚  11. Test security of systems and networks regularly                    โ”‚
โ”‚                                                                          โ”‚
โ”‚  MAINTAIN AN INFORMATION SECURITY POLICY                                 โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                 โ”‚
โ”‚  12. Support information security with organizational policies          โ”‚
โ”‚      and programs                                                        โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2. Card Data Environment (CDE)

The CDE is the environment where cardholder data is processed, stored, or transmitted. Everything in CDE scope must comply with PCI DSS.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    CARD DATA ENVIRONMENT BOUNDARIES                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚                     CORPORATE NETWORK                            โ”‚    โ”‚
โ”‚  โ”‚  (Out of PCI scope if properly segmented)                       โ”‚    โ”‚
โ”‚  โ”‚                                                                  โ”‚    โ”‚
โ”‚  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚    โ”‚
โ”‚  โ”‚   โ”‚   HR System   โ”‚  โ”‚   Email       โ”‚  โ”‚   Intranet    โ”‚      โ”‚    โ”‚
โ”‚  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚    โ”‚
โ”‚  โ”‚                                                                  โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚                            โ”‚                                             โ”‚
โ”‚                            โ”‚ (Firewall/Segmentation)                    โ”‚
โ”‚                            โ–ผ                                             โ”‚
โ”‚  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—    โ”‚
โ”‚  โ•‘                     CARD DATA ENVIRONMENT                        โ•‘    โ”‚
โ”‚  โ•‘                     (PCI DSS SCOPE)                              โ•‘    โ”‚
โ”‚  โ•‘                                                                  โ•‘    โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚                    ZONE 1: DMZ                          โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚ Load Balancer โ”‚  โ”‚ WAF (Web App  โ”‚                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚               โ”‚  โ”‚ Firewall)     โ”‚                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘    โ”‚
โ”‚  โ•‘             โ”‚                                                   โ•‘    โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚                    ZONE 2: APPLICATION                   โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚ Gateway API   โ”‚  โ”‚ 3DS Server    โ”‚                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚ Server        โ”‚  โ”‚               โ”‚                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘    โ”‚
โ”‚  โ•‘             โ”‚                                                   โ•‘    โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚                    ZONE 3: DATA                          โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚ Token Vault   โ”‚  โ”‚ Transaction   โ”‚  โ”‚  HSM        โ”‚ โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚ (encrypted    โ”‚  โ”‚ Database      โ”‚  โ”‚  (keys)     โ”‚ โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ”‚  PANs)        โ”‚  โ”‚               โ”‚  โ”‚             โ”‚ โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚   โ•‘    โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘    โ”‚
โ”‚  โ•‘                                                                  โ•‘    โ”‚
โ”‚  โ•‘  EVERYTHING HERE MUST:                                          โ•‘    โ”‚
โ”‚  โ•‘  โ€ข Have access controls                                         โ•‘    โ”‚
โ”‚  โ•‘  โ€ข Have logging enabled                                         โ•‘    โ”‚
โ”‚  โ•‘  โ€ข Be hardened (secure configuration)                          โ•‘    โ”‚
โ”‚  โ•‘  โ€ข Be regularly patched                                         โ•‘    โ”‚
โ”‚  โ•‘  โ€ข Be included in penetration tests                            โ•‘    โ”‚
โ”‚  โ•‘                                                                  โ•‘    โ”‚
โ”‚  โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•    โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3. What Can and Cannot Be Stored

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    DATA STORAGE RULES (PCI DSS Req 3)                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚                     CARDHOLDER DATA                              โ”‚    โ”‚
โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค    โ”‚
โ”‚  โ”‚                                                                  โ”‚    โ”‚
โ”‚  โ”‚  Data Element           โ”‚ Storage Permitted โ”‚ Must Encrypt      โ”‚    โ”‚
โ”‚  โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚    โ”‚
โ”‚  โ”‚  Primary Account Number โ”‚ YES               โ”‚ YES (always)      โ”‚    โ”‚
โ”‚  โ”‚  (PAN)                  โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  Cardholder Name        โ”‚ YES               โ”‚ NO (recommended)  โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  Service Code           โ”‚ YES               โ”‚ NO (recommended)  โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  Expiration Date        โ”‚ YES               โ”‚ NO (recommended)  โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚                  SENSITIVE AUTH DATA                             โ”‚    โ”‚
โ”‚  โ”‚                  (NEVER store after authorization!)              โ”‚    โ”‚
โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค    โ”‚
โ”‚  โ”‚                                                                  โ”‚    โ”‚
โ”‚  โ”‚  Data Element           โ”‚ Storage Permitted โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  Full Track Data        โ”‚ โŒ NEVER           โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  (magnetic stripe)      โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  CVV2/CVC2/CID          โ”‚ โŒ NEVER           โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  (3-4 digit code)       โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚  PIN / PIN Block        โ”‚ โŒ NEVER           โ”‚                   โ”‚    โ”‚
โ”‚  โ”‚                         โ”‚                   โ”‚                   โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ”‚                                                                          โ”‚
โ”‚  WHY THESE RULES?                                                        โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                                         โ”‚
โ”‚  โ€ข PAN: Needed for chargebacks, recurring payments                      โ”‚
โ”‚  โ€ข CVV: Proves card-present. If stolen from DB, attacker could use      โ”‚
โ”‚         for CNP fraud. Delete immediately after auth.                   โ”‚
โ”‚  โ€ข Track Data: Contains everything needed to clone card physically      โ”‚
โ”‚  โ€ข PIN: Obviously critical. Must never exist outside HSM.               โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4. Audit Logging Requirements

PCI DSS Requirement 10 mandates comprehensive logging:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    AUDIT LOGGING REQUIREMENTS                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  WHAT MUST BE LOGGED (10.2):                                            โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                             โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ€ข All individual user access to cardholder data                        โ”‚
โ”‚  โ€ข All actions taken by any individual with root or admin privileges    โ”‚
โ”‚  โ€ข Access to all audit trails                                           โ”‚
โ”‚  โ€ข Invalid logical access attempts                                       โ”‚
โ”‚  โ€ข Use of identification and authentication mechanisms                  โ”‚
โ”‚  โ€ข Initialization, stopping, or pausing of audit logs                   โ”‚
โ”‚  โ€ข Creation and deletion of system-level objects                        โ”‚
โ”‚                                                                          โ”‚
โ”‚  WHAT EACH LOG MUST CONTAIN (10.3):                                     โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                     โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚  โ”‚  {                                                             โ”‚     โ”‚
โ”‚  โ”‚    "timestamp": "2024-01-15T14:32:17.123Z",   // When          โ”‚     โ”‚
โ”‚  โ”‚    "user_id": "admin_jsmith",                 // Who           โ”‚     โ”‚
โ”‚  โ”‚    "event_type": "DATA_ACCESS",               // What type     โ”‚     โ”‚
โ”‚  โ”‚    "action": "READ",                          // What action   โ”‚     โ”‚
โ”‚  โ”‚    "resource": "token_vault",                 // On what       โ”‚     โ”‚
โ”‚  โ”‚    "resource_id": "tok_abc123",               // Which record  โ”‚     โ”‚
โ”‚  โ”‚    "source_ip": "10.0.1.50",                  // From where    โ”‚     โ”‚
โ”‚  โ”‚    "outcome": "SUCCESS",                      // Result        โ”‚     โ”‚
โ”‚  โ”‚    "details": "PAN revealed for chargeback"   // Why (if app)  โ”‚     โ”‚
โ”‚  โ”‚  }                                                             โ”‚     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚                                                                          โ”‚
โ”‚  LOG INTEGRITY (10.5):                                                   โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                                   โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ€ข Logs must be tamper-evident                                          โ”‚
โ”‚  โ€ข Write-once storage or hash chaining                                  โ”‚
โ”‚  โ€ข Centralized log collection (can't delete on source)                  โ”‚
โ”‚  โ€ข Regular backups                                                       โ”‚
โ”‚  โ€ข Retain for at least 1 year, 3 months immediately available          โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

5. Access Control Model

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    ROLE-BASED ACCESS CONTROL                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  PRINCIPLE: Least Privilege                                              โ”‚
โ”‚  Only grant access necessary for job function                           โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚  โ”‚  Role                  โ”‚ Can See PAN? โ”‚ Can Decrypt? โ”‚ Other   โ”‚     โ”‚
โ”‚  โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  TRANSACTION_PROCESSOR โ”‚ Masked only  โ”‚ NO           โ”‚ Auth    โ”‚     โ”‚
โ”‚  โ”‚  (most operators)      โ”‚ ****0366     โ”‚              โ”‚ only    โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  CHARGEBACK_ANALYST    โ”‚ Full (temp)  โ”‚ YES          โ”‚ Read    โ”‚     โ”‚
โ”‚  โ”‚  (disputes team)       โ”‚ Must log     โ”‚ Time-limited โ”‚ only    โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  SUPPORT_AGENT         โ”‚ Last 4 only  โ”‚ NO           โ”‚ Lookup  โ”‚     โ”‚
โ”‚  โ”‚  (customer service)    โ”‚              โ”‚              โ”‚ only    โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  SECURITY_ADMIN        โ”‚ NO           โ”‚ NO           โ”‚ Config  โ”‚     โ”‚
โ”‚  โ”‚  (manages access)      โ”‚ (ironically) โ”‚              โ”‚ Audit   โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  KEY_CUSTODIAN_1       โ”‚ NO           โ”‚ Partial key  โ”‚ Key ops โ”‚     โ”‚
โ”‚  โ”‚  KEY_CUSTODIAN_2       โ”‚ NO           โ”‚ Partial key  โ”‚ Key ops โ”‚     โ”‚
โ”‚  โ”‚  (split knowledge)     โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ”‚  SYSTEM_ACCOUNT        โ”‚ N/A          โ”‚ Automated    โ”‚ Service โ”‚     โ”‚
โ”‚  โ”‚  (batch processes)     โ”‚ (no human)   โ”‚              โ”‚ account โ”‚     โ”‚
โ”‚  โ”‚                        โ”‚              โ”‚              โ”‚         โ”‚     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚                                                                          โ”‚
โ”‚  DUAL CONTROL PRINCIPLE:                                                 โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                                 โ”‚
โ”‚  Some operations require two people:                                     โ”‚
โ”‚  โ€ข Key generation: Key Custodian 1 + Key Custodian 2                    โ”‚
โ”‚  โ€ข Key rotation: Key Custodian 1 + Key Custodian 2                      โ”‚
โ”‚  โ€ข Bulk PAN export: Chargeback Analyst + Security Admin approval        โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

6. Key Management Requirements

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    KEY MANAGEMENT (PCI DSS Req 3.5-3.7)                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  KEY LIFECYCLE:                                                          โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                                          โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚  โ”‚Generate โ”‚โ”€โ”€โ”€โ–บโ”‚ Store   โ”‚โ”€โ”€โ”€โ–บโ”‚  Use    โ”‚โ”€โ”€โ”€โ–บโ”‚ Rotate  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”‚
โ”‚  โ”‚         โ”‚    โ”‚ Securelyโ”‚    โ”‚         โ”‚    โ”‚         โ”‚      โ”‚       โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜      โ”‚       โ”‚
โ”‚       โ”‚                                            โ”‚           โ”‚       โ”‚
โ”‚       โ”‚                                            โ–ผ           โ”‚       โ”‚
โ”‚       โ”‚                                     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚       โ”‚
โ”‚       โ”‚                                     โ”‚ Archive   โ”‚      โ”‚       โ”‚
โ”‚       โ”‚                                     โ”‚ Old Keys  โ”‚      โ”‚       โ”‚
โ”‚       โ”‚                                     โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚       โ”‚
โ”‚       โ”‚                                           โ”‚           โ”‚       โ”‚
โ”‚       โ”‚                                           โ–ผ           โ”‚       โ”‚
โ”‚       โ”‚                                     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚       โ”‚
โ”‚       โ”‚                                     โ”‚ Destroy   โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
โ”‚       โ”‚                                     โ”‚ (secure)  โ”‚              โ”‚
โ”‚       โ”‚                                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
โ”‚       โ”‚                                                                 โ”‚
โ”‚       โ–ผ                                                                 โ”‚
โ”‚  SPLIT KNOWLEDGE / DUAL CONTROL:                                        โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                        โ”‚
โ”‚                                                                          โ”‚
โ”‚  No single person should know the complete key:                         โ”‚
โ”‚                                                                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚                                                                  โ”‚   โ”‚
โ”‚  โ”‚   Custodian A        Custodian B        Combined                โ”‚   โ”‚
โ”‚  โ”‚   โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•        โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•        โ•โ•โ•โ•โ•โ•โ•โ•                โ”‚   โ”‚
โ”‚  โ”‚   KEY_PART_1    โŠ•    KEY_PART_2    =    MASTER_KEY             โ”‚   โ”‚
โ”‚  โ”‚   (A knows)         (B knows)           (neither knows)         โ”‚   โ”‚
โ”‚  โ”‚                                                                  โ”‚   โ”‚
โ”‚  โ”‚   Both must be present for key ceremonies                       โ”‚   โ”‚
โ”‚  โ”‚   Neither can act alone                                          โ”‚   โ”‚
โ”‚  โ”‚                                                                  โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                                                                          โ”‚
โ”‚  KEY ROTATION REQUIREMENTS:                                              โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•                                              โ”‚
โ”‚  โ€ข Cryptoperiod defined (typically 1 year)                              โ”‚
โ”‚  โ€ข Old keys retained for decryption of historical data                  โ”‚
โ”‚  โ€ข Rotation process documented and tested                               โ”‚
โ”‚  โ€ข Emergency rotation procedure for suspected compromise                โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Specification

What Youโ€™ll Build

A complete mini payment gateway including:

  1. API Server: Authorization, capture, refund endpoints
  2. Token Vault Integration: Store PANs securely
  3. Network Segmentation: Simulate CDE isolation
  4. Audit System: Comprehensive, tamper-evident logging
  5. Admin Dashboard: Role-based card data access
  6. Compliance Documentation: Map implementation to PCI DSS requirements

Expected Output

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                    PAYMENT GATEWAY - ADMIN DASHBOARD                   โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                        โ•‘
โ•‘  User: jsmith@acme.com                                                 โ•‘
โ•‘  Role: CHARGEBACK_ANALYST                                             โ•‘
โ•‘  Session: Active (expires in 14:32)                                   โ•‘
โ•‘                                                                        โ•‘
โ•‘  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   โ•‘
โ•‘                                                                        โ•‘
โ•‘  TRANSACTION SEARCH                                                    โ•‘
โ•‘  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                    โ•‘
โ•‘  Transaction ID: [TXN-987654321     ]                                 โ•‘
โ•‘  [SEARCH]                                                              โ•‘
โ•‘                                                                        โ•‘
โ•‘  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   โ•‘
โ•‘                                                                        โ•‘
โ•‘  TRANSACTION DETAILS                                                   โ•‘
โ•‘  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                   โ•‘
โ•‘  ID:           TXN-987654321                                          โ•‘
โ•‘  Date:         2024-01-15 14:32:17 UTC                                โ•‘
โ•‘  Merchant:     ACME Store (MID: M001234)                              โ•‘
โ•‘  Amount:       $149.99 USD                                            โ•‘
โ•‘  Status:       CAPTURED                                                โ•‘
โ•‘  Auth Code:    A12345                                                  โ•‘
โ•‘                                                                        โ•‘
โ•‘  CARD INFORMATION                                                      โ•‘
โ•‘  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                      โ•‘
โ•‘  Token:        tok_a1b2c3d4e5f6                                       โ•‘
โ•‘  Last 4:       0366                                                    โ•‘
โ•‘  Network:      Visa                                                    โ•‘
โ•‘  Expiry:       12/25                                                   โ•‘
โ•‘                                                                        โ•‘
โ•‘  โš ๏ธ FULL PAN ACCESS                                                    โ•‘
โ•‘  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                     โ•‘
โ•‘  Your role permits PAN reveal for chargeback investigation.           โ•‘
โ•‘  This action will be logged with your user ID.                        โ•‘
โ•‘                                                                        โ•‘
โ•‘  Reason for access: [Chargeback CB-2024-0123     ]                    โ•‘
โ•‘  [REVEAL FULL PAN]                                                     โ•‘
โ•‘                                                                        โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

[User clicks REVEAL FULL PAN]

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                    โš ๏ธ SENSITIVE DATA DISPLAYED                         โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                        โ•‘
โ•‘  Full PAN: 4532015112830366                                           โ•‘
โ•‘                                                                        โ•‘
โ•‘  This reveal expires in: 00:29                                        โ•‘
โ•‘  Screen capture detection: ACTIVE                                     โ•‘
โ•‘                                                                        โ•‘
โ•‘  AUDIT LOG ENTRY CREATED:                                              โ•‘
โ•‘  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                             โ•‘
โ•‘  Time:    2024-01-15T14:35:42.123Z                                    โ•‘
โ•‘  User:    jsmith@acme.com                                             โ•‘
โ•‘  Action:  PAN_REVEAL                                                   โ•‘
โ•‘  Token:   tok_a1b2c3d4e5f6                                            โ•‘
โ•‘  Reason:  CB-2024-0123                                                โ•‘
โ•‘  IP:      10.0.1.50                                                    โ•‘
โ•‘                                                                        โ•‘
โ•‘  [CLOSE - I have recorded this information]                           โ•‘
โ•‘                                                                        โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Audit Log Viewer

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                    AUDIT LOG VIEWER                                    โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘                                                                        โ•‘
โ•‘  Filter: [All Events โ–ผ] Date: [2024-01-15] to [2024-01-15]           โ•‘
โ•‘  [SEARCH]                                                              โ•‘
โ•‘                                                                        โ•‘
โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘
โ•‘  โ”‚ Time          โ”‚ User     โ”‚ Event         โ”‚ Details      โ”‚ Hash โ”‚   โ•‘
โ•‘  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”‚   โ•‘
โ•‘  โ”‚ 14:35:42.123  โ”‚ jsmith   โ”‚ PAN_REVEAL    โ”‚ tok_a1b...   โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚ 14:32:17.456  โ”‚ SYSTEM   โ”‚ AUTH_SUCCESS  โ”‚ TXN-987...   โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚ 14:32:17.234  โ”‚ SYSTEM   โ”‚ AUTH_REQUEST  โ”‚ MID: M001... โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚ 14:30:00.000  โ”‚ admin    โ”‚ LOGIN         โ”‚ 10.0.1.100   โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚ 14:29:45.789  โ”‚ admin    โ”‚ LOGIN_FAIL    โ”‚ 10.0.1.100   โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚ 14:15:22.333  โ”‚ SYSTEM   โ”‚ KEY_ROTATION  โ”‚ v3 โ†’ v4      โ”‚ โœ“    โ”‚   โ•‘
โ•‘  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”‚   โ•‘
โ•‘  โ”‚                                                                โ”‚   โ•‘
โ•‘  โ”‚ โœ“ = Hash chain verified (tamper-evident)                      โ”‚   โ•‘
โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘
โ•‘                                                                        โ•‘
โ•‘  HASH CHAIN VERIFICATION:                                              โ•‘
โ•‘  Each log entry hash = SHA256(previous_hash + entry_data)             โ•‘
โ•‘  Genesis hash: 0x3a7f... (from audit initialization)                  โ•‘
โ•‘  Chain status: VALID (4,231 entries since initialization)             โ•‘
โ•‘                                                                        โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Project Structure

payment_gateway/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main/
โ”‚   โ”‚   โ”œโ”€โ”€ Program.cs              # Entry point (C#) or Application.java
โ”‚   โ”‚   โ”œโ”€โ”€ Startup.cs              # DI configuration
โ”‚   โ”‚   โ””โ”€โ”€ appsettings.json        # Configuration
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ AuthorizationController.cs
โ”‚   โ”‚   โ”œโ”€โ”€ CaptureController.cs
โ”‚   โ”‚   โ”œโ”€โ”€ RefundController.cs
โ”‚   โ”‚   โ””โ”€โ”€ AdminController.cs
โ”‚   โ”œโ”€โ”€ domain/
โ”‚   โ”‚   โ”œโ”€โ”€ Transaction.cs
โ”‚   โ”‚   โ”œโ”€โ”€ Merchant.cs
โ”‚   โ”‚   โ””โ”€โ”€ Card.cs
โ”‚   โ”œโ”€โ”€ vault/
โ”‚   โ”‚   โ”œโ”€โ”€ TokenVaultService.cs
โ”‚   โ”‚   โ”œโ”€โ”€ ITokenVault.cs
โ”‚   โ”‚   โ””โ”€โ”€ EncryptionService.cs
โ”‚   โ”œโ”€โ”€ security/
โ”‚   โ”‚   โ”œโ”€โ”€ AccessControlService.cs
โ”‚   โ”‚   โ”œโ”€โ”€ RoleDefinitions.cs
โ”‚   โ”‚   โ””โ”€โ”€ AuthenticationMiddleware.cs
โ”‚   โ”œโ”€โ”€ audit/
โ”‚   โ”‚   โ”œโ”€โ”€ AuditLogger.cs
โ”‚   โ”‚   โ”œโ”€โ”€ HashChainService.cs
โ”‚   โ”‚   โ””โ”€โ”€ AuditEntry.cs
โ”‚   โ”œโ”€โ”€ network/
โ”‚   โ”‚   โ”œโ”€โ”€ ProcessorClient.cs      # Mock card network
โ”‚   โ”‚   โ””โ”€โ”€ IssuerSimulator.cs
โ”‚   โ””โ”€โ”€ compliance/
โ”‚       โ”œโ”€โ”€ DataRetention.cs
โ”‚       โ””โ”€โ”€ PCIRequirements.cs
โ”œโ”€โ”€ web/
โ”‚   โ”œโ”€โ”€ admin-dashboard/
โ”‚   โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ”‚   โ”œโ”€โ”€ transactions.html
โ”‚   โ”‚   โ””โ”€โ”€ audit-log.html
โ”‚   โ””โ”€โ”€ assets/
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ AuthorizationTests.cs
โ”‚   โ”œโ”€โ”€ AccessControlTests.cs
โ”‚   โ”œโ”€โ”€ AuditLogTests.cs
โ”‚   โ””โ”€โ”€ PenetrationTests/           # Security test cases
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ pci-compliance-mapping.md
โ”‚   โ”œโ”€โ”€ architecture.md
โ”‚   โ””โ”€โ”€ security-controls.md
โ”œโ”€โ”€ docker/
โ”‚   โ”œโ”€โ”€ docker-compose.yml          # Simulated network zones
โ”‚   โ”œโ”€โ”€ Dockerfile.gateway
โ”‚   โ”œโ”€โ”€ Dockerfile.vault
โ”‚   โ””โ”€โ”€ Dockerfile.audit
โ””โ”€โ”€ README.md

Core API Design

// IPaymentGateway.cs

public interface IPaymentGateway
{
    Task<AuthorizationResponse> Authorize(AuthorizationRequest request);
    Task<CaptureResponse> Capture(CaptureRequest request);
    Task<RefundResponse> Refund(RefundRequest request);
    Task<VoidResponse> Void(VoidRequest request);
}

public class AuthorizationRequest
{
    public string MerchantId { get; set; }
    public string CardToken { get; set; }      // Already tokenized
    // OR for first-time cards:
    public string Pan { get; set; }            // Will be tokenized
    public string ExpiryDate { get; set; }
    public string Cvv { get; set; }            // NEVER stored after auth
    public decimal Amount { get; set; }
    public string Currency { get; set; }
    public string OrderId { get; set; }
}

public class AuthorizationResponse
{
    public string TransactionId { get; set; }
    public string AuthCode { get; set; }
    public TransactionStatus Status { get; set; }
    public string DeclineReason { get; set; }
    public string CardToken { get; set; }       // For future use
    public string MaskedPan { get; set; }       // ****0366
}

// IAuditLogger.cs

public interface IAuditLogger
{
    Task Log(AuditEntry entry);
    Task<IEnumerable<AuditEntry>> Query(AuditQuery query);
    Task<bool> VerifyIntegrity();
}

public class AuditEntry
{
    public DateTime Timestamp { get; set; }
    public string UserId { get; set; }
    public AuditEventType EventType { get; set; }
    public string Action { get; set; }
    public string ResourceType { get; set; }
    public string ResourceId { get; set; }
    public string SourceIp { get; set; }
    public string Outcome { get; set; }
    public string Details { get; set; }
    public string PreviousHash { get; set; }    // For chain
    public string EntryHash { get; set; }
}

// IAccessControl.cs

public interface IAccessControl
{
    Task<bool> CanAccess(string userId, string resource, string action);
    Task<bool> CanRevealPan(string userId, string reason);
    Task<string> GetMaskedPan(string token);
    Task<string> GetFullPan(string token, string userId, string reason);
}

Solution Architecture

Network Segmentation (Docker Simulation)

# docker-compose.yml

version: '3.8'

networks:
  dmz:
    driver: bridge
    ipam:
      config:
        - subnet: 172.16.1.0/24  # DMZ network

  application:
    driver: bridge
    ipam:
      config:
        - subnet: 172.16.2.0/24  # App network

  data:
    driver: bridge
    internal: true              # No external access
    ipam:
      config:
        - subnet: 172.16.3.0/24  # Data network

services:
  # DMZ Zone
  load-balancer:
    image: nginx:alpine
    networks:
      - dmz
    ports:
      - "443:443"

  # Application Zone
  gateway-api:
    build:
      context: .
      dockerfile: docker/Dockerfile.gateway
    networks:
      - dmz
      - application
    depends_on:
      - token-vault

  # Data Zone
  token-vault:
    build:
      context: .
      dockerfile: docker/Dockerfile.vault
    networks:
      - application
      - data
    environment:
      - VAULT_KEY_PATH=/run/secrets/vault_key
    secrets:
      - vault_key

  transaction-db:
    image: postgres:15
    networks:
      - data
    volumes:
      - tx-data:/var/lib/postgresql/data

  audit-db:
    image: postgres:15
    networks:
      - data
    volumes:
      - audit-data:/var/lib/postgresql/data

secrets:
  vault_key:
    file: ./secrets/vault_key.enc  # Would be HSM in production

volumes:
  tx-data:
  audit-data:

System Design

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PAYMENT GATEWAY ARCHITECTURE                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                          โ”‚
โ”‚  EXTERNAL                                                                โ”‚
โ”‚  โ•โ•โ•โ•โ•โ•โ•โ•                                                                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                                                    โ”‚
โ”‚  โ”‚   Merchant      โ”‚                                                    โ”‚
โ”‚  โ”‚   Application   โ”‚                                                    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                                                    โ”‚
โ”‚           โ”‚ HTTPS (TLS 1.2+)                                            โ”‚
โ”‚           โ–ผ                                                              โ”‚
โ”‚  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—     โ”‚
โ”‚  โ•‘  DMZ (172.16.1.0/24)                                           โ•‘     โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   Load Balancer / WAF                                   โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข TLS termination                                      โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข Rate limiting                                        โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข Request filtering                                    โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘     โ”‚
โ”‚  โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚
โ”‚                               โ”‚                                          โ”‚
โ”‚  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ–ผโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—     โ”‚
โ”‚  โ•‘  APPLICATION (172.16.2.0/24)                                   โ•‘     โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   Gateway API                                           โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚ Authorization  โ”‚  โ”‚ Access Control โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚ Service        โ”‚  โ”‚ Service        โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚           โ”‚                   โ”‚                        โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚         Business Logic             โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚  โ€ข Validate request                โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚  โ€ข Route to processor              โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ”‚  โ€ข Handle response                 โ”‚              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚           โ”‚                 โ”‚                          โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘     โ”‚
โ”‚  โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ”‚โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚
โ”‚                 โ”‚                 โ”‚                                      โ”‚
โ”‚  โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ–ผโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ–ผโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—     โ”‚
โ”‚  โ•‘  DATA (172.16.3.0/24) - INTERNAL ONLY                         โ•‘     โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   Token Vault   โ”‚  โ”‚  Transaction    โ”‚  โ”‚ Audit Log   โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚                 โ”‚  โ”‚  Database       โ”‚  โ”‚ Database    โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚  โ€ข Encrypted    โ”‚  โ”‚                 โ”‚  โ”‚             โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚    PANs         โ”‚  โ”‚  โ€ข TXN records  โ”‚  โ”‚ โ€ข Append-   โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚  โ€ข Token map    โ”‚  โ”‚  โ€ข Masked PAN   โ”‚  โ”‚   only      โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚                 โ”‚  โ”‚  โ€ข No CVV ever  โ”‚  โ”‚ โ€ข Hash      โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚                 โ”‚  โ”‚                 โ”‚  โ”‚   chain     โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘     โ”‚
โ”‚  โ•‘                                                                โ•‘     โ”‚
โ”‚  โ•‘  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   Key Management (simulated HSM)                        โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข Master Key (split knowledge)                        โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข Data Encryption Key                                 โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ”‚   โ€ข Key rotation schedule                               โ”‚   โ•‘     โ”‚
โ”‚  โ•‘  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ•‘     โ”‚
โ”‚  โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•     โ”‚
โ”‚                                                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Implementation Guide

Phase 1: Basic Authorization Flow

Goal: Implement auth/capture/refund with mock processor.

public class AuthorizationService : IAuthorizationService
{
    private readonly ITokenVault _vault;
    private readonly IProcessorClient _processor;
    private readonly IAuditLogger _audit;

    public async Task<AuthorizationResponse> Authorize(AuthorizationRequest request)
    {
        // 1. Validate request
        ValidateRequest(request);

        // 2. Tokenize PAN if provided (CVV passed to processor, NOT stored)
        string token;
        if (!string.IsNullOrEmpty(request.Pan))
        {
            token = await _vault.Tokenize(request.Pan);
            // CVV is passed to processor but NEVER touches our storage
        }
        else
        {
            token = request.CardToken;
        }

        // 3. Send to processor (they decrypt/route to issuer)
        var processorResponse = await _processor.Authorize(new ProcessorRequest
        {
            Token = token,
            Amount = request.Amount,
            Currency = request.Currency,
            MerchantId = request.MerchantId
        });

        // 4. Create transaction record (NO CVV, NO full PAN)
        var transaction = new Transaction
        {
            Id = GenerateTransactionId(),
            MerchantId = request.MerchantId,
            Token = token,
            MaskedPan = await _vault.GetMaskedPan(token),  // ****0366
            Amount = request.Amount,
            Currency = request.Currency,
            Status = processorResponse.Approved ? TransactionStatus.Authorized : TransactionStatus.Declined,
            AuthCode = processorResponse.AuthCode,
            CreatedAt = DateTime.UtcNow
        };

        await _transactionRepo.Save(transaction);

        // 5. Audit log
        await _audit.Log(new AuditEntry
        {
            EventType = AuditEventType.Authorization,
            Action = processorResponse.Approved ? "AUTH_SUCCESS" : "AUTH_DECLINED",
            ResourceId = transaction.Id,
            Details = $"Amount: {request.Amount} {request.Currency}"
        });

        return new AuthorizationResponse
        {
            TransactionId = transaction.Id,
            AuthCode = transaction.AuthCode,
            Status = transaction.Status,
            CardToken = token,
            MaskedPan = transaction.MaskedPan
        };
    }
}

Phase 2: Audit Logging with Hash Chain

Goal: Implement tamper-evident audit logs.

public class HashChainAuditLogger : IAuditLogger
{
    private readonly IAuditRepository _repo;
    private string _lastHash;

    public async Task Log(AuditEntry entry)
    {
        // 1. Get previous hash
        entry.PreviousHash = _lastHash ?? await GetGenesisHash();

        // 2. Add timestamp and system info
        entry.Timestamp = DateTime.UtcNow;
        entry.NodeId = Environment.MachineName;

        // 3. Calculate hash of this entry
        entry.EntryHash = CalculateHash(entry);

        // 4. Store (append-only table)
        await _repo.Append(entry);

        // 5. Update last hash
        _lastHash = entry.EntryHash;
    }

    private string CalculateHash(AuditEntry entry)
    {
        // Hash = SHA256(previousHash + timestamp + userId + eventType + action + resourceId + details)
        var data = $"{entry.PreviousHash}|{entry.Timestamp:O}|{entry.UserId}|" +
                   $"{entry.EventType}|{entry.Action}|{entry.ResourceId}|{entry.Details}";

        using var sha = SHA256.Create();
        var hashBytes = sha.ComputeHash(Encoding.UTF8.GetBytes(data));
        return Convert.ToHexString(hashBytes);
    }

    public async Task<bool> VerifyIntegrity()
    {
        // Walk entire chain and verify each hash
        var entries = await _repo.GetAllInOrder();

        string expectedPrevious = await GetGenesisHash();

        foreach (var entry in entries)
        {
            if (entry.PreviousHash != expectedPrevious)
            {
                return false;  // Chain broken!
            }

            var calculatedHash = CalculateHash(entry);
            if (calculatedHash != entry.EntryHash)
            {
                return false;  // Entry tampered!
            }

            expectedPrevious = entry.EntryHash;
        }

        return true;
    }
}

Phase 3: Role-Based Access Control

Goal: Implement least-privilege access to card data.

public class AccessControlService : IAccessControl
{
    private readonly IUserRepository _users;
    private readonly IAuditLogger _audit;
    private readonly ITokenVault _vault;

    private static readonly Dictionary<string, HashSet<string>> RolePermissions = new()
    {
        ["TRANSACTION_PROCESSOR"] = new() { "VIEW_MASKED_PAN", "CREATE_AUTH", "CAPTURE", "REFUND" },
        ["CHARGEBACK_ANALYST"] = new() { "VIEW_MASKED_PAN", "REVEAL_PAN", "VIEW_TRANSACTION" },
        ["SUPPORT_AGENT"] = new() { "VIEW_LAST4", "VIEW_TRANSACTION" },
        ["SECURITY_ADMIN"] = new() { "VIEW_AUDIT", "MANAGE_USERS", "VIEW_CONFIG" },
        ["KEY_CUSTODIAN"] = new() { "KEY_CEREMONY_PARTIAL" }
    };

    public async Task<bool> CanAccess(string userId, string resource, string action)
    {
        var user = await _users.GetById(userId);
        var permissions = RolePermissions.GetValueOrDefault(user.Role, new HashSet<string>());

        var allowed = permissions.Contains(action);

        await _audit.Log(new AuditEntry
        {
            UserId = userId,
            EventType = AuditEventType.AccessCheck,
            Action = action,
            ResourceId = resource,
            Outcome = allowed ? "ALLOWED" : "DENIED"
        });

        return allowed;
    }

    public async Task<string> GetFullPan(string token, string userId, string reason)
    {
        // Check permission
        if (!await CanAccess(userId, token, "REVEAL_PAN"))
        {
            throw new UnauthorizedAccessException("User not authorized for PAN reveal");
        }

        // Validate reason
        if (string.IsNullOrEmpty(reason) || !reason.StartsWith("CB-"))
        {
            throw new ArgumentException("PAN reveal requires valid chargeback reference");
        }

        // Log the reveal (CRITICAL)
        await _audit.Log(new AuditEntry
        {
            UserId = userId,
            EventType = AuditEventType.SensitiveDataAccess,
            Action = "PAN_REVEAL",
            ResourceId = token,
            Details = $"Reason: {reason}"
        });

        // Get PAN from vault
        return await _vault.Detokenize(token);
    }
}

Phase 4: Data Retention Service

Goal: Implement automatic data purging.

public class DataRetentionService : IDataRetentionService
{
    // PCI DSS: Define retention periods
    private static readonly Dictionary<string, TimeSpan> RetentionPeriods = new()
    {
        ["TRANSACTION"] = TimeSpan.FromDays(7 * 365),        // 7 years for tax/legal
        ["AUDIT_LOG"] = TimeSpan.FromDays(365),              // 1 year minimum
        ["CVV"] = TimeSpan.Zero,                             // NEVER stored
        ["FULL_PAN_IN_LOG"] = TimeSpan.Zero,                 // NEVER logged
    };

    public async Task EnforcePolicies()
    {
        // 1. Transactions older than retention period
        var cutoff = DateTime.UtcNow - RetentionPeriods["TRANSACTION"];
        var oldTransactions = await _transactionRepo.GetOlderThan(cutoff);

        foreach (var txn in oldTransactions)
        {
            // Delete token mapping (PAN no longer needed)
            await _vault.DeleteToken(txn.Token);

            // Keep transaction record but clear token reference
            txn.Token = "[PURGED]";
            txn.MaskedPan = "[PURGED]";
            await _transactionRepo.Update(txn);
        }

        await _audit.Log(new AuditEntry
        {
            EventType = AuditEventType.DataRetention,
            Action = "PURGE_OLD_TOKENS",
            Details = $"Purged {oldTransactions.Count} tokens"
        });
    }

    public bool CanStore(string dataType)
    {
        return dataType switch
        {
            "CVV" => false,          // NEVER
            "TRACK_DATA" => false,   // NEVER
            "PIN" => false,          // NEVER
            "PAN" => true,           // Only in vault, encrypted
            "MASKED_PAN" => true,    // Safe
            "EXPIRY" => true,        // Safe
            _ => false               // Default deny
        };
    }
}

Phase 5: Admin Dashboard

Goal: Build web UI with proper access controls.

Key security considerations:

  • Session timeout (PCI: 15 minutes idle)
  • Re-authentication for sensitive actions
  • No PAN in URLs or client-side storage
  • Audit all actions

Phase 6: Compliance Documentation

Goal: Map implementation to PCI DSS requirements.

# PCI DSS Compliance Mapping

## Requirement 3: Protect Stored Account Data

| Sub-Req | Description | Implementation |
|---------|-------------|----------------|
| 3.2 | Do not store SAD after auth | DataRetentionService.CanStore("CVV") = false |
| 3.4 | Render PAN unreadable | TokenVaultService uses AES-256-GCM |
| 3.5 | Protect keys | KeyManagementService with split knowledge |
| 3.6 | Document key procedures | docs/key-management-procedures.md |

## Requirement 7: Restrict Access to CHD

| Sub-Req | Description | Implementation |
|---------|-------------|----------------|
| 7.1 | Limit access by job | AccessControlService.RolePermissions |
| 7.2 | Deny all, allow by exception | Default deny in CanAccess() |

## Requirement 10: Track and Monitor Access

| Sub-Req | Description | Implementation |
|---------|-------------|----------------|
| 10.2 | Implement audit trails | HashChainAuditLogger |
| 10.3 | Record specific elements | AuditEntry structure |
| 10.5 | Secure audit trails | Hash chain, append-only |

Testing Strategy

Unit Tests

[Test]
public async Task Authorize_NeverStoresCvv()
{
    var request = new AuthorizationRequest
    {
        Pan = "4111111111111111",
        Cvv = "123",
        Amount = 100
    };

    var response = await _gateway.Authorize(request);

    // CVV should not appear anywhere in storage
    var transaction = await _transactionRepo.GetById(response.TransactionId);
    Assert.That(transaction.ToString(), Does.Not.Contain("123"));

    var auditLogs = await _auditRepo.GetAll();
    Assert.That(auditLogs.All(l => !l.Details.Contains("123")));
}

[Test]
public async Task RevealPan_RequiresValidReason()
{
    var user = await CreateUser("CHARGEBACK_ANALYST");

    // No reason
    Assert.ThrowsAsync<ArgumentException>(() =>
        _accessControl.GetFullPan("tok_123", user.Id, ""));

    // Invalid reason format
    Assert.ThrowsAsync<ArgumentException>(() =>
        _accessControl.GetFullPan("tok_123", user.Id, "just curious"));

    // Valid reason
    var pan = await _accessControl.GetFullPan("tok_123", user.Id, "CB-2024-0123");
    Assert.That(pan, Is.EqualTo("4111111111111111"));
}

Security Tests

[Test]
public async Task AuditLog_DetectsTampering()
{
    // Create some entries
    await _audit.Log(new AuditEntry { Action = "TEST1" });
    await _audit.Log(new AuditEntry { Action = "TEST2" });
    await _audit.Log(new AuditEntry { Action = "TEST3" });

    // Verify integrity
    Assert.That(await _audit.VerifyIntegrity(), Is.True);

    // Tamper with middle entry
    var entries = await _auditRepo.GetAll();
    entries[1].Details = "TAMPERED";
    await _auditRepo.Update(entries[1]);

    // Should detect tampering
    Assert.That(await _audit.VerifyIntegrity(), Is.False);
}

[Test]
public async Task NetworkSegmentation_DataZoneNotExternallyAccessible()
{
    // Attempt direct connection to data zone from outside
    var client = new HttpClient();

    // Should fail - data zone has no external routes
    Assert.ThrowsAsync<HttpRequestException>(() =>
        client.GetAsync("http://172.16.3.1:5432"));  // Direct DB access
}

Penetration Test Scenarios

# Security Test Cases

## SQL Injection
- [ ] Test all API inputs for SQL injection
- [ ] Test search functionality with payloads

## Access Control
- [ ] Verify TRANSACTION_PROCESSOR cannot reveal PAN
- [ ] Verify SUPPORT_AGENT only sees last 4
- [ ] Test horizontal privilege escalation (access other merchant's data)

## Session Management
- [ ] Verify session timeout (15 min)
- [ ] Test session fixation
- [ ] Test concurrent session limits

## Data Exposure
- [ ] Verify no PAN in URLs
- [ ] Verify no PAN in error messages
- [ ] Verify no PAN in client-side storage
- [ ] Verify no CVV anywhere post-auth

Common Pitfalls & Debugging

Pitfall 1: Logging PANs

Symptom: PAN appears in application logs.

Cause: Generic exception logging includes request body.

Fix: Scrub sensitive data before logging:

public class PanScrubber
{
    private static readonly Regex PanPattern = new(@"\b\d{13,19}\b");

    public static string Scrub(string input)
    {
        return PanPattern.Replace(input, m =>
            m.Value.Length > 4 ? $"****{m.Value[^4..]}" : "****");
    }
}

Pitfall 2: CVV in Memory

Symptom: CVV persists in memory after authorization.

Cause: String interning or GC delays.

Fix: Use SecureString or immediately clear:

public void ClearSensitiveData()
{
    if (_cvv != null)
    {
        var chars = _cvv.ToCharArray();
        Array.Clear(chars, 0, chars.Length);
        _cvv = null;
    }
}

Pitfall 3: Broken Hash Chain

Symptom: Audit verification fails after system restart.

Cause: Last hash not persisted.

Fix: Store last hash in database:

public async Task<string> GetLastHash()
{
    return await _repo.GetLastEntry()?.EntryHash ?? GetGenesisHash();
}

Extensions & Challenges

Extension 1: Real HSM Integration

Integrate with SoftHSM2 for realistic key management.

Extension 2: Merchant Onboarding

Add merchant registration with API key management.

Extension 3: Fraud Detection

Integrate velocity checks and rule-based fraud detection.

Extension 4: Settlement/Clearing

Add batch settlement processing.


Interview Questions This Prepares You For

  1. โ€œWhat data can never be stored after authorization?โ€
    • CVV/CVV2, PIN, full track data
  2. โ€œHow do you implement least privilege for card data?โ€
    • Role-based access, default deny, audit all access
  3. โ€œHow do you make audit logs tamper-evident?โ€
    • Hash chaining, append-only storage, centralized collection
  4. โ€œWhat is the CDE and how do you reduce its scope?โ€
    • Card Data Environment; reduce via tokenization, segmentation
  5. โ€œExplain split knowledge in key management.โ€
    • No single person knows complete key; requires multiple custodians

Resources

Standards

  • PCI DSS v4.0 (pcisecuritystandards.org)
  • PCI PA-DSS
  • NIST SP 800-57 (Key Management)

Books

Topic Book
PCI Compliance โ€œPCI DSS: An Integrated Data Security Standard Guideโ€ by Jim Seaman
Secure Architecture โ€œFundamentals of Software Architectureโ€ by Richards & Ford
Audit Logging โ€œDesigning Data-Intensive Applicationsโ€ by Kleppmann

Self-Assessment Checklist

  • Authorization flow works without storing CVV
  • PAN is tokenized and encrypted at rest
  • Audit logs capture all card data access
  • Hash chain detects log tampering
  • Role-based access prevents unauthorized PAN reveal
  • Network zones properly isolated (Docker simulation)
  • Documentation maps to PCI DSS requirements
  • CVV never appears in any logs or storage

Whatโ€™s Next?

Youโ€™ve built a compliant payment gateway. For the ultimate learning experience, proceed to Project 6: Full Payment Processing Simulator to build an entire payment ecosystem with multiple parties, settlement, and fraud detection.