
Pci Dss Specialist
- 88 installs
- 451 repo stars
- Updated July 21, 2026
- borghei/claude-skills
pci-dss-specialist is a Claude Code skill for PCI DSS v4.0 payment card data security compliance, assessment, and CDE scoping.
About
pci-dss-specialist is a skill for implementing, assessing, and maintaining compliance with PCI DSS v4.0, the payment card industry data security standard. It checks against all 12 requirements, scopes the cardholder data environment, determines the appropriate SAQ type, scores compliance, and identifies gaps with remediation priorities. A developer or compliance owner uses it for PCI scoping, tokenization, and merchant compliance.
- PCI DSS v4.0 compliance assessment against all 12 requirements
- CDE scoping and SAQ type determination from the business model
- Scores compliance per requirement and identifies gaps with remediation priorities
Pci Dss Specialist by the numbers
- 88 all-time installs (skills.sh)
- Ranked #1,056 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
pci-dss-specialist capabilities & compatibility
- Capabilities
- nist csf specialist · nis2 directive specialist · compliance assessment · security audit
- Works with
- stripe
- Use cases
- security audit
What pci-dss-specialist says it does
PCI DSS v4.0 payment card industry data security standard compliance,
Checks against all 12 PCI DSS requirements
Determines appropriate SAQ type based on business model
npx skills add https://github.com/borghei/claude-skills --skill pci-dss-specialistAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 88 |
|---|---|
| repo stars | ★ 451 |
| Last updated | July 21, 2026 |
| Repository | borghei/claude-skills ↗ |
What it does
Assess PCI DSS v4.0 compliance, scope the CDE, and determine the right SAQ type.
Who is it for?
PCI DSS compliance assessments, CDE scoping, SAQ determination, and merchant compliance.
Skip if: Non-payment security frameworks or general application penetration testing.
When should I use this skill?
You need PCI DSS assessment, cardholder data scoping, SAQ selection, or tokenization guidance.
What you get
A PCI DSS v4.0 compliance assessment with per-requirement scores, CDE scope, and remediation priorities.
- Per-requirement compliance scores
- CDE scope and SAQ determination
- Gap report with remediation priorities
By the numbers
- 12 PCI DSS requirements checked
- Per-requirement compliance score 0-100
- 2 bundled tools: pci_compliance_checker.py, pci_scope_analyzer.py
Files
PCI-DSS v4.0 Specialist
Implement, assess, and maintain compliance with the Payment Card Industry Data Security Standard version 4.0 — the global standard for protecting cardholder data in payment processing environments.
---
Table of Contents
- Trigger Phrases
- Quick Start
- Tools
- PCI DSS v4.0 Overview
- 12 Requirements Deep-Dive
- v4.0 Changes from v3.2.1
- CDE Scoping
- SAQ Types and Selection Guide
- Assessment Types
- Merchant and Service Provider Levels
- Infrastructure Controls
- PCI DSS Compliance Roadmap
- Reference Guides
- Validation Checkpoints
---
Trigger Phrases
Use this skill when you hear:
- "PCI DSS"
- "payment card security"
- "cardholder data"
- "PCI compliance"
- "payment security"
- "PCI assessment"
- "SAQ"
- "ROC"
- "QSA"
- "credit card security"
- "payment processing security"
- "tokenization"
- "CDE scoping"
- "merchant level compliance"
---
Quick Start
Check PCI Compliance Status
python scripts/pci_compliance_checker.py --input controls.json --output compliance_report.jsonDetermine SAQ Type
python scripts/pci_scope_analyzer.py --input business_model.json --output scope_report.jsonGenerate Compliance Gap Report (Markdown)
python scripts/pci_compliance_checker.py --input controls.json --format markdown --output gap_report.mdAnalyze CDE Scope
python scripts/pci_scope_analyzer.py --input business_model.json --format markdown --output scope_analysis.md---
Tools
pci_compliance_checker.py
Comprehensive PCI DSS v4.0 compliance assessment engine.
Capabilities:
- Checks against all 12 PCI DSS requirements
- Validates cardholder data environment scope
- Assesses technical controls (encryption, access, logging)
- Scores compliance per requirement (0-100)
- Identifies gaps with remediation priorities
- Generates JSON or Markdown output
Usage:
# Full compliance check
python scripts/pci_compliance_checker.py \
--input controls.json \
--output report.json
# Markdown report for stakeholders
python scripts/pci_compliance_checker.py \
--input controls.json \
--format markdown \
--output compliance_report.md
# Check specific requirements only
python scripts/pci_compliance_checker.py \
--input controls.json \
--requirements 3,4,7,8 \
--output data_security_report.jsonInput Format (controls.json):
{
"organization": "Acme Payments",
"assessment_date": "2026-03-09",
"merchant_level": 2,
"requirements": {
"1": {
"network_segmentation": true,
"firewall_rules_documented": true,
"waf_deployed": true,
"inbound_traffic_restricted": true,
"outbound_traffic_restricted": false,
"wireless_networks_segmented": true,
"notes": "Outbound filtering planned for Q2"
},
"3": {
"pan_storage_minimized": true,
"pan_masked_when_displayed": true,
"pan_encrypted_at_rest": true,
"encryption_algorithm": "AES-256",
"key_management_procedures": true,
"tokenization_implemented": true,
"sad_not_stored_after_auth": true,
"notes": "Tokenization covers 95% of stored PANs"
}
}
}pci_scope_analyzer.py
CDE scoping and SAQ type determination engine.
Capabilities:
- Determines appropriate SAQ type based on business model
- Maps cardholder data environment boundaries
- Identifies connected systems and security-impacting systems
- Generates scoping worksheet with system classifications
- Recommends scope reduction strategies
Usage:
# Determine SAQ type and CDE scope
python scripts/pci_scope_analyzer.py \
--input business_model.json \
--output scope_report.json
# Markdown scoping worksheet
python scripts/pci_scope_analyzer.py \
--input business_model.json \
--format markdown \
--output scoping_worksheet.mdInput Format (business_model.json):
{
"organization": "Acme Payments",
"business_type": "e-commerce",
"payment_channels": ["web", "mobile_app"],
"card_present": false,
"card_not_present": true,
"stores_pan": false,
"processes_pan": false,
"transmits_pan": false,
"payment_processor": "Stripe",
"uses_iframe_redirect": true,
"uses_p2pe": false,
"annual_transactions": 500000,
"card_brands": ["visa", "mastercard", "amex"],
"systems": [
{
"name": "web-frontend",
"type": "web_server",
"handles_cardholder_data": false,
"connected_to_cde": false,
"security_impacting": true,
"description": "Customer-facing e-commerce site with iframe payment"
},
{
"name": "payment-api",
"type": "application_server",
"handles_cardholder_data": false,
"connected_to_cde": true,
"security_impacting": true,
"description": "API server that communicates with Stripe"
}
]
}---
PCI DSS v4.0 Overview
What Is PCI DSS?
The Payment Card Industry Data Security Standard (PCI DSS) is a global security standard developed by the PCI Security Standards Council (PCI SSC), founded by American Express, Discover, JCB, Mastercard, and Visa. It applies to all entities that store, process, or transmit cardholder data (CHD) or sensitive authentication data (SAD).
PCI DSS v4.0 Timeline
| Date | Milestone |
|---|---|
| March 2022 | PCI DSS v4.0 published |
| March 2024 | v3.2.1 retired; v4.0 is the only active version |
| March 31, 2025 | All future-dated requirements become mandatory |
All organizations must now comply with the full PCI DSS v4.0 standard, including all previously future-dated requirements.
What Data Is Protected
Cardholder Data (CHD):
- Primary Account Number (PAN) — the credit/debit card number
- Cardholder Name (when stored with PAN)
- Service Code
- Expiration Date
Sensitive Authentication Data (SAD): Must NEVER be stored after authorization, even if encrypted.
- Full track data (magnetic stripe, chip)
- CVV/CVC/CAV2/CID (card verification codes)
- PIN and PIN block
---
12 Requirements Deep-Dive
Requirement 1: Install and Maintain Network Security Controls
Objective: Protect the cardholder data environment through network security controls.
Key Sub-Requirements:
- 1.2.1 — Network security controls (NSCs) are configured and maintained
- 1.2.5 — All services, protocols, and ports allowed are identified and approved
- 1.2.8 — NSC configuration files are secured and synchronized
- 1.3.1 — Inbound traffic to the CDE is restricted to only necessary traffic
- 1.3.2 — Outbound traffic from the CDE is restricted to only necessary traffic
- 1.4.1 — NSCs are implemented between trusted and untrusted networks
- 1.4.5 — Disclosure of internal IP addresses is prevented
- 1.5.1 — Security controls on all computing devices connecting via untrusted networks
Implementation Guidance:
- Deploy next-generation firewalls (NGFW) at CDE boundaries
- Implement Web Application Firewalls (WAF) for web-facing payment applications
- Use network segmentation to isolate CDE from corporate network
- Restrict inbound to CDE: only necessary ports/protocols from known sources
- Restrict outbound from CDE: only approved destinations (payment processor, updates)
- Document all firewall rules with business justification
- Review firewall rules at least every 6 months
- Implement micro-segmentation where possible
---
Requirement 2: Apply Secure Configurations to All System Components
Objective: Ensure all systems are configured securely with no unnecessary default settings.
Key Sub-Requirements:
- 2.2.1 — Configuration standards developed for all system components
- 2.2.2 — Vendor default accounts managed (changed, disabled, or removed)
- 2.2.3 — Primary functions requiring different security levels are managed (one primary function per server or use containerization)
- 2.2.4 — Only necessary services, protocols, daemons, and functions are enabled
- 2.2.5 — Insecure services are secured if present
- 2.2.6 — System security parameters are configured to prevent misuse
- 2.2.7 — Non-console administrative access is encrypted
Implementation Guidance:
- Apply CIS Benchmarks as baseline configurations
- Change ALL vendor default passwords before deployment
- Remove or disable unnecessary services, protocols, and daemon
- Harden operating systems using DISA STIGs or CIS Benchmarks
- Enforce encrypted administrative access (SSH, HTTPS, TLS 1.2+)
- Use configuration management tools for consistency (Ansible, Chef, Puppet)
- Deploy from hardened golden images
---
Requirement 3: Protect Stored Account Data
Objective: Minimize stored data and protect it with strong cryptography.
Key Sub-Requirements:
- 3.2.1 — Data retention and disposal policies implemented
- 3.3.1 — SAD not retained after authorization (even if encrypted)
- 3.3.2 — SAD that is stored before authorization is encrypted using strong cryptography
- 3.4.1 — PAN is masked when displayed (show only first 6 and last 4 digits max)
- 3.5.1 — PAN is rendered unreadable anywhere it is stored (encryption, tokenization, truncation, or hashing)
- 3.6.1 — Cryptographic key management procedures are defined and implemented
- 3.7.1-3.7.9 — Comprehensive key management lifecycle
Implementation Guidance:
- Minimize PAN storage — do not store unless absolutely necessary
- Use tokenization to replace PANs with non-reversible tokens
- Encrypt stored PAN with AES-256 (or equivalent)
- Never store SAD (CVV, track data, PIN) after authorization — period
- Mask PAN in all displays: show max first 6 / last 4 digits
- Implement HSM-based key management for encryption keys
- Rotate encryption keys at least annually
- Use split knowledge and dual control for key management
- Maintain key inventory with custodian assignments
- Use DUKPT or ANSI X9.24 for key management in POS environments
Tokenization vs Encryption Decision:
| Factor | Tokenization | Encryption |
|---|---|---|
| Reversibility | Non-reversible (preferred) | Reversible with key |
| Scope reduction | Removes systems from CDE scope | Systems remain in scope |
| Performance | Faster lookup (token maps) | Encryption/decryption overhead |
| Use case | Card-on-file, recurring billing | Data that must be recovered |
| Recommendation | Prefer tokenization when possible | Use when PAN recovery is required |
---
Requirement 4: Protect Cardholder Data with Strong Cryptography During Transmission
Objective: Encrypt CHD whenever transmitted over open, public networks.
Key Sub-Requirements:
- 4.2.1 — Strong cryptography and security protocols protect CHD during transmission over open, public networks
- 4.2.1.1 — Trusted certificates for PAN transmission over open, public networks
- 4.2.1.2 — Wireless networks transmitting PAN use industry best practices for strong cryptography
- 4.2.2 — PAN is secured with strong cryptography whenever sent via end-user messaging technologies
Implementation Guidance:
- Use TLS 1.2 as minimum, prefer TLS 1.3
- Disable SSL, TLS 1.0, TLS 1.1 entirely
- Use strong cipher suites (ECDHE key exchange, AES-GCM)
- Implement certificate pinning for mobile payment apps
- Deploy HSTS (HTTP Strict Transport Security) on all payment pages
- Use mTLS (mutual TLS) between internal CDE components
- Monitor certificate expiration and automate renewal
- Never send PAN via email, chat, or SMS unencrypted
---
Requirement 5: Protect All Systems and Networks from Malicious Software
Objective: Defend all systems against malware.
Key Sub-Requirements:
- 5.2.1 — Anti-malware solution(s) deployed on all system components
- 5.2.2 — Anti-malware solution performs periodic and real-time scans
- 5.2.3 — For systems not commonly affected by malware, periodic evaluations performed
- 5.3.1 — Anti-malware mechanisms are kept current
- 5.3.2 — Anti-malware performs periodic and real-time scans
- 5.3.3 — For removable media, anti-malware scans automatically upon insertion
- 5.3.4 — Audit logs for anti-malware are enabled and retained
- 5.3.5 — Anti-malware cannot be disabled or altered by users (except case-by-case with management approval for limited time, logged)
- 5.4.1 — Mechanisms detect and protect against phishing attacks
Implementation Guidance:
- Deploy EDR/XDR on all endpoints (workstations, servers, POS terminals)
- Ensure real-time scanning with automatic definition updates
- Enable email-based anti-phishing controls (SPF, DKIM, DMARC, sandbox)
- Implement application allowlisting on POS and critical CDE systems
- Log all anti-malware events and integrate with SIEM
- For Linux/Unix systems: document risk evaluation and deploy appropriate controls
---
Requirement 6: Develop and Maintain Secure Systems and Software
Objective: Protect against vulnerabilities through secure development and timely patching.
Key Sub-Requirements:
- 6.2.1 — Custom software developed securely (OWASP, CERT, SANS)
- 6.2.2 — Developer training in secure coding at least annually
- 6.2.3 — Custom software reviewed before release to identify vulnerabilities
- 6.2.4 — Software engineering techniques prevent common vulnerabilities (OWASP Top 10)
- 6.3.1 — Security vulnerabilities identified and managed (vulnerability management process)
- 6.3.2 — Software inventory maintained to enable vulnerability management
- 6.3.3 — Critical and high vulnerabilities patched within defined timeframes
- 6.4.1 — Public-facing web apps protected against known attacks (WAF or code review)
- 6.4.2 — Public-facing web apps have automated technical solution to detect and prevent web-based attacks (WAF in blocking mode)
- 6.4.3 — All payment page scripts managed, authorized, and integrity-ensured
- 6.5.1-6.5.6 — Change management procedures for all CDE system changes
Implementation Guidance:
- Implement SDLC with security gates (design review, code review, security testing)
- Train developers annually on secure coding (OWASP Top 10, CWE/SANS Top 25)
- Deploy WAF in blocking mode for all public-facing payment applications
- Patch critical vulnerabilities within 30 days, high within 60 days
- Implement Content Security Policy (CSP) and Subresource Integrity (SRI) for payment pages
- Monitor and authorize all JavaScript on payment pages (6.4.3 is critical for e-commerce)
- Conduct code reviews (manual or automated SAST) for all custom payment code
- Maintain complete software inventory with versions
---
Requirement 7: Restrict Access to System Components and Cardholder Data by Business Need to Know
Objective: Limit access to CHD to only those with a legitimate business need.
Key Sub-Requirements:
- 7.2.1 — Access control model defined and includes all system components
- 7.2.2 — Access assigned based on job classification and function
- 7.2.3 — Required privileges approved by authorized personnel
- 7.2.4 — All user accounts and related access privileges reviewed at least every 6 months
- 7.2.5 — All application and system accounts assigned and managed based on least privilege
- 7.2.5.1 — Access for application and system accounts reviewed periodically
- 7.2.6 — All user access to query repositories of stored CHD is restricted
Implementation Guidance:
- Implement role-based access control (RBAC) for all CDE systems
- Document access control policy with defined roles and permissions
- Enforce least privilege — users get minimum access needed
- Review all CDE access every 6 months and recertify
- Restrict database query access to CHD (no ad hoc SELECT * from card_data)
- Separate duties — no single person should control all aspects of a transaction
- Use automated identity governance for access provisioning and reviews
---
Requirement 8: Identify Users and Authenticate Access to System Components
Objective: Ensure all access to CDE is identified and strongly authenticated.
Key Sub-Requirements:
- 8.2.1 — All users assigned a unique ID before access
- 8.2.2 — Group, shared, or generic accounts not used (exceptions must be documented)
- 8.3.1 — All user access to CDE authenticated with at least one factor
- 8.3.2 — Strong cryptography used for all authentication factors
- 8.3.4 — Invalid authentication attempts limited (lockout after max 10 attempts for min 30 minutes)
- 8.3.6 — New passwords/passphrases: minimum 12 characters (or 8 if system cannot support 12), containing both numeric and alphabetic
- 8.3.9 — Passwords/passphrases changed at least every 90 days (or continuous risk-based approach)
- 8.4.1 — MFA implemented for all non-console access into CDE for administrative access
- 8.4.2 — MFA implemented for all access into the CDE
- 8.4.3 — MFA for all remote network access originating from outside the entity's network
- 8.5.1 — MFA implementation not susceptible to replay attacks, cannot be bypassed
- 8.6.1 — Interactive login for system/service accounts managed, disabled when not needed
- 8.6.2 — Passwords/passphrases for system/service accounts not hard-coded in scripts
- 8.6.3 — Passwords/passphrases for system/service accounts changed periodically and upon suspicion of compromise
Implementation Guidance:
- MFA is mandatory for ALL access into the CDE (not just admin) — this is a v4.0 change
- Use phishing-resistant MFA (FIDO2/WebAuthn, hardware keys) where possible
- Minimum 12-character passwords with complexity requirements
- Implement account lockout after 10 failed attempts
- Never use shared accounts in the CDE
- Manage service accounts — no hard-coded passwords, rotate periodically
- Deploy PAM for administrative access to CDE systems
- Log all authentication events and integrate with SIEM
---
Requirement 9: Restrict Physical Access to Cardholder Data
Objective: Prevent unauthorized physical access to systems that store, process, or transmit CHD.
Key Sub-Requirements:
- 9.2.1 — Appropriate facility entry controls for CDE
- 9.2.3 — Physical access to wireless access points, gateways, and networking devices restricted
- 9.2.4 — Console access to sensitive areas controlled
- 9.3.1 — Authorization for physical access reviewed at least every 6 months
- 9.3.2 — Procedures for visitor identification and management
- 9.3.3 — Visitor badges or identification surrendered upon departure
- 9.4.1 — Media with CHD physically secured
- 9.4.5 — Inventory of electronic media with CHD maintained
- 9.4.6 — Hard-copy materials with CHD destroyed when no longer needed (cross-cut shred, incinerate)
- 9.4.7 — Electronic media with CHD rendered unrecoverable (degauss, crypto-erase, destroy)
- 9.5.1 — POI (Point of Interaction) devices protected from tampering and substitution
Implementation Guidance:
- Implement badge access to server rooms and data centers housing CDE
- Deploy CCTV with 90-day retention for CDE physical locations
- Maintain visitor logs with escort requirements
- Inspect POS terminals regularly for skimming devices (daily/weekly)
- Cross-cut shred all paper containing CHD
- Cryptographically erase or physically destroy media before disposal
- Restrict access to network infrastructure components
---
Requirement 10: Log and Monitor All Access to System Components and Cardholder Data
Objective: Create comprehensive audit trails for all access to CDE and CHD.
Key Sub-Requirements:
- 10.2.1 — Audit logs capture all individual user access to CHD
- 10.2.1.1 — Audit logs capture all individual access to CHD
- 10.2.1.2 — All actions by any individual with administrative access are logged
- 10.2.1.3 — Access to all audit logs
- 10.2.1.4 — Invalid logical access attempts
- 10.2.1.5 — Changes to identification and authentication mechanisms
- 10.2.1.6 — Initialization, stopping, or pausing of audit logs
- 10.2.1.7 — Creation and deletion of system-level objects
- 10.2.2 — Audit logs include required details (user ID, event type, date/time, success/failure, origin, data/component affected)
- 10.3.1 — Read access to audit logs is restricted
- 10.3.2 — Audit log files are protected from modification
- 10.3.3 — Audit log files are backed up to a central log server
- 10.3.4 — File integrity monitoring on audit logs
- 10.4.1 — Audit logs reviewed at least daily for security events
- 10.4.1.1 — Automated mechanisms perform audit log reviews
- 10.4.2 — Logs of all CDE components are reviewed periodically
- 10.5.1 — Retain audit log history for at least 12 months (3 months immediately available)
- 10.6.1 — System clocks synchronized using NTP
- 10.6.2 — Time data protected
- 10.6.3 — Time settings received from industry-accepted sources
Implementation Guidance:
- Deploy SIEM for centralized log collection and automated review
- Log all access to CHD, administrative actions, and security events
- Protect log integrity with WORM storage or blockchain-based logging
- Retain logs for 12 months minimum (3 months online, remainder archived)
- Synchronize all system clocks to NTP (stratum 2 or better)
- Review logs daily using automated correlation rules
- Alert on suspicious patterns (multiple failed logins, after-hours access, bulk data access)
---
Requirement 11: Test Security of Systems and Networks Regularly
Objective: Regularly test security controls, systems, and networks to verify they work.
Key Sub-Requirements:
- 11.2.1 — Authorized and unauthorized wireless access points managed
- 11.2.2 — Wireless analyzer scans at least quarterly
- 11.3.1 — Internal vulnerability scans at least quarterly
- 11.3.1.1 — All other applicable vulnerabilities (non-critical/high) addressed and rescanned
- 11.3.1.3 — Internal scans after significant changes
- 11.3.2 — External vulnerability scans by ASV at least quarterly
- 11.4.1 — External penetration testing at least annually and after significant changes
- 11.4.3 — Internal penetration testing at least annually and after significant changes
- 11.4.4 — Vulnerabilities found during penetration testing are corrected
- 11.4.5 — Network segmentation tested at least annually (every 6 months for service providers)
- 11.5.1 — IDS/IPS deployed to monitor traffic into and within CDE
- 11.5.1.1 — IDS/IPS alerts generated for suspected compromises
- 11.5.2 — Change-detection mechanism (file integrity monitoring) deployed on critical files
- 11.6.1 — A change and tamper-detection mechanism deployed for payment pages
Implementation Guidance:
- Quarterly internal vulnerability scans with all high/critical resolved before pass
- Quarterly external ASV scans (must achieve passing scan)
- Annual external and internal penetration tests (by qualified tester)
- Pen tests must test network layer and application layer
- Deploy IDS/IPS at CDE perimeter and critical internal points
- FIM on critical system files, configuration files, and content files
- Wireless scanning quarterly to detect rogue access points
- Test network segmentation annually to verify CDE isolation
- Deploy change/tamper detection on payment page scripts (ties to 6.4.3)
---
Requirement 12: Support Information Security with Organizational Policies and Programs
Objective: Maintain an information security policy that addresses all PCI DSS requirements.
Key Sub-Requirements:
- 12.1.1 — Information security policy established, published, maintained, disseminated
- 12.1.2 — Roles and responsibilities defined for all requirements
- 12.1.3 — Information security policy reviewed at least annually
- 12.2.1 — Acceptable use policies for end-user technologies
- 12.3.1 — Targeted risk analysis for each requirement with customized approach flexibility
- 12.3.2 — Targeted risk analysis for each requirement met with customized approach
- 12.4.1 — Executive management establishes responsibility for protection of CHD
- 12.4.2 — Reviews performed at least quarterly (service providers: operations compliance)
- 12.5.1 — PCI DSS scope documented and confirmed annually
- 12.5.2 — PCI DSS scope documented and confirmed upon significant changes
- 12.5.3 — Significant changes resulting in scope changes trigger assessment
- 12.6.1 — Security awareness program implemented
- 12.6.2 — Awareness program reviewed at least annually
- 12.6.3 — Personnel receive awareness training upon hire and at least annually
- 12.6.3.1 — Training includes awareness of threats (phishing, social engineering)
- 12.8.1-12.8.5 — TPSPs (Third-Party Service Providers) managed
- 12.9.1 — TPSPs acknowledge responsibility for CHD security
- 12.10.1 — Incident response plan created and ready for activation
- 12.10.2 — IRP reviewed and tested at least annually
- 12.10.4 — Personnel with incident response responsibilities are trained
- 12.10.5 — IRP includes monitoring and responding to alerts
- 12.10.6 — IRP is updated based on lessons learned and industry developments
- 12.10.7 — Incident response procedures are in place to respond to detection of stored PAN anywhere not expected
Implementation Guidance:
- Create comprehensive security policy covering all 12 requirements
- Conduct targeted risk analysis for any customized approach implementations
- Confirm PCI DSS scope annually and after any significant changes
- Deliver security awareness training at hire and annually
- Include phishing awareness, social engineering, and CHD handling in training
- Manage all third-party service providers (maintain list, require compliance attestation)
- Maintain and test incident response plan at least annually
- Include specific procedures for unauthorized PAN discovery
---
v4.0 Changes from v3.2.1
Major Changes
1. Customized Approach (NEW) Organizations can now meet PCI DSS requirements using a "customized approach" rather than the traditional "defined approach." This allows organizations to design their own security controls, provided they meet the security objective of each requirement. Requires targeted risk analysis documentation and validation by QSA.
2. Targeted Risk Analysis v4.0 requires organizations to perform documented, targeted risk analyses for certain requirements (e.g., frequency of activities, password/passphrase policies). This replaces the "one-size-fits-all" approach.
3. Enhanced Authentication Requirements
- MFA required for ALL access into the CDE (not just remote admin)
- Minimum password length increased to 12 characters (from 7)
- 90-day password rotation or continuous risk-based authentication
4. Payment Page Script Security (6.4.3) All scripts on payment pages must be managed, authorized, and monitored for integrity. This addresses Magecart-style attacks.
5. Anti-Phishing Mechanisms (5.4.1) Organizations must implement automated anti-phishing mechanisms (e.g., DMARC, email sandbox).
6. Encryption of PAN Over Trusted Internal Networks (4.2.1) PAN must now be encrypted during transmission over ALL networks, not just public networks. Internal network encryption required.
7. Automated Log Review (10.4.1.1) Automated mechanisms must perform audit log reviews — manual-only review no longer sufficient.
Summary of Future-Dated Requirements (Now Mandatory)
All of the following became mandatory as of March 31, 2025:
| Requirement | What Changed |
|---|---|
| 3.3.2 | SAD encrypted before authorization if stored |
| 3.5.1.2 | Disk-level encryption no longer satisfies requirement (must be above disk) |
| 5.3.3 | Anti-malware scans on removable media |
| 5.4.1 | Anti-phishing mechanisms required |
| 6.3.2 | Software inventory for vulnerability management |
| 6.4.2 | WAF in blocking mode for public web apps |
| 6.4.3 | Payment page script management |
| 8.3.6 | 12-character minimum passwords |
| 8.4.2 | MFA for all CDE access |
| 8.5.1 | MFA replay attack protection |
| 8.6.1-3 | System/service account management |
| 10.4.1.1 | Automated log review |
| 10.7.2 | Detect failures of critical security controls |
| 11.3.1.1 | Manage all vulnerabilities (not just high/critical) |
| 11.4.7 | Multi-tenant service provider pen testing |
| 11.5.1.1 | IDS/IPS alerts for suspected compromise |
| 11.6.1 | Payment page tamper detection |
| 12.3.1 | Targeted risk analysis |
| 12.6.3.1 | Phishing/social engineering in awareness training |
| 12.10.7 | Respond to unexpected stored PAN |
---
Cardholder Data Environment Scoping
CDE Definition
The Cardholder Data Environment (CDE) includes: 1. System components that store, process, or transmit CHD/SAD — These are directly in scope 2. System components on the same network segment — These are in scope unless segmented 3. System components that connect to or provide security services — Connected-to and security-impacting systems
System Classification
| Category | Definition | In Scope? | Examples |
|---|---|---|---|
| CDE Systems | Store, process, or transmit CHD | Yes — Full scope | Payment servers, databases with PAN, POS terminals |
| Connected-to | Direct connectivity to CDE | Yes — Full scope | DNS servers for CDE, AD/LDAP for CDE authentication |
| Security-Impacting | Provide security services to CDE | Yes — Full scope | SIEM, AV server, patch management for CDE systems |
| Out of Scope | No connectivity, no CHD, no security impact | No | Isolated HR systems, marketing servers |
Scope Reduction Strategies
1. Tokenization: Replace PAN with non-reversible tokens. Systems that only handle tokens are out of scope.
2. P2PE (Point-to-Point Encryption): Validated P2PE solutions encrypt cardholder data at the point of interaction. Merchants using validated P2PE can use SAQ P2PE (reduced scope).
3. Network Segmentation: Isolate CDE on a separate network segment with firewalls and strict access controls. Non-CDE segments are out of scope.
4. Outsource Processing: Use third-party payment processors (Stripe, Braintree, Adyen) to handle all CHD. The merchant never touches cardholder data.
5. iFrame/Redirect: For e-commerce, use the payment processor's hosted payment page (iFrame or redirect). The merchant's systems never receive cardholder data.
---
SAQ Types and Selection Guide
Self-Assessment Questionnaires (SAQs) are validation tools for merchants and service providers not required to undergo a full on-site assessment (ROC).
| SAQ Type | Applies To | CHD Handling | Questions |
|---|---|---|---|
| SAQ A | E-commerce or MOTO merchants | All payment processing fully outsourced; no electronic storage/processing/transmission of CHD | ~30 |
| SAQ A-EP | E-commerce merchants | Payment page elements from third party, but merchant website impacts security of payment transaction | ~140 |
| SAQ B | Merchants with standalone POS (dial-out terminals) | Imprint-only or standalone dial-out terminals; no electronic CHD storage | ~40 |
| SAQ B-IP | Merchants with standalone IP-connected POS | Standalone POS terminals connected via IP; no electronic CHD storage | ~80 |
| SAQ C | Merchants with payment app systems connected to internet | Payment application connected to internet; no electronic CHD storage | ~160 |
| SAQ C-VT | Merchants with web-based virtual terminals | Manual entry via virtual terminal from processor's web-based solution; no electronic CHD storage | ~80 |
| SAQ D (Merchant) | All other merchants | Does not qualify for other SAQ types | ~330 |
| SAQ D (Service Provider) | Service providers | Service providers eligible for SAQ | ~330 |
| SAQ P2PE | Merchants using validated P2PE | Hardware terminals with validated P2PE solution; no electronic CHD storage | ~30 |
SAQ Selection Decision Tree
Does your organization store, process, or transmit CHD?
├── No → Not subject to PCI DSS
└── Yes → Continue
│
Are you a Service Provider?
├── Yes → SAQ D (Service Provider) or ROC
└── No (Merchant) → Continue
│
Do you store CHD electronically?
├── Yes → SAQ D (Merchant)
└── No → Continue
│
E-commerce only?
├── Yes → Do you fully outsource all payment processing?
│ ├── Yes (iFrame/redirect, no scripts on payment page) → SAQ A
│ └── No (payment page on your server or scripts affecting payment) → SAQ A-EP
├── Card-present (POS)?
│ ├── Using validated P2PE? → SAQ P2PE
│ ├── Standalone dial-out terminal? → SAQ B
│ ├── Standalone IP-connected terminal? → SAQ B-IP
│ └── Payment application system? → SAQ C
└── Virtual terminal only? → SAQ C-VT---
Assessment Types
Self-Assessment Questionnaire (SAQ)
Who: Level 2-4 merchants (unless acquirer requires ROC) What: Self-assessment using applicable SAQ type Frequency: Annual Output: Completed SAQ + Attestation of Compliance (AOC)
Report on Compliance (ROC)
Who: Level 1 merchants, all Level 1 service providers What: On-site assessment by Qualified Security Assessor (QSA) Frequency: Annual Output: ROC document + AOC
Attestation of Compliance (AOC)
Who: All entities, accompanies SAQ or ROC What: Executive summary confirming compliance status Frequency: Annual, accompanies assessment Output: Signed AOC form
---
Merchant and Service Provider Levels
Merchant Levels
| Level | Annual Visa Transactions | Assessment Required |
|---|---|---|
| Level 1 | Over 6 million | Annual ROC by QSA + quarterly ASV scan |
| Level 2 | 1 million to 6 million | Annual SAQ + quarterly ASV scan |
| Level 3 | 20,000 to 1 million (e-commerce) | Annual SAQ + quarterly ASV scan |
| Level 4 | Under 20,000 (e-commerce) or up to 1 million (other) | Annual SAQ + quarterly ASV scan (recommended) |
Note: Card brands and acquirers may have different thresholds. Check with your acquirer.
Service Provider Levels
| Level | Annual Transactions | Assessment Required |
|---|---|---|
| Level 1 | Over 300,000 | Annual ROC by QSA + quarterly ASV scan |
| Level 2 | Under 300,000 | Annual SAQ D + quarterly ASV scan |
---
Infrastructure Controls
Network Segmentation Validation
Purpose: Verify CDE is properly isolated from non-CDE networks.
Testing Methods:
- Firewall rule review — verify only approved traffic can cross CDE boundary
- Penetration testing from non-CDE segments attempting to reach CDE
- Traffic analysis confirming no unintended data flows
- VLAN hopping tests
- ARP spoofing tests
Frequency: Annually (every 6 months for service providers)
DNS Security for Payment Systems
- Implement DNSSEC for all CDE domain names
- Use internal DNS servers for CDE (not public resolvers)
- Monitor DNS queries from CDE for data exfiltration indicators
- Restrict CDE DNS queries to approved destinations only
- Implement DNS sinkholing for known malicious domains
TLS Configuration for Payment Channels
- Minimum TLS 1.2, prefer TLS 1.3 for all payment communications
- Strong cipher suites only: ECDHE key exchange, AES-GCM
- HSTS with long max-age on all payment-related web pages
- Certificate transparency monitoring for payment domains
- Automated certificate renewal (Let's Encrypt, ACME protocol)
- mTLS between CDE microservices
- Certificate pinning for mobile payment applications
Endpoint Security for POS Systems
- Harden POS operating systems (application allowlisting)
- Deploy endpoint protection with anti-tamper capabilities
- Implement POS-specific network segmentation
- Regular POS terminal inspection for skimming devices
- Remote POS management via encrypted channels only
- Disable USB ports and external interfaces on POS terminals
- Monitor POS terminal integrity
Cloud Security for Payment Processing
AWS:
- Use VPC with private subnets for CDE workloads
- AWS KMS or CloudHSM for encryption key management
- GuardDuty for threat detection in CDE
- Config rules for CDE compliance monitoring
- S3 bucket policies preventing public access to CHD
- Restrict IAM roles accessing CDE resources
Azure:
- Azure Virtual Network with NSGs for CDE isolation
- Azure Key Vault (HSM-backed) for key management
- Microsoft Defender for Cloud for CDE monitoring
- Azure Policy for CDE compliance enforcement
- Storage Service Encryption with customer-managed keys
GCP:
- VPC Service Controls for CDE isolation
- Cloud KMS or Cloud HSM for key management
- Security Command Center for CDE visibility
- Organization policies restricting CDE resource configuration
- BigQuery with column-level encryption for analytics on payment data
Container/Kubernetes Security in CDE
- Scan container images for vulnerabilities before deployment
- Use private container registries with signed images
- Implement Kubernetes RBAC with CDE-specific namespaces
- Pod Security Standards (Restricted) for CDE pods
- Network policies isolating CDE pods
- No privileged containers in CDE
- Secrets management via external vault (not Kubernetes secrets)
- Service mesh (Istio, Linkerd) with mTLS for CDE pod-to-pod traffic
- Runtime security monitoring (Falco, Sysdig)
API Security for Payment APIs
- OAuth 2.0 / OpenID Connect for API authentication
- API rate limiting and throttling
- Input validation and output encoding for all API parameters
- API gateway with WAF protection
- API versioning with deprecated version retirement
- Mutual TLS for server-to-server API calls
- PCI-compliant API logging (mask PAN in logs)
- API security testing (DAST) in CI/CD pipeline
Tokenization Architecture
┌───────────────┐ ┌──────────────────┐ ┌────────────────┐
│ Customer │────▶│ Payment Page │────▶│ Token Service │
│ (Browser) │ │ (Merchant) │ │ (Processor) │
└───────────────┘ └──────────────────┘ └──────┬─────────┘
│
┌────────▼────────┐
│ Token Vault │
│ (PAN → Token) │
└────────┬────────┘
│
┌────────▼────────┐
│ Card Network │
│ (Detokenize) │
└─────────────────┘Key Points:
- Token format should be indistinguishable from PAN (same length, passes Luhn check is optional)
- Token vault must be PCI DSS compliant
- Tokens should be non-reversible without access to the vault
- Use format-preserving tokens when legacy systems require card-like values
Encryption Key Management
DUKPT (Derived Unique Key Per Transaction):
- Used in POS environments
- Each transaction uses a unique encryption key
- Derived from a Base Derivation Key (BDK)
- Protects against mass compromise from single key exposure
P2PE (Point-to-Point Encryption):
- Encrypts at the terminal (point of interaction)
- Decrypts only at the processor's secure environment
- Validated P2PE solutions listed on PCI SSC website
- Significantly reduces merchant's CDE scope
Key Lifecycle:
- Generation: Use HSM or certified key generation
- Distribution: Split knowledge, dual control
- Storage: HSM or encrypted key storage
- Usage: Track key usage and enforce permitted operations
- Rotation: Annual rotation minimum; immediately upon suspected compromise
- Destruction: Cryptographic erase with verification
---
PCI DSS Compliance Roadmap
Phase 1: Scope and Assess (Months 1-2)
1. Determine Merchant/SP Level — Transaction volume determines assessment type 2. Define CDE Scope — Map all systems that store, process, or transmit CHD 3. Identify SAQ Type — Use the scope analyzer tool 4. Conduct Gap Assessment — Use the compliance checker tool 5. Document Scope — Create CDE inventory and data flow diagram
Deliverables:
- CDE scope document with data flow diagrams
- Gap assessment report with prioritized findings
- SAQ type determination
- Project plan and budget estimate
Phase 2: Quick Wins and Critical Gaps (Months 3-4)
1. Stop storing SAD — Eliminate any storage of CVV, track data, PIN immediately 2. Enable MFA for CDE — Deploy MFA for all CDE access (Req 8.4.2) 3. Enable encryption — Encrypt stored PAN and PAN in transit (Req 3, 4) 4. Deploy logging — Centralize logs from CDE systems (Req 10) 5. Update passwords — Enforce 12-character minimum (Req 8.3.6)
Phase 3: Core Controls (Months 5-7)
1. Network segmentation — Isolate CDE, deploy firewalls, restrict traffic (Req 1) 2. Hardening — Apply CIS Benchmarks to all CDE systems (Req 2) 3. Access controls — Implement RBAC, least privilege, access reviews (Req 7) 4. Vulnerability management — Deploy scanning, establish patch SLAs (Req 6, 11) 5. Anti-malware — Deploy EDR/XDR, anti-phishing controls (Req 5)
Phase 4: Advanced Controls (Months 8-10)
1. WAF deployment — Deploy in blocking mode for payment web apps (Req 6.4.2) 2. Payment page security — Manage scripts, deploy tamper detection (Req 6.4.3, 11.6.1) 3. Penetration testing — External and internal pen tests (Req 11.4) 4. IDS/IPS — Deploy at CDE perimeter and internal segments (Req 11.5) 5. Physical security — Secure data centers, POS terminals, media (Req 9)
Phase 5: Policy, Training, and Validation (Months 11-12)
1. Security policy — Comprehensive policy covering all 12 requirements (Req 12) 2. Awareness training — Deploy training program with phishing simulation (Req 12.6) 3. Third-party management — Assess and document all TPSPs (Req 12.8) 4. Incident response — Develop and test IRP (Req 12.10) 5. Formal assessment — Complete SAQ or schedule QSA for ROC
---
Reference Guides
| Guide | Description |
|---|---|
| PCI DSS Requirements Guide | Complete 12 requirements with sub-requirements, testing procedures, v4.0 changes |
| PCI Infrastructure Security | Network architecture, cloud deployment, tokenization, key management, API security |
---
Validation Checkpoints
Before Starting Assessment
- [ ] Merchant/SP level determined based on transaction volume
- [ ] CDE scope defined with data flow diagrams
- [ ] SAQ type identified (or ROC requirement confirmed)
- [ ] All systems in scope inventoried
- [ ] Payment processor compliance attestation obtained
During Assessment
- [ ] Each requirement assessed with evidence collected
- [ ] Network segmentation validated
- [ ] Encryption verified (at rest and in transit)
- [ ] Access controls tested (RBAC, MFA, least privilege)
- [ ] Logging and monitoring validated (SIEM, log retention)
- [ ] Vulnerability scans and pen test results reviewed
After Assessment
- [ ] SAQ/ROC completed with all sections addressed
- [ ] AOC signed by authorized officer
- [ ] Quarterly ASV scans scheduled
- [ ] Remediation plan for any findings
- [ ] Next assessment date scheduled
- [ ] Scope re-validation trigger process documented
Ongoing Compliance
- [ ] Quarterly internal vulnerability scans
- [ ] Quarterly external ASV scans
- [ ] Annual penetration testing
- [ ] Annual security awareness training
- [ ] Annual policy review
- [ ] Annual scope re-validation
- [ ] Semi-annual firewall rule review
- [ ] Semi-annual access review
- [ ] Daily log review (automated)
---
Troubleshooting
| Problem | Likely Cause | Resolution |
|---|---|---|
| Compliance checker reports 0% for a requirement | Controls JSON missing the requirement section entirely | Ensure the requirements object in the input JSON includes entries for all 12 requirements (keys "1" through "12"). Use a sample template as a starting point. |
| Scope analyzer returns wrong SAQ type | Business model flags incorrectly set (e.g., stores_pan true when using tokenization) | Review all boolean flags: stores_pan, processes_pan, transmits_pan, uses_iframe_redirect, uses_p2pe. Tokenized PANs are not considered stored CHD. |
| Gap report shows requirements as non-applicable | The --requirements flag is filtering scope | Remove the --requirements flag to assess all 12 requirements. When specified, only the listed requirements are evaluated. |
| Encryption controls flagged despite AES-256 | Disk-level encryption used instead of file/column-level | PCI DSS v4.0 no longer accepts disk-level encryption as encryption at rest (except removable media). Implement file-level, column-level, or application-layer encryption. |
| MFA requirement flagged even though MFA is deployed | MFA not covering all CDE access paths | PCI DSS v4.0 requires MFA for all access into the CDE, not just remote access. Verify MFA covers console, VPN, API, and administrative access. |
| Payment page script controls failing | Requirements 6.4.3 and 11.6.1 not addressed | Inventory all scripts on payment pages, document authorization and integrity for each, and deploy tamper-detection mechanisms. These became mandatory March 31, 2025. |
| Third-party service provider compliance gaps | TPSP AOC not obtained or expired | Obtain current Attestation of Compliance (AOC) from every third-party service provider handling cardholder data. Verify scope coverage matches your use case. |
---
Success Criteria
- CDE scope clearly defined with network diagrams, data flow documentation, and system inventory covering all in-scope components
- SAQ type correctly determined and validated against actual business model, payment channels, and data handling practices
- Compliance score of 80%+ across all 12 requirements on initial assessment, trending to 95%+ before formal audit
- All future-dated v4.0 requirements (mandatory since March 31, 2025) fully implemented, including payment page script controls (6.4.3, 11.6.1), targeted risk analysis, and enhanced MFA
- Quarterly ASV scans passing with no exploitable vulnerabilities, and annual penetration testing completed with findings remediated
- Third-party service providers validated with current AOCs covering the services used, and TPSP monitoring procedures documented
- Scope reduction strategies implemented (tokenization, P2PE, network segmentation) reducing the number of in-scope systems by 30%+
---
Scope & Limitations
In Scope:
- PCI DSS v4.0/v4.0.1 compliance assessment against all 12 requirements
- SAQ type determination based on business model and payment processing architecture
- CDE scoping with connected system and security-impacting system identification
- Technical control validation (encryption, access control, logging, network segmentation)
- Compliance scoring with per-requirement gap analysis and remediation priorities
- Scope reduction strategy recommendations (tokenization, segmentation, P2PE)
Out of Scope:
- Approved Scanning Vendor (ASV) vulnerability scans (requires PCI SSC-approved ASV vendor)
- Qualified Security Assessor (QSA) on-site assessment or Report on Compliance (ROC) generation
- Payment application security validation (PA-DSS / PCI SSF scope)
- PIN Transaction Security (PTS) device certification
- Card brand-specific program requirements (Visa, Mastercard, Amex each have additional program rules)
- Legal advice on contractual obligations with acquiring banks or card brands
- Real-time transaction monitoring or fraud detection
---
Integration Points
| Skill | Integration |
|---|---|
| infrastructure-compliance-auditor | Validates network segmentation, TLS configuration, endpoint security, and logging controls that satisfy PCI DSS Requirements 1, 2, 4, 10, 11 |
| nist-csf-specialist | CSF functions map to PCI DSS requirements; use the control mapper to build unified control matrices for dual-compliance programs |
| soc2-compliance-expert | SOC 2 CC6 (access), CC7 (operations), CC8 (change management) overlap significantly with PCI DSS; leverage shared evidence |
| information-security-manager-iso27001 | ISO 27001 Annex A controls provide a management system framework supporting PCI DSS compliance |
| nis2-directive-specialist | EU entities subject to both NIS2 and PCI DSS can map shared controls (encryption, incident response, access control) |
---
Tool Reference
pci_compliance_checker.py
Assesses compliance against all 12 PCI DSS v4.0 requirements with per-requirement scoring.
| Flag | Required | Description |
|---|---|---|
--input | Yes | Path to controls JSON file with per-requirement control status (boolean values) |
--output | Yes | Path to write the compliance report |
--format | No | Output format: json (default) or markdown |
--requirements | No | Comma-separated list of requirement numbers to assess (e.g., 3,4,7,8). Omit for all 12. |
pci_scope_analyzer.py
Determines SAQ type and maps CDE boundaries based on business model.
| Flag | Required | Description |
|---|---|---|
--input | Yes | Path to business model JSON file with payment channel, data handling, and system inventory details |
--output | Yes | Path to write the scope analysis report |
--format | No | Output format: json (default) or markdown |
PCI DSS v4.0 Requirements Guide — Complete Reference
This reference provides all 12 PCI DSS v4.0 requirements with sub-requirements, testing procedures, guidance, v4.0 changes, and customized approach considerations.
---
Requirement 1: Install and Maintain Network Security Controls
Goal: Protect the cardholder data environment through network security controls (NSCs) such as firewalls, cloud security groups, and other traffic-filtering technologies.
Sub-Requirements
| ID | Requirement | Testing Procedure | v4.0 Change |
|---|---|---|---|
| 1.1.1 | All security policies and operational procedures identified and kept current | Review documents, interview personnel | Clarified |
| 1.1.2 | Roles and responsibilities documented and understood | Review documentation, interview | Clarified |
| 1.2.1 | NSC configuration standards defined and implemented | Review standards, examine configurations | Updated |
| 1.2.2 | All changes to network connections and NSCs approved and managed | Review change records | Updated |
| 1.2.3 | Accurate network diagram maintained showing all connections | Examine diagram, compare to environment | Clarified |
| 1.2.4 | Accurate data-flow diagram maintained | Examine diagram | Clarified |
| 1.2.5 | All services, protocols, and ports allowed are identified, approved, and have defined business need | Review configurations, documentation | Updated |
| 1.2.6 | Security features defined for insecure services/protocols | Review configurations | Evolved |
| 1.2.7 | NSC configurations reviewed at least every 6 months | Review records | Updated |
| 1.2.8 | NSC configuration files secured from unauthorized access | Examine file permissions | New |
| 1.3.1 | Inbound traffic to CDE restricted | Examine NSC configs | Updated |
| 1.3.2 | Outbound traffic from CDE restricted | Examine NSC configs | Updated |
| 1.3.3 | NSCs installed between wireless networks and CDE | Examine configs, network diagrams | Updated |
| 1.4.1 | NSCs between trusted and untrusted networks | Examine network configs | Updated |
| 1.4.2 | Inbound traffic from untrusted restricted to authorized | Examine NSC configs | Updated |
| 1.4.3 | Anti-spoofing measures | Examine NSC configs | Updated |
| 1.4.4 | CHD cannot flow from untrusted to CDE without authorization | Test traffic flows | Updated |
| 1.4.5 | Disclosure of internal IPs prevented | Examine configurations | Updated |
| 1.5.1 | Security controls for computing devices on untrusted networks | Examine device configurations | Updated |
Guidance and Good Practices
- Document every firewall rule with a business justification and owner
- Use deny-all default rules with explicit allow rules only
- Implement micro-segmentation within the CDE for defense in depth
- Review and clean up unused firewall rules during 6-month reviews
- Consider zero trust network architecture (ZTNA) as a long-term strategy
Customized Approach Considerations
The security objective is to control traffic at CDE boundaries. Alternative controls could include software-defined perimeters, micro-segmentation platforms, or service mesh with mTLS, provided they meet the objective of restricting unauthorized traffic to and from the CDE.
---
Requirement 2: Apply Secure Configurations to All System Components
Goal: Malicious individuals exploit vendor default settings and passwords. Ensure all systems are hardened before deployment.
Sub-Requirements
| ID | Requirement | Testing Procedure | v4.0 Change |
|---|---|---|---|
| 2.1.1 | All security policies and procedures documented | Review documents | Clarified |
| 2.1.2 | Roles and responsibilities defined | Interview, review docs | Clarified |
| 2.2.1 | Configuration standards developed for all system types | Review standards | Updated |
| 2.2.2 | Vendor default accounts managed | Examine system configurations | Updated |
| 2.2.3 | Primary functions with different security levels managed | Examine configurations | Updated |
| 2.2.4 | Only necessary services enabled | Examine configurations | Updated |
| 2.2.5 | Insecure services secured if used | Examine documentation, configs | Clarified |
| 2.2.6 | System security parameters configured to prevent misuse | Examine configs | Updated |
| 2.2.7 | Non-console admin access encrypted | Examine configs | Updated |
Guidance
- Maintain hardened golden images for all standard system types
- Use CIS Benchmarks Level 2 for CDE systems
- Automate hardening verification with compliance scanning tools
- Include containers and serverless functions in hardening standards
- Remove or rename all default accounts; change all default passwords
---
Requirement 3: Protect Stored Account Data
Goal: Minimize data storage and protect any stored account data.
Sub-Requirements
| ID | Requirement | v4.0 Change |
|---|---|---|
| 3.1.1 | All security policies documented | Clarified |
| 3.1.2 | Roles and responsibilities defined | Clarified |
| 3.2.1 | Data retention and disposal policies | Updated |
| 3.3.1 | SAD not stored after authorization | Critical — unchanged |
| 3.3.1.1 | Full track data not stored | Critical — unchanged |
| 3.3.1.2 | CVV/CVC not stored | Critical — unchanged |
| 3.3.1.3 | PIN/PIN block not stored | Critical — unchanged |
| 3.3.2 | SAD encrypted prior to authorization if stored | New (was future-dated, now mandatory) |
| 3.3.3 | Additional requirement for issuers storing SAD | Updated |
| 3.4.1 | PAN masked when displayed | Updated |
| 3.4.2 | PAN secured with technical controls preventing copy | New |
| 3.5.1 | PAN rendered unreadable anywhere stored | Updated |
| 3.5.1.1 | Hashes keyed using cryptographic keyed hashing | New |
| 3.5.1.2 | Disk/partition-level encryption only for removable media | New (was future-dated, now mandatory) |
| 3.5.1.3 | Disk/partition-level encryption not used to render PAN unreadable on non-removable media | New requirement |
| 3.6.1 | Cryptographic key management processes defined | Updated |
| 3.6.1.1 | Additional requirement for service providers | SP-specific |
| 3.7.1-3.7.9 | Key lifecycle management | Updated |
Critical Points
- NEVER store SAD after authorization — this is absolute. Not even encrypted SAD.
- Disk-level/partition-level encryption (e.g., BitLocker, LUKS) no longer satisfies 3.5.1 for non-removable storage. Must use database-level, column-level, or file-level encryption.
- Tokenization is the preferred approach as it removes systems from scope.
---
Requirement 4: Protect CHD During Transmission
Goal: Encrypt CHD during transmission to prevent interception.
Sub-Requirements
| ID | Requirement | v4.0 Change |
|---|---|---|
| 4.1.1 | Policies documented | Clarified |
| 4.1.2 | Roles defined | Clarified |
| 4.2.1 | Strong cryptography for transmission over open/public networks | Updated — includes internal networks |
| 4.2.1.1 | Trusted keys and certificates used | Updated |
| 4.2.1.2 | Wireless transmission encryption | Updated |
| 4.2.2 | PAN secured when sent via end-user messaging | Updated |
Key Changes in v4.0
- PAN must be encrypted during transmission over ALL networks, not just public/open networks. This is a significant expansion.
- Only TLS 1.2+ is acceptable. SSL and TLS 1.0/1.1 are explicitly prohibited.
---
Requirement 5: Protect from Malicious Software
Goal: Deploy and maintain anti-malware defenses.
Sub-Requirements
| ID | Requirement | v4.0 Change |
|---|---|---|
| 5.1.1 | Policies documented | Clarified |
| 5.1.2 | Roles defined | Clarified |
| 5.2.1 | Anti-malware deployed on all applicable systems | Updated |
| 5.2.2 | Anti-malware performs periodic and real-time scans | Updated |
| 5.2.3 | Systems not commonly affected by malware periodically evaluated | Updated |
| 5.2.3.1 | Frequency of periodic evaluations via targeted risk analysis | New |
| 5.3.1 | Anti-malware solutions kept current | Updated |
| 5.3.2 | Scans performed and definitions current | Updated |
| 5.3.3 | Removable media scanned automatically | New (was future-dated, now mandatory) |
| 5.3.4 | Anti-malware logs enabled and retained | Updated |
| 5.3.5 | Anti-malware cannot be disabled without authorization | Updated |
| 5.4.1 | Anti-phishing mechanisms deployed | New (was future-dated, now mandatory) |
Key v4.0 Addition: Anti-Phishing (5.4.1)
Organizations must implement automated anti-phishing mechanisms. Examples include:
- Email gateway with anti-phishing filters
- DMARC enforcement (p=reject)
- URL filtering and link protection
- Phishing-resistant MFA (FIDO2/WebAuthn)
- Domain-based anti-spoofing controls
---
Requirement 6: Secure Systems and Software
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 6.2.1 | Custom software developed securely | Updated |
| 6.2.2 | Developer training annually | Updated |
| 6.2.3 | Code review before release | Updated |
| 6.2.4 | OWASP Top 10 vulnerabilities addressed | Updated |
| 6.3.1 | Vulnerabilities identified and managed | Updated |
| 6.3.2 | Software inventory maintained | New (was future-dated, now mandatory) |
| 6.3.3 | Critical/high vulnerabilities patched | Updated |
| 6.4.1 | Public web apps protected | Updated |
| 6.4.2 | WAF in blocking mode for public web apps | New (was future-dated, now mandatory) |
| 6.4.3 | Payment page scripts managed and authorized | New (was future-dated, now mandatory) |
| 6.5.1 | Change management procedures | Updated |
Critical v4.0 Changes
6.4.3 — Payment Page Script Management: All scripts loaded and executed on payment pages must be:
- Managed (inventory of all scripts maintained)
- Authorized (explicitly approved for use)
- Integrity assured (SRI hashes, CSP policies)
- Monitored for unauthorized changes
This directly addresses Magecart/web-skimming attacks.
---
Requirement 7: Restrict Access
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 7.2.1 | Access control model defined | Updated |
| 7.2.2 | Access based on job classification | Updated |
| 7.2.3 | Privileges approved by authorized personnel | Updated |
| 7.2.4 | Accounts and privileges reviewed every 6 months | Updated |
| 7.2.5 | System accounts managed on least privilege | New |
| 7.2.5.1 | System account access reviewed periodically | New (was future-dated, now mandatory) |
| 7.2.6 | Query access to stored CHD restricted | Updated |
---
Requirement 8: Identify and Authenticate
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 8.2.1 | Unique IDs for all users | Updated |
| 8.2.2 | No shared/generic accounts | Updated |
| 8.3.1 | All access authenticated | Updated |
| 8.3.4 | Account lockout (max 10 attempts, 30 min) | Updated |
| 8.3.6 | Minimum 12-character passwords | Changed (was 7, now 12) |
| 8.3.9 | Passwords changed every 90 days or continuous risk assessment | Updated |
| 8.4.1 | MFA for admin access to CDE | Updated |
| 8.4.2 | MFA for ALL access to CDE | New (was future-dated, now mandatory) |
| 8.4.3 | MFA for remote access | Updated |
| 8.5.1 | MFA replay-resistant | New (was future-dated, now mandatory) |
| 8.6.1 | System/service account interactive login managed | New (was future-dated, now mandatory) |
| 8.6.2 | No hard-coded passwords for system accounts | New (was future-dated, now mandatory) |
| 8.6.3 | Service account passwords rotated | New (was future-dated, now mandatory) |
Critical v4.0 Change: MFA for All CDE Access (8.4.2)
MFA is now required for ALL access into the CDE — not just remote administrative access. This includes:
- All users accessing CDE systems
- Application access that reaches CDE databases
- Operator access to CDE infrastructure
---
Requirement 9: Physical Access
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 9.2.1 | Facility entry controls | Updated |
| 9.3.1 | Physical access reviewed every 6 months | Updated |
| 9.3.2 | Visitor management | Updated |
| 9.4.1 | Media physically secured | Updated |
| 9.4.5 | Electronic media inventory | Updated |
| 9.4.6 | Hard-copy materials destroyed | Updated |
| 9.4.7 | Electronic media rendered unrecoverable | Updated |
| 9.5.1 | POI device protection | Updated |
| 9.5.1.2 | POI device inspection frequency via targeted risk analysis | New |
---
Requirement 10: Logging and Monitoring
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 10.2.1 | Audit logs capture all access to CHD | Updated |
| 10.2.1.1-7 | Specific event types logged | Updated |
| 10.2.2 | Log details include required fields | Updated |
| 10.3.1-4 | Log protection (read access, modification, centralization, FIM) | Updated |
| 10.4.1 | Logs reviewed daily | Updated |
| 10.4.1.1 | Automated log review mechanisms | New (was future-dated, now mandatory) |
| 10.5.1 | 12-month retention (3 months online) | Updated |
| 10.6.1-3 | NTP synchronization | Updated |
| 10.7.1 | Critical security control failures detected | Updated |
| 10.7.2 | Failures of critical security controls detected and reported | New (was future-dated, now mandatory) |
Critical v4.0 Change: Automated Log Review (10.4.1.1)
Manual log review alone is no longer sufficient. Organizations must deploy automated mechanisms (SIEM, log analytics) to perform log reviews. Manual review supplements but cannot replace automation.
---
Requirement 11: Security Testing
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 11.2.1-2 | Wireless scanning quarterly | Updated |
| 11.3.1 | Internal vulnerability scans quarterly | Updated |
| 11.3.1.1 | All non-critical/high vulnerabilities managed | New (was future-dated, now mandatory) |
| 11.3.2 | External ASV scans quarterly | Updated |
| 11.4.1 | External pen test annually | Updated |
| 11.4.3 | Internal pen test annually | Updated |
| 11.4.5 | Segmentation testing annually (6 months for SP) | Updated |
| 11.4.7 | Multi-tenant SP pen testing | New |
| 11.5.1 | IDS/IPS deployed | Updated |
| 11.5.1.1 | IDS/IPS alerts for suspected compromise | New (was future-dated, now mandatory) |
| 11.5.2 | FIM deployed | Updated |
| 11.6.1 | Payment page tamper detection | New (was future-dated, now mandatory) |
Critical v4.0 Change: Payment Page Tamper Detection (11.6.1)
A change-and-tamper-detection mechanism must be deployed on payment pages to alert personnel of unauthorized modifications. This directly supports 6.4.3 (script management) and protects against web-skimming attacks.
---
Requirement 12: Policies and Programs
Sub-Requirements (Key)
| ID | Requirement | v4.0 Change |
|---|---|---|
| 12.1.1 | Security policy established | Updated |
| 12.1.2 | Roles and responsibilities defined | Updated |
| 12.2.1 | Acceptable use policies | Updated |
| 12.3.1 | Targeted risk analysis for each requirement | New (was future-dated, now mandatory) |
| 12.3.2 | Customized approach risk analysis | New |
| 12.4.1 | Executive responsibility for CHD protection | Updated |
| 12.4.2 | Quarterly operations reviews (SP) | Updated |
| 12.5.1 | PCI DSS scope documented annually | Updated |
| 12.5.2 | Scope documented upon significant changes | New |
| 12.6.1 | Security awareness program | Updated |
| 12.6.3 | Training upon hire and annually | Updated |
| 12.6.3.1 | Phishing/social engineering in training | New (was future-dated, now mandatory) |
| 12.8.1-5 | TPSP management | Updated |
| 12.10.1 | Incident response plan | Updated |
| 12.10.2 | IRP tested annually | Updated |
| 12.10.4 | IR personnel trained | Updated |
| 12.10.5 | IRP includes monitoring alerts | Updated |
| 12.10.7 | Response to unexpected stored PAN | New (was future-dated, now mandatory) |
PCI DSS v4.0 Infrastructure Security Guide
Comprehensive guide to infrastructure security for PCI DSS compliance, covering network architecture, cloud deployments, tokenization, key management, POS/terminal security, API security, and mobile payments.
---
Table of Contents
- Network Architecture
- Cloud Deployment Models
- Tokenization vs Encryption
- Key Management Lifecycle
- POS and Payment Terminal Security
- API Security for Payment Systems
- Mobile Payment Security (mPOS)
- E-commerce Security Controls
- Container and Kubernetes Security
---
Network Architecture
Reference CDE Network Architecture
┌──────────────────────────────────────────────────────────────┐
│ INTERNET │
└──────────────────────────┬───────────────────────────────────┘
│
┌──────▼──────┐
│ Perimeter │
│ Firewall/ │
│ WAF/DDoS │
└──────┬──────┘
│
┌──────▼──────┐
│ DMZ │
│ (Web/API │
│ Frontend) │
└──────┬──────┘
│
┌──────▼──────┐
│ Internal │
│ Firewall │
└──────┬──────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌────▼────┐ ┌─────▼─────┐ ┌─────▼─────┐
│Corporate│ │ CDE │ │Management │
│ Network │ │ (Payment │ │ Network │
│ │ │ Systems) │ │ (Admin) │
│No CHD │ │ PAN stored │ │ PAM/Jump │
│access │ │ processed │ │ servers │
└─────────┘ └─────┬─────┘ └───────────┘
│
┌─────▼─────┐
│ Database │
│ Segment │
│ (Encrypted │
│ PAN store)│
└───────────┘Segmentation Requirements
Effective segmentation requires: 1. Physical or logical network separation between CDE and non-CDE 2. Firewall or equivalent NSC between all segments 3. Default deny all traffic between segments 4. Explicit allow rules only for business-justified traffic 5. Logging of all cross-segment traffic 6. Annual segmentation testing (6 months for service providers)
Segmentation Validation Tests
| Test | Purpose | Frequency |
|---|---|---|
| Firewall rule review | Verify only approved traffic crosses CDE boundary | Every 6 months |
| Pen test from non-CDE to CDE | Verify no unauthorized access paths | Annual (6 months SP) |
| Traffic analysis | Confirm no unintended data flows | Quarterly |
| VLAN hopping test | Verify VLAN isolation is effective | Annual |
| ARP spoofing test | Verify Layer 2 controls prevent spoofing | Annual |
| DNS resolution test | Verify CDE DNS is isolated | Annual |
Network Security Controls Checklist
- [ ] Next-generation firewall at CDE perimeter (stateful inspection, application awareness)
- [ ] WAF in blocking mode for all public-facing payment web applications
- [ ] IDS/IPS at CDE perimeter and critical internal points
- [ ] Network micro-segmentation within CDE for defense in depth
- [ ] Outbound traffic filtering — CDE systems only reach approved destinations
- [ ] DDoS protection for internet-facing payment services
- [ ] Network access control (NAC) — only approved devices connect to CDE
- [ ] Wireless networks fully segmented from CDE (separate SSID, VLAN, firewall)
- [ ] VPN with MFA for remote administrative access to CDE
- [ ] Network monitoring with alerting for anomalous CDE traffic patterns
---
Cloud Deployment Models
Shared Responsibility for PCI DSS
| Cloud Model | Customer Responsibility | Cloud Provider Responsibility |
|---|---|---|
| IaaS (AWS EC2, Azure VM, GCP Compute) | OS, applications, data, access control, patching, logging | Physical security, hypervisor, network infrastructure |
| PaaS (AWS RDS, Azure App Service, GCP Cloud Run) | Application, data, access control, logging configuration | Physical, hypervisor, OS, runtime, patching |
| SaaS (Payment processor hosted, Stripe) | Data input, access management, policy | Everything else |
AWS PCI DSS Architecture
VPC Design:
- Create a dedicated VPC for CDE workloads — do not mix with non-payment systems
- Use private subnets for all CDE instances (no public IPs)
- Deploy NAT Gateway for outbound traffic (controlled egress)
- Use VPC Flow Logs for network monitoring
Key AWS Services for PCI:
| Service | PCI DSS Requirement | Usage |
|---|---|---|
| AWS KMS / CloudHSM | Req 3 (encryption), Req 4 (key management) | Encrypt PAN at rest, manage keys |
| AWS WAF | Req 6 (web app protection) | Protect payment web apps |
| AWS Config | Req 2 (config management) | Monitor configuration compliance |
| Amazon GuardDuty | Req 10 (monitoring), Req 11 (testing) | Threat detection |
| AWS CloudTrail | Req 10 (logging) | API activity logging |
| AWS Security Hub | Req 12 (governance) | Aggregated security findings |
| AWS Secrets Manager | Req 8 (credentials) | Rotate service account passwords |
| Amazon Macie | Req 3 (stored data) | Discover and protect stored PAN |
IAM Hardening:
- Use IAM roles (not access keys) for CDE workloads
- Enable MFA for all IAM users with CDE access
- Implement least privilege with permission boundaries
- Use Service Control Policies (SCPs) to restrict CDE account actions
- No root account usage except for account-level operations
Azure PCI DSS Architecture
Network Design:
- Dedicated VNET for CDE with Network Security Groups (NSGs)
- Azure Private Link for PaaS services accessed from CDE
- Azure Firewall Premium with IDPS for CDE traffic
Key Azure Services:
| Service | PCI DSS Requirement | Usage |
|---|---|---|
| Azure Key Vault (HSM) | Req 3, 4 | Key management, encryption |
| Azure WAF | Req 6 | Web app protection |
| Microsoft Defender for Cloud | Req 11 | Vulnerability management, threat detection |
| Azure Monitor / Sentinel | Req 10 | Logging, SIEM |
| Azure Policy | Req 2 | Configuration compliance |
| Azure AD Conditional Access | Req 7, 8 | Access control, MFA |
GCP PCI DSS Architecture
Network Design:
- Dedicated VPC with Shared VPC for CDE isolation
- VPC Service Controls for API-level isolation
- Private Google Access for GCP service connectivity
Key GCP Services:
| Service | PCI DSS Requirement | Usage |
|---|---|---|
| Cloud KMS / Cloud HSM | Req 3, 4 | Encryption, key management |
| Cloud Armor | Req 6 | WAF, DDoS protection |
| Security Command Center | Req 11 | Vulnerability and threat detection |
| Cloud Logging / Chronicle | Req 10 | Centralized logging, SIEM |
| Organization Policies | Req 2 | Configuration constraints |
| BeyondCorp Enterprise | Req 7, 8 | Zero trust access |
---
Tokenization vs Encryption
Decision Framework
| Factor | Tokenization | Encryption |
|---|---|---|
| Scope Impact | Removes systems from PCI scope | Systems remain in PCI scope |
| Data Recovery | Non-reversible (preferred) or vault-based | Reversible with decryption key |
| Performance | Token lookup (fast) | Encrypt/decrypt overhead |
| Key Management | No keys to manage (non-reversible) | Full key lifecycle required |
| Best For | Card-on-file, recurring billing, analytics | Systems requiring PAN recovery |
| Vendor Examples | Stripe tokens, Braintree, TokenEx | AES-256, RSA, format-preserving encryption |
When to Use Tokenization
- Card-on-file: Store tokens for recurring charges (subscription services)
- Analytics: Use tokens for transaction analytics without exposing PAN
- Multi-system: Pass tokens between systems to keep them out of scope
- Data warehousing: Store tokens in analytical databases
When to Use Encryption
- Payment processing: When your system must decrypt PAN to process a transaction
- Issuer processing: Card issuers must recover full PAN
- Regulatory requirement: When a regulation requires access to original PAN
- Legacy integration: When systems cannot be modified to accept tokens
Tokenization Architecture Patterns
Pattern 1: Processor-Managed Tokenization (Recommended for Merchants)
Customer → Merchant Website → Processor.js (iFrame) → Processor (tokenize) → Token returned
Merchant stores token only — never sees PAN — qualifies for SAQ APattern 2: Third-Party Token Vault
Customer → Merchant POS → Token Service Provider → Token Vault (PAN→Token mapping)
Merchant receives token — Token SP handles PCI scope for vaultPattern 3: On-Premises Token Vault (Highest scope impact)
Customer → Merchant System → On-Premises Tokenization Engine → Internal Vault
Full PCI scope for vault infrastructure — avoid if possibleFormat-Preserving Tokenization
Tokens that maintain the same format as the original PAN (e.g., 16-digit number) for compatibility with legacy systems. Uses algorithms like FF1 (NIST SP 800-38G). Helpful when systems validate card number format but do not process actual PANs.
---
Key Management Lifecycle
Key Lifecycle Stages
Generation → Distribution → Storage → Usage → Rotation → Revocation → DestructionKey Management Requirements (PCI DSS 3.6-3.7)
| Stage | Requirement | Implementation |
|---|---|---|
| Generation | Strong keys using approved methods | Use HSM or FIPS 140-2/3 certified generator |
| Distribution | Secure distribution, never in clear text | Split knowledge, dual control, encrypted transport |
| Storage | Encrypted storage, access controlled | Store in HSM, KMS, or encrypted key store |
| Usage | Used only for intended purpose | Enforce key usage policies in HSM/KMS |
| Rotation | Rotated at defined intervals | Annual minimum; crypto-period based on key type |
| Revocation | Revoked when compromised or expired | Immediate revocation capability, CRL/OCSP |
| Destruction | Securely destroyed when no longer needed | Zeroize in HSM, cryptographic erasure |
Key Management Best Practices
Split Knowledge: No single person has access to the complete cryptographic key. Key components are held by different custodians.
Dual Control: Two or more persons are required to perform a key management operation. Both must be present to load a key into an HSM.
Key Custodians:
- Designate primary and alternate key custodians
- Key custodians must sign acknowledgment of responsibilities
- Key custodian list reviewed and updated at least annually
- Background checks required for key custodians
HSM (Hardware Security Module):
- Use FIPS 140-2 Level 3 or FIPS 140-3 certified HSMs
- Deploy HSMs in physically secured, access-controlled locations
- Maintain HSM firmware at current supported version
- Back up HSM keys using secure key ceremony procedures
- Cloud: Use AWS CloudHSM, Azure Dedicated HSM, or GCP Cloud HSM
DUKPT (Derived Unique Key Per Transaction)
Used primarily in POS environments:
- Base Derivation Key (BDK) generates unique keys for each terminal
- Each transaction uses a different derived key
- Compromise of a single transaction key does not expose other transactions
- Terminal-specific Initial PIN Encryption Key (IPEK) derived from BDK
- After approximately 1 million transactions, terminal must be re-injected with new IPEK
P2PE Key Management
- P2PE encryption key injected at PCI SSC-listed Key Injection Facility (KIF)
- Key management handled entirely by the P2PE solution provider
- Merchant has no access to encryption keys — scope reduction
- Decryption occurs only at the processor's secure decryption environment
- Key rotation managed by P2PE provider per their key management policy
---
POS and Payment Terminal Security
Terminal Physical Security
Daily Inspections:
- Examine terminals for signs of tampering (loose housing, additional wiring, overlay devices)
- Compare serial numbers against authorized terminal inventory
- Check for skimming devices over card readers
- Verify tamper-evident seals are intact
Terminal Management:
- Maintain inventory of all terminals with serial numbers and locations
- Deploy terminals only from authorized, verified shipments
- Use tamper-evident packaging for terminal transport
- Restrict terminal configuration access to authorized personnel
- Update terminal firmware promptly when security patches are available
Terminal Network Security
POS Terminal → Dedicated POS VLAN → POS Firewall → Payment Processor
│
└── NO direct Internet access
└── NO access to corporate email/web
└── NO lateral movement to other VLANsRequirements:
- POS terminals on dedicated VLAN/network segment
- Firewall rules permit only traffic to payment processor
- No internet browsing capability on POS systems
- USB ports disabled on POS terminals
- Bluetooth disabled unless required for P2PE peripheral
- Wireless POS uses WPA3 with enterprise authentication on isolated SSID
Terminal Hardening
- Application allowlisting — only authorized POS software executes
- Remove or disable all unnecessary software and services
- Enable auto-screen-lock with PIN/badge unlock
- Disable local admin access for cashier-level users
- Centralize terminal management for consistent configuration
- Enable secure boot to prevent unauthorized OS loading
---
API Security for Payment Systems
Payment API Security Architecture
┌──────────┐ ┌──────────┐ ┌──────────────┐ ┌─────────────┐
│ Client │─TLS→│ API │─mTLS→│ Payment │─mTLS→│ Processor │
│ (Web/ │ │ Gateway │ │ Service │ │ (Stripe, │
│ Mobile) │ │ (WAF, │ │ (Business │ │ Adyen) │
│ │ │ Rate │ │ Logic) │ │ │
│ │ │ Limit) │ │ │ │ │
└──────────┘ └──────────┘ └──────────────┘ └─────────────┘API Security Controls
| Control | Requirement | Implementation |
|---|---|---|
| Authentication | Req 8 | OAuth 2.0 / API keys with rotation |
| Authorization | Req 7 | RBAC per API endpoint, scoped tokens |
| Encryption | Req 4 | TLS 1.2+ for all API traffic, mTLS for internal |
| Input Validation | Req 6 | Validate all parameters, reject malformed requests |
| Rate Limiting | Req 6 | Prevent brute force and abuse |
| Logging | Req 10 | Log all API calls, mask PAN in logs |
| WAF | Req 6 | API-aware WAF protecting payment endpoints |
| Versioning | Req 6 | Manage API versions, retire insecure versions |
PAN Handling in APIs
DO:
- Use tokenization for API responses (return tokens, not PANs)
- Mask PAN in all API logs (show only first 6/last 4)
- Use mTLS between internal payment services
- Validate PAN format (Luhn check) before processing
- Use JWE (JSON Web Encryption) for PAN in request bodies if PAN must be transmitted
DO NOT:
- Include PAN in URL paths or query parameters (logged by web servers)
- Log full PAN in any application or API gateway log
- Return full PAN in API responses
- Cache PAN in API gateway or CDN
- Store PAN in API request/response logs
API Security Testing
- DAST (Dynamic Application Security Testing) in CI/CD pipeline
- SAST (Static Application Security Testing) for API code
- API-specific penetration testing (OWASP API Security Top 10)
- Fuzz testing for API endpoints handling payment data
- Authentication bypass testing
- Authorization testing (vertical and horizontal privilege escalation)
---
Mobile Payment Security (mPOS)
mPOS Architecture
┌────────────┐ Bluetooth/ ┌──────────────┐ ┌─────────────┐
│ Card │───Audio Jack───▶│ Smartphone/ │─TLS─▶│ Payment │
│ Reader │ (encrypted) │ Tablet App │ │ Processor │
│ (P2PE/ │ │ (Merchant │ │ │
│ EMV) │ │ App) │ │ │
└────────────┘ └──────────────┘ └─────────────┘mPOS Security Requirements
Device Security:
- Use PCI PTS-approved card readers only
- Deploy P2PE-validated mPOS solutions when available
- Enable full-disk encryption on mobile devices
- Implement MDM (Mobile Device Management) for merchant devices
- Remote wipe capability for lost/stolen devices
- Application-level encryption for payment data in transit
Application Security:
- Certificate pinning to prevent MitM attacks
- Jailbreak/root detection — refuse to run on compromised devices
- Code obfuscation and anti-tampering
- Secure local storage (no PAN stored locally)
- Session management with automatic timeout
- Biometric or PIN authentication for app access
Communication Security:
- TLS 1.2+ for all communication to payment processor
- Certificate pinning for the payment processor endpoint
- Bluetooth security: Use Bluetooth Low Energy (BLE) with encryption for card reader communication
- Disable fallback to insecure communication protocols
---
E-commerce Security Controls
Payment Page Security (Critical for v4.0)
Requirement 6.4.3 — Script Management:
All scripts on payment pages must be: 1. Inventoried — maintain a list of every script (first-party and third-party) 2. Authorized — explicitly approved for use on payment pages 3. Integrity-verified — use Subresource Integrity (SRI) hashes or Content Security Policy (CSP)
Implementation:
Content-Security-Policy:
default-src 'self';
script-src 'self' https://js.stripe.com 'sha256-<hash>';
frame-src https://js.stripe.com;
connect-src https://api.stripe.com;
style-src 'self' 'unsafe-inline';Requirement 11.6.1 — Tamper Detection:
Deploy mechanisms to detect unauthorized changes to payment pages:
- Real-time JavaScript integrity monitoring
- HTTP header monitoring (CSP violation reports)
- DOM change detection on payment page elements
- External monitoring services that periodically check payment page integrity
- Alert on any unauthorized script changes
iFrame Integration Best Practices
When using processor-hosted iFrame (SAQ A eligible):
- Load iFrame only from processor's domain (strict CSP)
- No JavaScript that interacts with iFrame contents
- No overlays on top of the iFrame
- Validate iFrame source URL integrity
- Monitor for unauthorized changes to iFrame integration code
HTTPS/TLS Configuration
| Setting | Required Value | Notes |
|---|---|---|
| Minimum TLS | 1.2 | Prefer TLS 1.3 |
| Key Exchange | ECDHE | Forward secrecy required |
| Cipher | AES-128-GCM or AES-256-GCM | No CBC mode |
| Certificate | 2048-bit RSA or P-256 ECDSA | Prefer ECDSA for performance |
| HSTS | max-age=31536000; includeSubDomains | Enable on all payment domains |
| OCSP Stapling | Enabled | Improve TLS handshake performance |
| Certificate Transparency | Required | Monitor for unauthorized certificates |
Bot and Fraud Protection
- Deploy CAPTCHA or invisible challenge on payment pages
- Implement velocity checks (max transactions per card/IP/session)
- Use 3D Secure 2.0 (3DS2) for cardholder authentication
- Device fingerprinting for fraud detection
- Address Verification Service (AVS) and CVV verification
- Geolocation checks for suspicious transaction origins
---
Container and Kubernetes Security
CDE Container Security Requirements
| Control | Requirement | Implementation |
|---|---|---|
| Image Security | Req 6 (secure development) | Scan images for vulnerabilities; use private registry; sign images |
| Runtime Security | Req 5 (malware), Req 10 (monitoring) | Deploy runtime protection (Falco, Sysdig); log all container events |
| Network Policy | Req 1 (network controls) | Kubernetes NetworkPolicies; deny all default; explicit allow |
| Secrets | Req 8 (authentication) | External vault (HashiCorp, AWS Secrets Manager); never K8s secrets for PAN/keys |
| RBAC | Req 7 (access control) | CDE namespace RBAC; separate service accounts per workload |
| Pod Security | Req 2 (hardening) | Pod Security Standards: Restricted; no root; read-only filesystem |
| Service Mesh | Req 4 (encryption) | Istio/Linkerd with automatic mTLS for pod-to-pod |
| Compliance | Req 2 (configuration) | OPA/Gatekeeper policies enforcing PCI controls |
Kubernetes CDE Namespace Configuration
# Network Policy — deny all ingress/egress by default
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all
namespace: cde
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
---
# Allow only specific ingress from API gateway
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-api-gateway
namespace: cde
spec:
podSelector:
matchLabels:
app: payment-service
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: api-gateway
ports:
- protocol: TCP
port: 8443Container Image Pipeline
Developer → Code Review → Build → SAST → Image Scan → Sign → Private Registry → Deploy
│ │
│ Reject if critical
│ vulnerabilities found
│
Reject if security
issues foundImage Security Standards:
- Base images from trusted sources only (verified publisher)
- Scan with multiple scanners (Trivy, Snyk, Anchore)
- No critical or high vulnerabilities in production images
- Sign images with Cosign or Notary
- Enforce signed image verification at admission (Kyverno, OPA)
- Minimal base images (distroless, Alpine) to reduce attack surface
- No secrets baked into images (use runtime injection)
- Rebuild images at least monthly to pick up base image patches
#!/usr/bin/env python3
"""
PCI DSS v4.0 Compliance Checker
Checks organizational compliance against all 12 PCI DSS v4.0 requirements.
Validates technical controls, scores compliance per requirement, and generates
prioritized gap analysis with remediation recommendations.
Usage:
python pci_compliance_checker.py --input controls.json --output report.json
python pci_compliance_checker.py --input controls.json --format markdown --output report.md
python pci_compliance_checker.py --input controls.json --requirements 3,4,7,8 --output report.json
"""
import argparse
import json
import sys
from datetime import datetime
from typing import Any
# ---------------------------------------------------------------------------
# PCI DSS v4.0 Requirements and Controls
# ---------------------------------------------------------------------------
PCI_REQUIREMENTS: dict[str, dict[str, Any]] = {
"1": {
"title": "Install and Maintain Network Security Controls",
"controls": {
"network_segmentation": {
"name": "Network segmentation implemented for CDE isolation",
"weight": 15, "critical": True,
},
"firewall_rules_documented": {
"name": "Firewall/NSC rules documented with business justification",
"weight": 10, "critical": False,
},
"waf_deployed": {
"name": "WAF deployed for web-facing payment applications",
"weight": 10, "critical": True,
},
"inbound_traffic_restricted": {
"name": "Inbound traffic to CDE restricted to necessary only",
"weight": 15, "critical": True,
},
"outbound_traffic_restricted": {
"name": "Outbound traffic from CDE restricted to necessary only",
"weight": 15, "critical": True,
},
"wireless_networks_segmented": {
"name": "Wireless networks segmented from CDE",
"weight": 10, "critical": True,
},
"firewall_rules_reviewed_6mo": {
"name": "Firewall rules reviewed at least every 6 months",
"weight": 10, "critical": False,
},
"internal_ip_not_disclosed": {
"name": "Internal IP addresses not disclosed externally",
"weight": 10, "critical": False,
},
"remote_device_security": {
"name": "Security controls on devices connecting via untrusted networks",
"weight": 5, "critical": False,
},
},
},
"2": {
"title": "Apply Secure Configurations to All System Components",
"controls": {
"config_standards_defined": {
"name": "Configuration standards developed for all CDE system components",
"weight": 15, "critical": False,
},
"default_credentials_changed": {
"name": "All vendor default accounts changed, disabled, or removed",
"weight": 20, "critical": True,
},
"unnecessary_services_disabled": {
"name": "Only necessary services, protocols, and functions enabled",
"weight": 15, "critical": True,
},
"hardening_baselines_applied": {
"name": "System hardening baselines (CIS/DISA) applied",
"weight": 20, "critical": True,
},
"admin_access_encrypted": {
"name": "Non-console administrative access encrypted (SSH, TLS)",
"weight": 15, "critical": True,
},
"single_primary_function": {
"name": "One primary function per server (or containerized)",
"weight": 15, "critical": False,
},
},
},
"3": {
"title": "Protect Stored Account Data",
"controls": {
"pan_storage_minimized": {
"name": "PAN storage minimized to business need only",
"weight": 15, "critical": True,
},
"pan_masked_when_displayed": {
"name": "PAN masked when displayed (max first 6 / last 4)",
"weight": 10, "critical": True,
},
"pan_encrypted_at_rest": {
"name": "PAN rendered unreadable when stored (encryption/tokenization)",
"weight": 20, "critical": True,
},
"encryption_algorithm": {
"name": "Strong encryption algorithm used (AES-256 or equivalent)",
"weight": 10, "critical": True,
"type": "text", "valid_values": ["AES-256", "AES-128", "3DES", "RSA-2048"],
},
"key_management_procedures": {
"name": "Cryptographic key management procedures defined and implemented",
"weight": 15, "critical": True,
},
"tokenization_implemented": {
"name": "Tokenization used to reduce PAN storage",
"weight": 10, "critical": False,
},
"sad_not_stored_after_auth": {
"name": "SAD (CVV, track data, PIN) NEVER stored after authorization",
"weight": 20, "critical": True,
},
"data_retention_policy": {
"name": "Data retention and disposal policies implemented",
"weight": 10, "critical": False,
},
},
},
"4": {
"title": "Protect Cardholder Data with Strong Cryptography During Transmission",
"controls": {
"tls_12_or_higher": {
"name": "TLS 1.2+ used for all CHD transmission",
"weight": 25, "critical": True,
},
"strong_cipher_suites": {
"name": "Strong cipher suites configured (ECDHE, AES-GCM)",
"weight": 20, "critical": True,
},
"trusted_certificates": {
"name": "Trusted certificates used for PAN transmission",
"weight": 15, "critical": True,
},
"hsts_enabled": {
"name": "HSTS enabled on payment-related web pages",
"weight": 15, "critical": False,
},
"internal_transmission_encrypted": {
"name": "PAN encrypted during internal network transmission (v4.0 new)",
"weight": 15, "critical": True,
},
"pan_not_sent_via_messaging": {
"name": "PAN not sent via unencrypted messaging (email, chat, SMS)",
"weight": 10, "critical": True,
},
},
},
"5": {
"title": "Protect All Systems and Networks from Malicious Software",
"controls": {
"antimalware_deployed": {
"name": "Anti-malware deployed on all applicable system components",
"weight": 20, "critical": True,
},
"realtime_scanning_enabled": {
"name": "Real-time scanning and periodic scans enabled",
"weight": 15, "critical": True,
},
"definitions_current": {
"name": "Anti-malware definitions kept current (automatic updates)",
"weight": 15, "critical": True,
},
"antimalware_logs_enabled": {
"name": "Anti-malware audit logs enabled and retained",
"weight": 10, "critical": False,
},
"antimalware_tamper_protected": {
"name": "Anti-malware cannot be disabled by users without authorization",
"weight": 15, "critical": True,
},
"antiphishing_deployed": {
"name": "Anti-phishing mechanisms deployed (v4.0 new: 5.4.1)",
"weight": 15, "critical": True,
},
"removable_media_scanning": {
"name": "Anti-malware scans on removable media insertion",
"weight": 10, "critical": False,
},
},
},
"6": {
"title": "Develop and Maintain Secure Systems and Software",
"controls": {
"secure_sdlc": {
"name": "Secure SDLC practices implemented",
"weight": 15, "critical": True,
},
"developer_training_annual": {
"name": "Developer secure coding training at least annually",
"weight": 10, "critical": False,
},
"code_review_before_release": {
"name": "Custom code reviewed before release for vulnerabilities",
"weight": 15, "critical": True,
},
"vulnerability_management_process": {
"name": "Vulnerability management process established",
"weight": 15, "critical": True,
},
"critical_patches_30_days": {
"name": "Critical/high vulnerabilities patched within defined timeframes",
"weight": 15, "critical": True,
},
"waf_blocking_mode": {
"name": "WAF deployed in blocking mode for public web apps (v4.0: 6.4.2)",
"weight": 10, "critical": True,
},
"payment_page_scripts_managed": {
"name": "Payment page scripts managed, authorized, integrity ensured (v4.0: 6.4.3)",
"weight": 15, "critical": True,
},
"software_inventory": {
"name": "Software inventory maintained for vulnerability management (v4.0: 6.3.2)",
"weight": 5, "critical": False,
},
},
},
"7": {
"title": "Restrict Access to System Components and Cardholder Data by Business Need to Know",
"controls": {
"access_control_model_defined": {
"name": "Access control model defined covering all CDE components",
"weight": 20, "critical": True,
},
"rbac_implemented": {
"name": "RBAC implemented with least privilege",
"weight": 20, "critical": True,
},
"access_approved_by_authorized": {
"name": "Access privileges approved by authorized personnel",
"weight": 15, "critical": False,
},
"access_reviewed_6_months": {
"name": "All user accounts and privileges reviewed every 6 months",
"weight": 20, "critical": True,
},
"query_access_restricted": {
"name": "User access to query CHD repositories restricted",
"weight": 15, "critical": True,
},
"service_account_least_privilege": {
"name": "Application/system accounts assigned based on least privilege",
"weight": 10, "critical": False,
},
},
},
"8": {
"title": "Identify Users and Authenticate Access to System Components",
"controls": {
"unique_ids": {
"name": "All users assigned unique IDs",
"weight": 10, "critical": True,
},
"no_shared_accounts": {
"name": "No group, shared, or generic accounts in CDE",
"weight": 10, "critical": True,
},
"mfa_all_cde_access": {
"name": "MFA for ALL access into CDE (v4.0: 8.4.2)",
"weight": 15, "critical": True,
},
"mfa_admin_access": {
"name": "MFA for all administrative access to CDE",
"weight": 15, "critical": True,
},
"mfa_remote_access": {
"name": "MFA for all remote network access",
"weight": 10, "critical": True,
},
"password_12_chars": {
"name": "Minimum 12-character passwords (v4.0: 8.3.6)",
"weight": 10, "critical": True,
},
"account_lockout": {
"name": "Account lockout after max 10 invalid attempts (min 30 min)",
"weight": 10, "critical": True,
},
"service_accounts_managed": {
"name": "Service/system accounts managed, no hard-coded passwords (v4.0: 8.6.1-3)",
"weight": 10, "critical": True,
},
"mfa_replay_resistant": {
"name": "MFA not susceptible to replay attacks (v4.0: 8.5.1)",
"weight": 10, "critical": True,
},
},
},
"9": {
"title": "Restrict Physical Access to Cardholder Data",
"controls": {
"facility_entry_controls": {
"name": "Facility entry controls for CDE areas",
"weight": 20, "critical": True,
},
"visitor_management": {
"name": "Visitor identification, badge, and escort procedures",
"weight": 15, "critical": False,
},
"physical_access_reviewed": {
"name": "Physical access authorization reviewed every 6 months",
"weight": 10, "critical": False,
},
"media_physically_secured": {
"name": "Media with CHD physically secured",
"weight": 15, "critical": True,
},
"media_destroyed": {
"name": "Media rendered unrecoverable when no longer needed",
"weight": 15, "critical": True,
},
"poi_tamper_protection": {
"name": "POI devices protected from tampering and substitution",
"weight": 15, "critical": True,
},
"cctv_deployed": {
"name": "CCTV monitoring CDE physical locations",
"weight": 10, "critical": False,
},
},
},
"10": {
"title": "Log and Monitor All Access to System Components and Cardholder Data",
"controls": {
"audit_logs_all_access": {
"name": "Audit logs capture all individual access to CHD",
"weight": 15, "critical": True,
},
"audit_logs_admin_actions": {
"name": "All administrative actions logged",
"weight": 10, "critical": True,
},
"log_details_complete": {
"name": "Logs include user ID, event type, date/time, success/failure, origin",
"weight": 10, "critical": True,
},
"logs_protected": {
"name": "Audit log files protected from unauthorized modification",
"weight": 10, "critical": True,
},
"logs_centralized": {
"name": "Logs backed up to central log server (SIEM)",
"weight": 10, "critical": True,
},
"fim_on_logs": {
"name": "File integrity monitoring on audit logs",
"weight": 10, "critical": True,
},
"automated_log_review": {
"name": "Automated mechanisms perform log reviews (v4.0: 10.4.1.1)",
"weight": 10, "critical": True,
},
"logs_retained_12_months": {
"name": "Logs retained 12 months (3 months immediately available)",
"weight": 10, "critical": True,
},
"ntp_synchronized": {
"name": "System clocks synchronized using NTP",
"weight": 10, "critical": False,
},
"security_control_failure_detection": {
"name": "Failures of critical security controls detected and reported (v4.0: 10.7.2)",
"weight": 5, "critical": True,
},
},
},
"11": {
"title": "Test Security of Systems and Networks Regularly",
"controls": {
"internal_vuln_scans_quarterly": {
"name": "Internal vulnerability scans at least quarterly",
"weight": 15, "critical": True,
},
"external_asv_scans_quarterly": {
"name": "External ASV scans at least quarterly",
"weight": 15, "critical": True,
},
"external_pen_test_annual": {
"name": "External penetration testing at least annually",
"weight": 15, "critical": True,
},
"internal_pen_test_annual": {
"name": "Internal penetration testing at least annually",
"weight": 10, "critical": True,
},
"segmentation_testing": {
"name": "Network segmentation tested annually (6 months for SP)",
"weight": 10, "critical": True,
},
"ids_ips_deployed": {
"name": "IDS/IPS deployed at CDE perimeter and critical points",
"weight": 10, "critical": True,
},
"fim_deployed": {
"name": "File integrity monitoring on critical system files",
"weight": 10, "critical": True,
},
"wireless_scanning_quarterly": {
"name": "Wireless analyzer scans at least quarterly",
"weight": 5, "critical": False,
},
"payment_page_tamper_detection": {
"name": "Payment page change/tamper detection (v4.0: 11.6.1)",
"weight": 10, "critical": True,
},
},
},
"12": {
"title": "Support Information Security with Organizational Policies and Programs",
"controls": {
"security_policy": {
"name": "Information security policy established and reviewed annually",
"weight": 10, "critical": True,
},
"roles_responsibilities_defined": {
"name": "Roles and responsibilities defined for all requirements",
"weight": 10, "critical": False,
},
"acceptable_use_policies": {
"name": "Acceptable use policies for end-user technologies",
"weight": 5, "critical": False,
},
"targeted_risk_analysis": {
"name": "Targeted risk analysis performed for applicable requirements (v4.0: 12.3.1)",
"weight": 10, "critical": True,
},
"scope_documented_annually": {
"name": "PCI DSS scope documented and confirmed annually",
"weight": 10, "critical": True,
},
"awareness_training": {
"name": "Security awareness training upon hire and annually",
"weight": 10, "critical": True,
},
"phishing_training": {
"name": "Training includes phishing and social engineering awareness (v4.0: 12.6.3.1)",
"weight": 10, "critical": True,
},
"tpsp_managed": {
"name": "Third-party service providers managed with compliance attestations",
"weight": 10, "critical": True,
},
"incident_response_plan": {
"name": "Incident response plan created and tested annually",
"weight": 10, "critical": True,
},
"irp_includes_unexpected_pan": {
"name": "IRP includes procedures for unexpected stored PAN discovery (v4.0: 12.10.7)",
"weight": 5, "critical": True,
},
"executive_responsibility": {
"name": "Executive management responsible for CHD protection",
"weight": 10, "critical": False,
},
},
},
}
def load_input(path: str) -> dict:
"""Load controls data from JSON file."""
try:
with open(path, "r") as f:
return json.load(f)
except FileNotFoundError:
print(f"Error: File not found: {path}", file=sys.stderr)
sys.exit(1)
except json.JSONDecodeError as e:
print(f"Error: Invalid JSON: {e}", file=sys.stderr)
sys.exit(1)
def assess_requirement(req_id: str, req_def: dict, controls_data: dict) -> dict:
"""Assess a single PCI DSS requirement."""
controls = req_def["controls"]
user_controls = controls_data.get(req_id, {})
notes = user_controls.pop("notes", "") if isinstance(user_controls, dict) else ""
total_weight = sum(c["weight"] for c in controls.values())
achieved_weight = 0
control_results: list[dict] = []
gaps: list[dict] = []
for ctrl_id, ctrl_def in controls.items():
user_value = user_controls.get(ctrl_id)
if ctrl_def.get("type") == "text":
# Text-value controls: check if a valid value is provided
is_met = user_value in ctrl_def.get("valid_values", []) if user_value else False
else:
is_met = bool(user_value) if user_value is not None else False
if is_met:
achieved_weight += ctrl_def["weight"]
result = {
"control": ctrl_id,
"name": ctrl_def["name"],
"status": "PASS" if is_met else "FAIL",
"critical": ctrl_def["critical"],
"weight": ctrl_def["weight"],
}
control_results.append(result)
if not is_met:
gaps.append({
"control": ctrl_id,
"name": ctrl_def["name"],
"critical": ctrl_def["critical"],
"priority": "CRITICAL" if ctrl_def["critical"] else "HIGH",
})
score = round((achieved_weight / total_weight) * 100, 1) if total_weight > 0 else 0
passed = sum(1 for c in control_results if c["status"] == "PASS")
failed = sum(1 for c in control_results if c["status"] == "FAIL")
return {
"requirement": req_id,
"title": req_def["title"],
"score": score,
"status": "COMPLIANT" if score == 100 else ("PARTIAL" if score >= 50 else "NON-COMPLIANT"),
"controls_passed": passed,
"controls_failed": failed,
"controls_total": len(control_results),
"controls": control_results,
"gaps": gaps,
"critical_gaps": sum(1 for g in gaps if g["critical"]),
"notes": notes,
}
def run_assessment(data: dict, filter_reqs: list[str] | None = None) -> dict:
"""Run full PCI DSS compliance assessment."""
controls_data = data.get("requirements", {})
results: list[dict] = []
for req_id, req_def in PCI_REQUIREMENTS.items():
if filter_reqs and req_id not in filter_reqs:
continue
results.append(assess_requirement(req_id, req_def, controls_data))
# Summary
total_score = sum(r["score"] for r in results)
avg_score = round(total_score / len(results), 1) if results else 0
total_gaps = sum(len(r["gaps"]) for r in results)
critical_gaps = sum(r["critical_gaps"] for r in results)
compliant = sum(1 for r in results if r["status"] == "COMPLIANT")
partial = sum(1 for r in results if r["status"] == "PARTIAL")
non_compliant = sum(1 for r in results if r["status"] == "NON-COMPLIANT")
# Overall status
if avg_score == 100:
overall_status = "COMPLIANT"
elif critical_gaps > 0:
overall_status = "NON-COMPLIANT"
elif avg_score >= 80:
overall_status = "SUBSTANTIALLY COMPLIANT — gaps must be remediated"
else:
overall_status = "NON-COMPLIANT"
return {
"metadata": {
"organization": data.get("organization", "Unknown"),
"assessment_date": data.get("assessment_date", datetime.now().strftime("%Y-%m-%d")),
"merchant_level": data.get("merchant_level", "Unknown"),
"report_generated": datetime.now().strftime("%Y-%m-%dT%H:%M:%S"),
"pci_dss_version": "4.0",
},
"summary": {
"overall_score": avg_score,
"overall_status": overall_status,
"requirements_assessed": len(results),
"compliant": compliant,
"partial": partial,
"non_compliant": non_compliant,
"total_gaps": total_gaps,
"critical_gaps": critical_gaps,
},
"requirements": results,
"remediation_priorities": _build_remediation(results),
}
def _build_remediation(results: list[dict]) -> list[dict]:
"""Build prioritized remediation list from gaps."""
all_gaps: list[dict] = []
for r in results:
for g in r["gaps"]:
all_gaps.append({
"requirement": r["requirement"],
"requirement_title": r["title"],
"control": g["control"],
"control_name": g["name"],
"priority": g["priority"],
"critical": g["critical"],
})
# Sort: critical first, then by requirement number
all_gaps.sort(key=lambda g: (0 if g["critical"] else 1, int(g["requirement"])))
return all_gaps
def format_markdown(report: dict) -> str:
"""Format report as Markdown."""
lines: list[str] = []
meta = report["metadata"]
summary = report["summary"]
lines.append("# PCI DSS v4.0 Compliance Assessment Report")
lines.append("")
lines.append(f"**Organization:** {meta['organization']}")
lines.append(f"**Assessment Date:** {meta['assessment_date']}")
lines.append(f"**Merchant Level:** {meta['merchant_level']}")
lines.append(f"**PCI DSS Version:** {meta['pci_dss_version']}")
lines.append(f"**Report Generated:** {meta['report_generated']}")
lines.append("")
# Overall Status
lines.append("## Overall Status")
lines.append("")
lines.append(f"| Metric | Value |")
lines.append(f"|--------|-------|")
lines.append(f"| Overall Score | {summary['overall_score']}% |")
lines.append(f"| Status | **{summary['overall_status']}** |")
lines.append(f"| Requirements Assessed | {summary['requirements_assessed']} |")
lines.append(f"| Compliant | {summary['compliant']} |")
lines.append(f"| Partial | {summary['partial']} |")
lines.append(f"| Non-Compliant | {summary['non_compliant']} |")
lines.append(f"| Total Gaps | {summary['total_gaps']} |")
lines.append(f"| Critical Gaps | {summary['critical_gaps']} |")
lines.append("")
# Requirement Scores
lines.append("## Requirement Scores")
lines.append("")
lines.append("| Req | Title | Score | Status | Gaps |")
lines.append("|-----|-------|-------|--------|------|")
for r in report["requirements"]:
lines.append(
f"| {r['requirement']} | {r['title']} | {r['score']}% | {r['status']} | {len(r['gaps'])} |"
)
lines.append("")
# Detailed Findings
lines.append("## Detailed Findings")
lines.append("")
for r in report["requirements"]:
lines.append(f"### Requirement {r['requirement']}: {r['title']}")
lines.append("")
lines.append(f"**Score:** {r['score']}% | **Status:** {r['status']} | "
f"**Passed:** {r['controls_passed']}/{r['controls_total']}")
if r["notes"]:
lines.append(f"**Notes:** {r['notes']}")
lines.append("")
lines.append("| Control | Status | Critical |")
lines.append("|---------|--------|----------|")
for c in r["controls"]:
icon = "PASS" if c["status"] == "PASS" else "FAIL"
lines.append(f"| {c['name']} | {icon} | {'Yes' if c['critical'] else 'No'} |")
lines.append("")
# Remediation Priorities
if report["remediation_priorities"]:
lines.append("## Remediation Priorities")
lines.append("")
lines.append("| Priority | Req | Control | Critical |")
lines.append("|----------|-----|---------|----------|")
for g in report["remediation_priorities"]:
lines.append(
f"| {g['priority']} | Req {g['requirement']} | {g['control_name']} | "
f"{'Yes' if g['critical'] else 'No'} |"
)
lines.append("")
return "\n".join(lines)
def write_output(report: dict, output_path: str | None, fmt: str) -> None:
"""Write report to file or stdout."""
if fmt == "markdown":
content = format_markdown(report)
else:
content = json.dumps(report, indent=2)
if output_path:
with open(output_path, "w") as f:
f.write(content)
print(f"Report written to {output_path}", file=sys.stderr)
else:
print(content)
def main() -> None:
parser = argparse.ArgumentParser(
description="PCI DSS v4.0 Compliance Checker — assess compliance across all 12 requirements"
)
parser.add_argument(
"--input", "-i", required=True,
help="Path to controls JSON file"
)
parser.add_argument(
"--output", "-o",
help="Output file path (stdout if not specified)"
)
parser.add_argument(
"--format", "-f", choices=["json", "markdown"], default="json",
help="Output format (default: json)"
)
parser.add_argument(
"--requirements", "-r",
help="Comma-separated requirement numbers to check (e.g., 3,4,7,8)"
)
args = parser.parse_args()
data = load_input(args.input)
filter_reqs = None
if args.requirements:
filter_reqs = [r.strip() for r in args.requirements.split(",")]
valid_reqs = set(PCI_REQUIREMENTS.keys())
invalid = [r for r in filter_reqs if r not in valid_reqs]
if invalid:
print(f"Error: Unknown requirements: {', '.join(invalid)}", file=sys.stderr)
print(f"Valid: {', '.join(sorted(valid_reqs, key=int))}", file=sys.stderr)
sys.exit(1)
report = run_assessment(data, filter_reqs)
write_output(report, args.output, args.format)
if __name__ == "__main__":
main()
Related skills
FAQ
Which PCI DSS version does it cover?
PCI DSS v4.0, checking against all 12 requirements.
Can it determine our SAQ type?
Yes. The pci_scope_analyzer.py tool determines the appropriate SAQ type based on the business model and CDE scope.