Skip to content
Tutorials Center
My learning

Topics

Lesson 68 of 80 ยท Privacy, Cloud and Secure Design

Compliance and Security Frameworks

Understand ISO 27001, SOC 2, NIST CSF and PCI DSS, how audits work, why policies matter, and how to map controls and track evidence, with Python demos.

Sooner or later a customer, regulator or investor asks: "How do we know you are secure?" A friendly answer is not enough. Organizations answer with frameworks: agreed lists of security practices that a company can follow, measure itself against and have an independent person check. Following a framework does not make you unbreakable, but it gives you a structured way to decide what to do, a shared language with partners and, in some cases, a certificate or report you can show to customers.

This lesson explains the most common frameworks (ISO 27001, SOC 2, the NIST Cybersecurity Framework and PCI DSS), the difference between compliance and security, how an audit works and why written policies matter. The frameworks are described in general terms; always read the current official text before relying on a detail. The tools you built in earlier lessons (logging, access control, backups, vulnerability management) are exactly the controls these frameworks ask for.

Compliance is not security

Two ideas are worth stating before any acronyms.

Compliance means meeting the requirements of a standard, law or contract, and being able to prove it. Security means actually reducing the chance and impact of attacks. They overlap heavily, but they are not the same: an organization can pass an audit and still be breached, because an audit samples evidence at a point in time and a standard cannot anticipate every attack. The opposite also happens: a team with excellent practices but no documentation fails an audit because it cannot show proof.

The healthy approach is to treat frameworks as a floor and a map. Build real security based on your risks (see Threats, Vulnerabilities and Risk), then use the framework to make sure nothing important was forgotten and to produce evidence as a by-product of normal work.

Standards, laws and frameworks

These words are used loosely, so a quick glossary helps.

  • A law or regulation is mandatory and enforced by authorities (for example data protection law, see Privacy and Data Protection).
  • A standard is a published set of requirements, such as ISO 27001, that you can be certified against.
  • A framework is a flexible guide for organizing a security program, such as the NIST Cybersecurity Framework. You use it; nobody certifies you against it.
  • A contractual requirement is mandatory because you signed it. PCI DSS is the best-known example.
  • A control is a specific safeguard: a policy, a technical setting or a process, such as "administrators must use MFA".

ISO/IEC 27001

ISO/IEC 27001 is the international standard for an information security management system (ISMS), the set of policies, processes and responsibilities an organization uses to manage security continuously. Key points:

  • It is certifiable: an accredited certification body audits you and issues a certificate, typically valid for three years with yearly surveillance audits in between.
  • It is risk-based. You identify assets and risks, then choose controls to treat them and record that choice in a Statement of Applicability.
  • The main clauses cover context and scope, leadership, planning (including risk assessment), support, operation, performance evaluation (internal audit and management review) and improvement. These follow the plan-do-check-act cycle.
  • Annex A is a catalogue of controls. In the 2022 edition it lists 93 controls in four themes: organizational, people, physical and technological. Examples are access control, secure authentication, backup, logging, cryptography and supplier security.

ISO 27001 is popular worldwide, and especially with customers in Europe and Asia. A related standard, ISO 27002, gives implementation guidance for the controls.

Running an information security management system

An ISMS is not a document set you write once and file away. It is a management cycle that keeps security aligned with risk as the business changes. Whether or not you certify, the same loop applies to any framework.

flowchart LR
    A["Plan<br/>scope, policy, risk assessment, objectives"] --> B["Implement<br/>controls, training, procedures"]
    B --> C["Monitor<br/>metrics, logs, internal audit"]
    C --> D["Review<br/>management review, audit findings"]
    D --> E["Improve<br/>corrective actions, updated risks"]
    E --> A

Plan, implement, monitor, review, improve: a variation of plan-do-check-act.

The lifecycle stages

  1. Plan. Define the context (who cares about security and which laws apply) and the scope (which sites, systems and processes are inside the ISMS). Obtain top-management commitment and write the security policy. Run a risk assessment: identify assets, threats and vulnerabilities, rate likelihood and impact, and decide the risk treatment (reduce, accept, transfer or avoid, as in Threats, Vulnerabilities and Risk). Set measurable security objectives, assign roles, and record which controls apply and why in the Statement of Applicability.
  2. Implement. Carry out the risk treatment plan: deploy controls such as access management, backup, logging and supplier checks. Provide training and awareness, define procedures, and manage documented information (keep it current and controlled, with version history and owners).
  3. Monitor. Measure whether controls work (Security Metrics and KPIs), watch logs and incidents, test backups and recovery, and run internal audits at planned intervals by people independent of the area audited.
  4. Review. At least once a year (and after major changes) management review examines audit results, incidents, metrics, risk status and resource needs, then decides on changes. This is where leadership shows commitment.
  5. Improve. Deal with every nonconformity (something that does not meet a requirement): contain it, find the root cause, apply a corrective action, and check that it worked. Feed lessons into the next planning round.

Main components of an ISMS

Component Purpose
Scope statement Defines boundaries so that auditors and teams know what is covered
Information security policy Leadership's direction, approved and communicated (Cyber Law, Ethics and Security Policy)
Risk assessment and treatment method A repeatable way to find, rate and decide on risk
Risk register and treatment plan The living list of risks, owners, decisions and deadlines
Statement of Applicability Which controls are in or out, and the justification
Objectives and metrics What success looks like and how it is measured
Roles and responsibilities Named owners, including an overall ISMS manager
Competence and awareness Training and evidence that people know their duties
Operational procedures and controls The day-to-day security work
Incident management Detection, response and learning (The Incident Response Process)
Internal audit programme Independent checks of the ISMS and its controls
Management review records Evidence of leadership oversight
Corrective action log Tracking of nonconformities until closed
Supplier management Security requirements for third parties

Tracking the cycle in code

A spreadsheet or tool usually holds the risk register. The idea is simple enough to model: every risk has an owner, a treatment and a review date, and the ISMS manager looks for anything overdue or untreated.

Python A small ISMS risk register with review checks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Certification versus operating an ISMS

Organizations often pursue ISO/IEC 27001 certification because customers ask for it, but the value comes from the operation. Typical audit stages are a document review, an on-site audit of how controls work in practice, yearly surveillance audits and a recertification audit after three years. Common reasons for failure are a scope that is too narrow to be meaningful, a risk assessment copied from a template, missing management-review evidence, controls that exist on paper but not in practice, and no follow-through on corrective actions. Treat the audit as a health check, not a trophy.

SOC 2

SOC 2 is an attestation report from an independent CPA firm, common among software-as-a-service providers selling to US companies. It is not a certificate; it is a report that describes your controls and the auditor's opinion about them. It is based on the AICPA Trust Services Criteria:

  • Security (required in every SOC 2): protection against unauthorized access.
  • Availability, Processing integrity, Confidentiality and Privacy: optional, chosen according to the promises you make to customers.

There are two report types. A Type I report says your controls were suitably designed at a single date. A Type II report says they also operated effectively over a period, usually 3 to 12 months. Customers generally prefer Type II because it shows the controls work in daily life, not just on paper. You pick which criteria are in scope, so always read what a vendor's report actually covers.

NIST Cybersecurity Framework

The NIST Cybersecurity Framework (CSF) comes from the US National Institute of Standards and Technology, but it is used worldwide by organizations of every size. Version 2.0 (published in 2024) organizes security outcomes into six functions:

  1. Govern: strategy, roles, policy, risk management and supply chain oversight.
  2. Identify: know your assets, risks and improvement needs.
  3. Protect: safeguards such as access control, training, data security and platform hardening.
  4. Detect: find attacks and anomalies through continuous monitoring.
  5. Respond: contain and handle incidents.
  6. Recover: restore systems and services and communicate during recovery.
flowchart LR
    G["Govern"] --- I["Identify"]
    G --- P["Protect"]
    G --- D["Detect"]
    G --- RS["Respond"]
    G --- RC["Recover"]
    I --> P --> D --> RS --> RC

Govern sits across the other five functions; the rest follow the life of an incident from preparation to recovery.

The CSF is deliberately outcome-focused ("assets are inventoried") rather than prescriptive ("use this product"). Organizations create a current profile and a target profile, then plan the work to close the gap. It maps well to the chapters of this course: protect covers authentication and secure coding, detect covers logging, respond and recover cover incident response and backups.

PCI DSS

The Payment Card Industry Data Security Standard (PCI DSS) is required by the card brands for anyone who stores, processes or transmits payment card data. It is contractual, not law, but non-compliance can mean fines from your bank and the loss of your ability to accept cards. The current major version is 4.0, with 4.0.1 as the latest revision at the time of writing. It is organized into 12 requirements under six goals, such as building and maintaining a secure network, protecting account data, managing vulnerabilities, controlling access, monitoring and testing networks, and maintaining a security policy.

Highlights worth knowing:

  • Scope is everything. Systems that handle cardholder data, and anything connected to them, are in scope. The best way to reduce PCI effort is to reduce scope, for example by letting a certified payment provider collect card numbers so they never touch your servers.
  • Never store sensitive authentication data (the card verification code, full track data or PIN) after authorization.
  • The primary account number (PAN) must be unreadable wherever it is stored and masked when displayed, with only a limited number of digits visible.
  • Validation depends on volume: small merchants usually complete a self-assessment questionnaire, large ones are assessed by a Qualified Security Assessor.
Python Masking card numbers the PCI way

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The mask keeps the log useful for support (the last four digits identify the card for a customer) without turning every log file into a store of card numbers that falls under the strictest rules.

How frameworks compare

ISO 27001 SOC 2 NIST CSF PCI DSS
Type Certifiable standard Auditor's attestation report Voluntary framework Contractual standard
Who checks Certification body CPA firm Nobody (self-assessment) Self-assessment or QSA
Best for A management system, global trust SaaS vendors with US customers Organizing a program, communicating risk Anyone handling card data
Scope you choose Yes, in the ISMS scope Yes, systems and criteria Yes Defined by card data flows

Many organizations use several. Because they overlap strongly, they build one control set and map each control to every framework it satisfies, instead of doing separate work for each audit. The demo below shows that idea with an invented control list. The mapping is illustrative and simplified; real crosswalks are longer and subtler.

Python One control set, many frameworks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Closing the same three gaps improves several frameworks at once. That is the point of a unified control set: audits become a view of work you already do.

Policies, standards and procedures

Frameworks all ask for documentation, and people often groan about it. Done well, documents are how a company's security survives staff turnover. They form a hierarchy:

  • Policy: a short, management-approved statement of intent and rules ("All production access requires MFA"). It changes rarely.
  • Standard: specific mandatory requirements that support a policy ("Passwords of at least 12 characters, checked against breach lists").
  • Procedure or runbook: step-by-step instructions for a task, such as onboarding, offboarding or restoring a backup.
  • Guideline: recommended, non-mandatory advice.

Typical policies include acceptable use, access control, password and authentication, data classification and handling, incident response, backup and recovery, change management, vendor management and secure development. Good policies are short, owned by a named person, approved by management, communicated to staff and reviewed on a schedule. An out-of-date policy is a common audit finding, and it is easy to prevent.

Python Which policies are overdue for review?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

How an audit works

Audits look different depending on the framework, but the rhythm is similar.

flowchart LR
    S["Define scope"] --> G["Gap assessment"]
    G --> F["Fix gaps and write evidence"]
    F --> I["Internal audit"]
    I --> E["External audit"]
    E --> R["Certificate or report"]
    R --> M["Continuous monitoring"]
    M -.-> G

Compliance is a cycle, not a project: the audit repeats and the controls must keep working in between.

  1. Scope. Decide which systems, locations, teams and data are covered. A smaller, well-defined scope is cheaper and easier to defend.
  2. Gap assessment. Compare your current state with the requirements, as the control-mapping demo did.
  3. Remediation. Close the gaps, write the policies and set up the processes.
  4. Evidence. Auditors do not take your word. They look at evidence: configuration screenshots, exported user lists, tickets showing access approval, training records, logs of a restore test. The most useful habit is to collect evidence automatically during normal operation.
  5. Audit. The auditor interviews staff, inspects documents and samples records (for example, ten recently departed employees to check that access was removed on time). Findings are graded, and you respond with a corrective action plan.
  6. Continuous compliance. Controls must run all year, so teams monitor them with dashboards and alerts rather than scrambling before the next audit.

Two cautions. Do not "audit-proof" by creating paperwork that does not match reality, because auditors and attackers both find the difference. And do not let compliance become the ceiling: pair it with testing, monitoring and threat-based thinking.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which statement about compliance and security is most accurate?

    Audits check evidence at a point in time against a standard. Real security also needs risk-based decisions, testing and monitoring beyond the checklist.
  2. 2. What is the difference between a SOC 2 Type I and Type II report?

    Type II adds evidence that controls worked over a period of months, which is why customers usually ask for it.
  3. 3. Which framework is a voluntary guide organized around Govern, Identify, Protect, Detect, Respond and Recover?

    The NIST CSF 2.0 groups outcomes into those six functions, and nobody issues a certificate against it.
  4. 4. What is the most effective way to reduce the effort of PCI DSS?

    Systems that touch card data are in scope. Not handling card data in the first place shrinks scope, and the verification code must never be stored after authorization.
  5. 5. What do auditors mainly look for when they test a control?

    A policy states intent, but auditors sample real records to verify that the control is actually performed.

Summary

  • Frameworks give you a map and a common language; compliance proves you meet requirements, while security reduces real risk. Aim for both.
  • ISO 27001 certifies a risk-based management system; SOC 2 is an auditor's report on Trust Services Criteria; NIST CSF is a voluntary outcome-based guide; PCI DSS is a contractual standard for card data.
  • Build one control set and map it to every framework you need, so audits reuse the same evidence.
  • Policies, standards and procedures need owners, approval and a review schedule.
  • Audits follow scope, gap assessment, remediation, evidence, examination and continuous monitoring, and the cycle repeats.

Next: Project: Password Audit Tool, the first hands-on project, where you will put authentication and hashing knowledge to work.