ArchitectMind
  1. Home
  2. Java Ecosystem
  3. Book 10 · Security, System Design & Solution Architecture
  4. Volume I
  5. Security vs Compliance
Book 10 · Volume I — Security Architecture · Topic 1.4

Security vs Compliance

Reducing real risk while meeting external obligations efficiently

11 min readStage 4 · Production & architecture10 interview questions
Chapter
Chapter 1 — Security Architecture Fundamentals
Prerequisites
Topics 1.1–1.3
You will be able to
Distinguish security and compliance goals, map one set of controls to multiple frameworks, reduce compliance scope architecturally, automate evidence, handle conflicts and exceptions, and communicate both security posture and compliance status
Covers
Security vs compliance
On this page
  1. 1. Concept / Definition
  2. 2. Why It Exists
  3. 3. Core Concepts — Frameworks and Regulations
  4. 4. How It Works Internally — Common Control Framework
  5. 4A. Deep Dive — Scope Reduction by Architecture
  6. 4B. Deep Dive — Where Security Goes Beyond Compliance
  7. 4C. Deep Dive — When They Conflict
  8. 4D. Deep Dive — Risk Acceptance and Exceptions
  9. 4E. Deep Dive — Roles and Metrics
  10. 5. APIs / Features / Syntax
  11. 6. Practical Examples
  12. 7. Common Problems & Mistakes
  13. 8. Performance & Production Considerations
  14. 9. Architecture & Design Considerations
  15. 10. Interview Questions & Answers

1Concept / Definition

Security is the ongoing practice of reducing risk to assets from real threats. Compliance is demonstrating adherence to requirements set by regulators, standards bodies, contracts or internal policy, usually through evidence at points in time. They overlap heavily — most compliance requirements are security controls — but they are not the same: a system can pass an audit and still be breached, and a secure system can fail an audit for lack of evidence.

Security vs compliance
Figure 1 — Security vs compliance
One control, many frameworks
Figure 2 — One control, many frameworks
VocabularyMeaning
Control frameworkSet of controls (ISO 27001 Annex A, PCI DSS)
ScopeSystems subject to a requirement (e.g. PCI CDE)
EvidenceArtefacts proving a control operates
Common control frameworkUnified controls mapped to many frameworks
Table 1 — Terms

2Why It Exists

Compliance-only mindsetSecurity-first mindset
"Is the checkbox ticked?""Is the risk reduced?"
Annual audit sprintContinuous controls and evidence
Minimum requirementsThreat-driven controls
Duplicate evidence per frameworkMap once, reuse
Table 2 — Why distinguish

3Core Concepts — Frameworks and Regulations

Framework/regulationScope for our examples
PCI DSS 4.0PayGrid and ShopNow card data environments
ISO/IEC 27001:2022Organisation-wide ISMS (all three)
SOC 2PayGrid for enterprise merchants
RBI cyber security framework, IT outsourcing directionsNovaBank; payment system operators
India DPDP Act 2023Personal data processing (all)
CERT-In directionsIncident reporting timelines (6 hours), log retention
GDPRPayGrid EU data plane
NIST CSF 2.0Programme structure reference
Table 3 — Landscape

4How It Works Internally — Common Control Framework

StepPractice
Inventory requirementsPer framework and regulation
Define unified controlsE.g. "CTL-ENC-01: encrypt data at rest with managed keys"
MapEach control to framework clauses
Implement as codeSCPs, Config rules, IaC modules, app libraries
Collect evidence automaticallyAudit Manager, Config, Security Hub, Git history
Test controlsContinuous checks + periodic sampling
ReportPer framework from the same data
Table 4 — Map once, prove many times
Continuous compliance
Figure 3 — Continuous compliance

4ADeep Dive — Scope Reduction by Architecture

TechniqueEffect
Tokenise card data at entryMost services out of PCI scope
Isolate CDE in separate accounts/VPCsSmaller audited surface
Hosted payment fields / iframesMerchant pages out of scope
Data minimisationFewer DPDP obligations for unused data
Region locksResidency compliance by construction
Table 5 — Architecture is the cheapest compliance tool

4BDeep Dive — Where Security Goes Beyond Compliance

AreaCompliance minimumSecurity practice
Vulnerability scansQuarterly (PCI)Continuous scanning, fix SLAs
Pen testsAnnualPlus red teams, bug bounty
Access reviewsPeriodicJIT, continuous unused-access analysis
LoggingRetain logsDetect and respond in minutes
Threat modelingRarely required explicitlyEvery significant change
Table 6 — Beyond the checklist

4CDeep Dive — When They Conflict

ConflictResolution
Mandated password rotation vs NIST guidance (rotate on compromise)Satisfy requirement where binding; argue with evidence for modern controls (passkeys)
Log everything vs data minimisationLog security events, mask personal data
Retention requirement vs deletion rightsLegal basis hierarchy; documented
Prescriptive control vs better alternativeCompensating control with documentation (PCI customised approach)
Table 7 — Navigate, don't ignore

4DDeep Dive — Risk Acceptance and Exceptions

ElementPractice
Risk registerRisks, owners, treatment
ExceptionsTime-bound, compensating controls, approver
ReviewQuarterly
EvidenceException records for auditors
Table 8 — Transparent residual risk

4EDeep Dive — Roles and Metrics

RoleResponsibility
CISOSecurity strategy and risk
GRC teamFrameworks, audits, evidence
Security architectsControls in design
EngineeringImplement and operate controls
Internal auditIndependent assurance
Table 9 — Organisation
MetricUse
Control pass rate (automated)Compliance posture
Audit findingsAssurance quality
Incidents, MTTR, open criticalsSecurity outcomes
Table 10 — Measure both

5APIs / Features / Syntax

YAML
# Unified control definition mapped to multiple frameworks (GRC repo)
id: CTL-ENC-01
statement: "Data at rest encrypted with customer-managed KMS keys"
mappings:
  pci_dss_4: ["3.5.1"]
  iso27001_2022: ["A.8.24"]
  rbi_csf: ["Data security - encryption"]
  soc2: ["CC6.1"]
implementation:
  - scp-deny-unencrypted-volumes
  - config-rule-rds-encrypted
  - tf-module-defaults
evidence: [aws-config:rds-storage-encrypted, audit-manager:pci-framework]
owner: platform-security
BASH
# Audit Manager: create an assessment from a standard framework and list evidence folders
aws auditmanager create-assessment --name "PCI-DSS-2026" \
  --framework-id "$PCI_FRAMEWORK_ID" --scope file://pci-scope.json \
  --assessment-reports-destination destinationType=S3,destination=s3://grc-reports \
  --roles roleType=PROCESS_OWNER,roleArn="$GRC_ROLE_ARN"
JAVA
// Data minimisation for DPDP: log security events without personal data
log.atInfo()
   .addKeyValue("event", "LOGIN_FAILED")
   .addKeyValue("userRef", pseudonymise(userId))        // no name/phone/email
   .addKeyValue("reason", reason)
   .log("authentication failure");

6Practical Examples

6.1 Compliant but breached (industry lesson)

Many publicised breaches involved organisations that had passed audits; attackers used unpatched components or stolen credentials between assessments. ShopNow uses this to justify continuous controls beyond audit cycles.

6.2 PCI scope reduction

PayGrid tokenises card numbers at the edge of its CDE; only 4 services and 2 data stores remain in PCI scope, versus 60+ before redesign.

6.3 Evidence automation

NovaBank's evidence collection for its annual RBI and ISO audits dropped from 6 weeks to 1 week with Audit Manager, Config conformance packs and Git-based change records.

6.4 Worked example — control reuse

ControlFrameworks satisfied
MFA for privileged accessPCI 8.4, ISO A.8.5, RBI, SOC 2
Table 11 — Map once

6.5 Worked example — CERT-In requirement

RequirementImplementation
Report incidents within 6 hoursIR runbook step with regulatory comms owner
Log retention 180 days in IndiaLog archive in ap-south-1
Table 12 — Regulatory to technical

6.6 Worked example — compensating control

RequirementCompensating control
Specific legacy system can't do MFANetwork isolation + Verified Access + session recording
Table 13 — Documented alternative

6.7 Worked example — interview whiteboard

PromptAnswer outline
"How do you balance security and compliance?""Security reduces real risk continuously; compliance proves adherence to requirements. Design threat-driven controls, then map to frameworks via a common control framework; implement as code; automate evidence (Config, Security Hub, Audit Manager, Git); reduce scope architecturally (tokenisation, isolation, minimisation, region locks); go beyond minimums (continuous scanning, threat modeling, detection); handle conflicts with compensating controls and documented risk acceptance; measure both control pass rates and security outcomes."
Table 14 — Structured answer

6.8 Worked example — PayGrid SOC 2

EvidenceSource
Change managementPR approvals, pipeline logs
Access reviewsIdentity Center exports
Table 15 — Same controls, another framework

6.9 Worked example — anti-patterns

Anti-patternEffect
Audit sprintsControls lapse between audits
Framework silosDuplicate work
Checkbox controlsNo risk reduction
Undocumented exceptionsAudit findings
Table 16 — Common mistakes

6.10 Worked example — DPDP Act impacts

ObligationArchitectural impact
Consent and purposeConsent service, purpose tags
Deletion on withdrawalData inventory, deletion workflows
Table 17 — Privacy compliance by design

6.11 Worked example — control testing

ControlTest
Encryption at restConfig rule continuous
Access reviewSample quarterly
Table 18 — Continuous + sampling

6.12 Worked example — auditor collaboration

PracticeDetail
Read-only dashboards for auditorsFaster fieldwork
Table 19 — Transparency

6.13 Worked example — policy hierarchy

LevelExample
Policy"Protect customer data"
Standard"Encrypt with CMKs"
ControlCTL-ENC-01
Table 20 — Traceability

6.14 Worked example — board reporting

SectionContent
Compliance statusFrameworks, findings
Security postureIncidents, risks, trends
Table 21 — Both views

6.15 Worked example — GDPR for EU plane

RequirementImplementation
Data in EURegion SCPs
DPIAFor new processing
Table 22 — Jurisdiction-specific

6.16 Worked example — interview follow-ups

Follow-upAnswer
"Can you be compliant but insecure?"Yes — controls may be minimal or lapse between audits
"Cheapest way to reduce PCI effort?"Reduce scope via tokenisation and isolation
Table 23 — Common probes

6.17 Worked example — checklist

Item✔
Frameworks inventoried✔
Common controls mapped✔
Controls as code✔
Evidence automated✔
Scope minimised✔
Exceptions governed✔
Table 24 — Baseline

6.18 Worked example — vendor compliance

VendorEvidence required
SaaS processing PIISOC 2/ISO, DPA, residency
Table 25 — Third-party obligations

6.19 Worked example — security beyond compliance budget

InvestmentReason
Bug bountyNot required; finds real issues
Table 26 — Risk-driven spend

6.20 Worked example — compliance as code in CI

CheckFramework link
No public buckets (Checkov)PCI 1.3, ISO A.8.20
Table 27 — Shift-left compliance

6.21 Worked example — interview scenario

QuestionAnswer
"Regulator requirement conflicts with best practice"Comply where binding, document, propose compensating/modern controls
Table 28 — Pragmatic handling

6.22 Worked example — evidence retention

EvidenceRetention
Audit artefacts7 years
Table 29 — Future audits

6.23 Worked example — PCI customised approach

UseDetail
Demonstrate objective met differentlyRisk analysis + targeted testing
Table 30 — Flexibility in PCI 4.0

6.24 Worked example — continuous monitoring dashboard

PanelContent
Control pass rate by frameworkDaily
Table 31 — Always audit-ready

6.25 Worked example — breach notification

RegulationTimeline
CERT-In6 hours
DPDPAs prescribed to Board and affected principals
Table 32 — Operational readiness

6.26 Worked example — maturity goal

StageCharacteristic
TargetContinuous compliance as by-product of secure engineering
Table 33 — End state

7Common Problems & Mistakes

MistakeFix
Compliance-driven designRisk-driven
Siloed frameworksCommon controls
Manual evidenceAutomation
Large scopeArchitecture
Table 34 — Mistakes and fixes

The most expensive mistake is treating the audit as the goal. Teams run an audit sprint every spring, collect screenshots, close findings and then let controls drift for eleven months, so the organisation is compliant on one day a year and exposed on the rest. Siloed framework programmes are the second trap: PCI, ISO 27001, SOC 2 and RBI teams each ask engineering for the same encryption or access-review evidence in different formats, which burns goodwill and hides gaps. Scope is often accepted rather than designed, so card numbers or personal data leak into logs, analytics and test environments and pull dozens of services into audit. Finally, exceptions granted under deadline pressure are rarely time-bound, and auditors find them years later without an owner or compensating control.

8Performance & Production Considerations

ConsiderationPractice
Control overheadAutomate
Evidence storageOrganised, retained
Audit disruptionRead-only access
Table 35 — Operating compliance

Run compliance as a production system rather than a project. Controls implemented as SCPs, Config rules and IaC modules should report continuously into Security Hub and Audit Manager, with failing controls raised as tickets that carry the same severity and service-level targets as security findings. Evidence needs an owner, a naming scheme and a retention policy, typically seven years in an immutable, versioned S3 bucket with Object Lock, so an auditor's request is a query rather than a search through inboxes. Give auditors read-only dashboards and sampled evidence packs so fieldwork does not interrupt engineers. Watch the operational cost too: noisy Config rules and excessive logging of personal data create cost and privacy risk, so tune rules and mask fields before they reach the log pipeline.

9Architecture & Design Considerations

GuidelineDetail
Security firstThreat-driven
Scope by designIsolation, tokenisation
Evidence by designAutomation
Table 36 — Design guidance

10Interview Questions & Answers

Q1L1 · BasicConcept

What is the difference between security and compliance?

Security is about reducing real risk to assets from real threats, continuously; compliance is about demonstrating that you meet requirements set by regulators, standards or contracts, usually through evidence at a point in time. Security is risk-driven and outcome-focused, so it asks whether an attacker can actually reach customer data. Compliance is requirement-driven and evidence-focused, so it asks whether the control in PCI DSS 3.5.1 exists and can be proven. They overlap heavily because most compliance clauses are security controls, but they are not interchangeable. The practical rule is to design threat-driven controls first, then map them to frameworks and automate the evidence, rather than designing to the checklist.

Q2L1 · BasicTricky

Can a compliant system be insecure?

Yes, and it happens regularly. An audit samples controls at a point in time against a minimum baseline, so a system can pass while still having weaknesses the framework does not cover, or controls that lapse the week after fieldwork. Attackers exploit the gap: an unpatched library released between quarterly scans, a stolen credential for an account that passed its annual access review, or a business-logic flaw no checklist mentions. Many publicised breaches hit organisations holding a current PCI or ISO certificate. That is why ShopNow runs continuous scanning, threat modeling and detection beyond audit cycles. Treat a clean audit as evidence of discipline, not as proof of security.

Q3L2 · IntermediateConcept

What is a common control framework?

A common control framework is a single, organisation-wide set of controls, each mapped to the clauses of every framework and regulation that applies. Instead of separate PCI, ISO 27001, SOC 2 and RBI programmes, you define a control once, such as CTL-ENC-01 for encryption at rest with customer-managed KMS keys, and record that it satisfies PCI 3.5.1, ISO A.8.24, SOC 2 CC6.1 and the RBI data security requirement. The control has one owner, one implementation as code and one evidence stream. Reports for each framework are generated from the same data. The payoff is less duplicated effort, consistent controls across teams and much faster onboarding of a new framework.

Q4L2 · IntermediateDesign

How do you reduce PCI scope?

Reduce PCI scope by keeping card data out of as many systems as possible, because scope covers everything that stores, processes or transmits card numbers and everything connected to it. Tokenise the PAN at the earliest point, ideally with hosted payment fields or an iframe from the PSP so card data never touches your pages. Isolate the remaining cardholder data environment in dedicated AWS accounts and VPCs with tightly controlled connectivity. Make sure logs, analytics, backups and test data never contain PANs, using masking and data discovery tools. PayGrid's redesign cut scope from more than sixty services to four services and two data stores, which shrank audit effort dramatically.

Q5L3 · Senior EngineerInternals

How is compliance evidence automated?

Automate evidence by making the controls themselves produce it continuously. AWS Config rules and conformance packs record whether resources such as RDS instances or S3 buckets are encrypted and private, and Security Hub aggregates findings against standards such as PCI DSS and CIS. Audit Manager maps those signals to framework controls and assembles evidence folders for an assessment. Change management evidence comes from Git: pull request approvals, pipeline logs and signed artefacts show who changed what and who approved it. Access reviews come from Identity Center exports. Manual sampling remains for human processes. NovaBank cut evidence collection for its annual audits from six weeks to one this way.

Q6L3 · Senior EngineerConcept

What is a compensating control?

A compensating control is an alternative control that meets the objective of a requirement when the stated control cannot be implemented for a legitimate technical or business reason. It must address the same risk at least as well, go beyond other controls already required, and be documented with a risk analysis, an owner and a review date. For example, a legacy system that cannot support MFA might be isolated on its own network segment, reachable only through AWS Verified Access with strong authentication, with every session recorded. PCI DSS 4.0 formalises this through compensating control worksheets and its customised approach. Auditors accept them when the reasoning and testing are clearly evidenced.

Q7L4 · Technical ArchitectConcept

Which Indian regulations affect design?

Three shape most designs in India. The RBI cyber security framework and IT outsourcing directions govern banks and payment operators like NovaBank, covering board-approved security policy, outsourcing and cloud risk, audit rights over vendors and incident reporting. The Digital Personal Data Protection Act 2023 requires a lawful purpose and consent, data minimisation, honouring withdrawal and deletion, and breach notification, which drives consent services and data inventories. CERT-In directions require reporting cyber incidents within six hours and keeping logs for 180 days within India. RBI's payment data storage rule also requires payment system data to be stored only in India, which drives region locks such as ap-south-1.

Q8L4 · Technical ArchitectScenario

How do you handle conflicting requirements?

Comply where the requirement is legally or contractually binding, document the conflict, and propose a better control through the formal route rather than ignoring either side. For a mandated ninety-day password rotation that contradicts NIST guidance, satisfy it where binding while arguing with evidence for passkeys and compromise-based rotation. For logging everything versus data minimisation, log security events but mask or pseudonymise personal data. For retention versus deletion rights, apply the legal-basis hierarchy and record the decision. Where PCI allows it, use a compensating control or the customised approach. Record each resolution in an ADR with GRC and legal sign-off, so it is defensible at audit.

Q9L5 · Solution ArchitectDesign

What metrics show both views?

Report two families of metrics side by side, because each hides what the other shows. Compliance posture comes from automated control pass rates by framework, open and overdue audit findings, the number and age of exceptions, and time to produce evidence. Security outcomes come from incidents and their impact, mean time to detect and respond, open critical vulnerabilities against fix SLAs, and the trend in top risks on the register. A board pack showing ninety-eight percent control pass rate alongside rising critical vulnerabilities tells a very different story from the pass rate alone. Trends over quarters matter more than any single number, so present direction as well as value.

Q10L5 · Solution ArchitectConcept

What is the target maturity?

The target is continuous compliance as a by-product of secure engineering. Controls are defined once in a common control framework, implemented as code in SCPs, Config rules, IaC modules and application libraries, and checked in CI and in production every day. Evidence is collected automatically and retained, so the organisation is audit-ready at any moment and audit preparation takes days, not weeks. Scope is minimised by architecture, exceptions are time-bound and owned, and security work goes beyond the minimum through threat modeling, red teaming and detection. At that point the GRC team spends its time on risk judgement and new regulations rather than chasing screenshots from engineers.

Test your knowledge on this topic →Flashcards from this topic's 10 questions, filtered by level and type.

Free question pack

Get 100 free Core Java interview questions

Subscribe for the Book 1 question pack (PDF, every answer explained) and new tutorials once a week. No spam, unsubscribe anytime. What is in the pack?

Almost done! Check your inbox and click the confirmation link. Your download link arrives as soon as you confirm.