Scrivio Interview library
DesignIntermediate7 min read · updated 12 November 2026

Your Spring Boot services handle payment card data and must meet PCI DSS. What technical controls would you put in place in the services and pipeline?

The most effective control is to shrink the scope: tokenise card data at the edge, ideally with the payment provider's hosted fields, so most services only ever see a token. For the few systems that remain in scope, we encrypt in transit with TLS and at rest with keys held in a key management service, apply strict least-privilege access with audit logging, make sure card data can never reach logs through masking and tests, and run vulnerability scanning with patch deadlines and network segmentation of the in-scope environment.

Why this question is asked

PCI DSS, the Payment Card Industry Data Security Standard, applies to any system that stores, processes or transmits cardholder data, and to everything connected to those systems. Every system in scope must meet hundreds of requirements and be assessed, so the real engineering question is not only how to secure card data, but how to keep it away from as many systems as possible. Interviewers ask this to see whether we design for scope reduction first. In this answer, we will recap what PCI DSS cares about, reduce scope with tokenisation, then go through encryption, access control and audit, logging hygiene, and scanning, patching and segmentation. The current version is PCI DSS 4.0.1; check the exact requirement numbers against it.

1A Quick Recap: What Is in Scope

Cardholder data is mainly the PAN, the primary account number printed on the card, plus the cardholder name and expiry date when stored with it. Sensitive authentication data, such as the CVV code and the magnetic stripe or chip data, is even more restricted: it must never be stored after authorisation, even encrypted.

The cardholder data environment, the CDE, is every system that handles this data, plus systems connected to it that could affect its security. The bigger the CDE, the more systems need hardening, evidence and assessment. A Spring Boot order service that receives a raw card number in its request body is in scope, and so are its database, its logs and possibly its neighbours.

2Minimising Scope With Tokenisation

Tokenisation replaces the card number with a token, a random reference that is useless to an attacker and can only be turned back into the card number by the token service. The best version keeps the card number out of our systems entirely: the browser or app sends card details straight to the payment provider through its hosted fields or SDK, and our backend only receives a token.

Java
// Before: the order service receives the raw card number (in scope)
record CheckoutRequest(String pan, String expiry, String cvv, long amountCents) {}
// After: the client sends card data to the provider and posts only a token
record CheckoutRequest(String paymentToken, long amountCents) {} // e.g. "tok_9f3a..."
@PostMapping("/checkout")
OrderResult checkout(@RequestBody CheckoutRequest req) {
return payments.charge(req.paymentToken(), req.amountCents()); // provider resolves the token
}
Step throughShrinking the cardholder data environment
  1. Browser or appcard fields hosted by the payment provider
  2. Payment providerstores card data, returns a token
  3. Order and checkout serviceshandle tokens only, out of or light on scope
  4. Token service (only if we must store PANs)small, segmented, fully in scope
  5. Key management servicekeys never leave it

5 layers, from the top down. Step through them one at a time.

The fewer layers that see a PAN, the smaller the audit and the risk.

Notice the effect on scope. The order service, its database and its logs no longer handle card data, so they leave the CDE or fall into a much lighter category. If we must hold card numbers ourselves, for example for a payout system, we isolate a small tokenisation service as the only component that sees them, and everything else uses its tokens. Scope reduction is the decision that makes every later control cheaper.

3Encryption in Transit and at Rest

Every connection that carries card data or tokens uses TLS 1.2 or higher with strong ciphers, both from clients and between internal services, so a compromised network segment does not expose data. In Spring Boot we configure server TLS through SSL bundles, and we make outbound clients reject invalid certificates rather than trusting everything for convenience.

At rest, stored card numbers are encrypted with strong cryptography, usually by envelope encryption: each record or batch is encrypted with a data key, and the data key is itself encrypted by a master key held in a key management service, such as a cloud KMS or an HSM. The application asks the KMS to decrypt the data key when it needs it, and the master key never leaves the KMS. Keys are rotated on a schedule, and the people who manage keys are separate from those who can read the data.

4Access Control and Audit Logging

Access to in-scope systems follows least privilege: each person and service gets only the access its role needs, granted by role, reviewed regularly, and removed promptly when roles change. Administrative and remote access require multi-factor authentication. Service-to-service calls authenticate too, for example with mutual TLS or OAuth client credentials, so that a compromised service cannot freely call the token service.

Every access to cardholder data and every administrative action is recorded in an audit log: who, what, when, from where and whether it succeeded. Audit logs go to a separate, tamper-resistant store that the audited people cannot modify, and someone, or something, reviews them, for example with alerts on unusual access patterns.

5Never Logging Card Data

Logs are a classic leak: a developer logs a whole request object while debugging, and card numbers end up in a log platform that is not in scope. We defend in layers. Request and response DTOs that might hold card data override toString() to mask it. A masking filter in the logging configuration replaces anything that looks like a PAN. And a test fails the build if card-like data appears in captured logs.

Java
record CardDetails(String pan, String expiry) {
@Override public String toString() {
return "CardDetails[pan=" + mask(pan) + ", expiry=**/**]"; // CardDetails[pan=************1111, ...]
}
static String mask(String p) { return "*".repeat(p.length() - 4) + p.substring(p.length() - 4); }
}
@Test
void checkoutNeverLogsCardNumbers(CapturedOutput output) { // Spring Boot OutputCaptureExtension
checkout("4111111111111111");
assertThat(output.getAll()).doesNotContainPattern("\\b\\d{13,19}\\b"); // passes
}

Notice that the test uses a well-known test card number and a pattern for 13 to 19 digit sequences. It may catch other long numbers too, which is acceptable for a guard. We also run periodic scans of the log platform for the same pattern, because tests only cover code paths we thought of.

6Scanning, Patching and Segmentation

In-scope systems need regular vulnerability scanning: dependency and container image scanning in CI, internal network scans, and external scans by an approved scanning vendor, at least quarterly and after significant changes. Findings have deadlines; critical security patches are applied within a short, defined window, which PCI DSS sets at one month for critical ones. Our dependency automation, SBOMs and BOM process make those deadlines realistic.

Finally, the CDE is separated from everything else on the network: its own Kubernetes namespace or cluster with network policies, its own database, firewall rules that allow only the specific flows needed, and no direct route from the general corporate network. Segmentation is what lets the rest of the company stay out of scope, and it must be tested regularly to prove it works.

7Follow-up questions

Does using a payment provider make us PCI compliant automatically?

No, but it reduces the work greatly. We still have obligations, for example for the pages that load the provider's fields, and we complete a self-assessment questionnaire or assessment that matches how we integrate. The less card data touches our systems, the smaller that obligation.

Can we store the CVV to make repeat payments easier?

No. Sensitive authentication data such as the CVV must not be stored after authorisation, even encrypted. Repeat payments use provider tokens or stored credential mechanisms instead.

Is tokenisation the same as encryption?

No. An encrypted card number can be decrypted by anyone with the key. A token is a random reference with no mathematical relationship to the card number; only the token service's lookup can resolve it. That is why tokens can usually sit outside the CDE while encrypted card numbers cannot.

8Conclusion

In this answer, we designed PCI DSS controls for Spring Boot services. We started by shrinking scope with tokenisation, ideally keeping card numbers out of our systems entirely, then protected what remains with TLS in transit and envelope encryption with KMS-held keys at rest, least-privilege access with MFA and tamper-resistant audit logs, layered masking and tests so card data never reaches logs, and scanning, patch deadlines and tested network segmentation for the cardholder data environment.

What to say in the interviewAbout 80 seconds aloud

Open with

My first goal would be to keep card data out of as many systems as possible, because everything that touches it is in PCI scope. So I'd tokenise early, ideally with the payment provider's hosted fields or SDK, so the browser sends card details straight to the provider and our Spring Boot services only receive a token.

Then, if they want more

If we must store card numbers, I'd isolate one small token service as the only component that sees them. For whatever stays in scope, I'd use TLS 1.2 or higher everywhere, including internal calls, and envelope encryption at rest with the master key in a KMS or HSM, rotated, with key managers separate from data readers.

Access follows least privilege with role-based grants, regular reviews and MFA for admin access, plus authenticated service-to-service calls, and every access to card data goes to a tamper-resistant audit log.

I'd make sure card numbers never reach logs, with masked toString methods on DTOs, a masking pattern in the logging config, a test that fails if card-like numbers appear in captured output, and periodic log scans.

Finally, vulnerability scanning in CI and quarterly external scans, patch deadlines for criticals, and network segmentation of the cardholder data environment that we test regularly. And never store the CVV.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your Spring Boot services handle payment card data and must meet PCI DSS. What technical...": https://scrivio-interview-library.netlify.app/architecture/platform-and-governance/73e9598c5b/