Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Lesson 05 · 40 minutes

Write a statement of applicability and link risks to controls

After this lesson you can
  • Record which controls apply, why, and whether each is implemented
  • Link every treated risk to a control and every control to its evidence
  • Find a risk with no control and a control with no evidence with a program
Lab files of this lesson (27)

The lab folder as it stands after this lesson. Unzip it in ~/krlab.

More

The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.

Scenario

The school network sends its auditor, Jonas, for a first visit to Brindle Books. He reads the risk register and asks: "R1 says a second factor. Where is that control described, who runs it, and what shows me that it is on?" Then he asks the opposite: "You do no awareness training. Did you decide that, or forget it?" One document answers both kinds of question. It is called the statement of applicability, and you write it today.

Recall

Lesson 4: which treatment options need an action and a due date in the register?

reduce, avoid and transfer. Each of them changes something, so somebody must do it by a date. accept changes nothing and has no action.

Lesson 2: how many controls does Annex A of ISO/IEC 27001:2022 list, and in which themes?

93 controls in four themes: 37 organisational (numbers 5.1 to 5.37), 8 people (6.1 to 6.8), 14 physical (7.1 to 7.14) and 34 technological (8.1 to 8.34).

The idea

The statement of applicability (SoA) is the list of controls of an organisation with a decision for each one. ISO/IEC 27001 asks for it as a result of the risk treatment. For every control it says four things.

ColumnQuestion it answers
applicableDo we need this control, yes or no?
justificationWhy is it in, or why is it out? A risk, a law, a contract, a business reason.
statusimplemented, planned, or not_applicable
evidenceWhich record shows that it works?

An exclusion is allowed. An exclusion with no reason is a gap. That is the answer to Jonas's second question: the SoA shows that the organisation looked at a control and decided.

The SoA also makes the trace between three files. Each risk that is reduced or transferred points to at least one control. Each implemented control points to evidence. An auditor walks this trace in both directions: from a risk down to the proof, and from a control up to the reason it exists.

The trace that an auditor walks
Risk registerSoAEvidenceAuditeach treated risk has a controleach implemented control has a recordsampled and testedRisk registerSoAEvidenceAudit123
  1. Risk register → SoA: each treated risk has a control
  2. SoA → Evidence: each implemented control has a record
  3. Evidence → Audit: sampled and tested

A real SoA has a row for each of the 93 controls of Annex A, and rows for your own controls that Annex A does not list. The titles and the text of those controls are in the standard, which this course does not copy. So the SoA of this lesson has twelve rows, with titles in the course's own words and a ref column that points to the Annex A number that the course judges closest. You cannot check those numbers without the standard: annex_a.py proves only that a number can exist, and the paid text or a certified auditor settles whether it is the right control. Check each number against the standard before you use it at work. An own control has an empty ref.

Worked example

Work in ~/krlab/security-governance.

1. Write the statement

risks holds the ids of the risks that the control treats, with a space between them. evidence names the files that show the control at work. Some of those files come in later lessons. C10 and C12 are planned, so they have no evidence yet. C11 is an exclusion. The drawing takes the row of C05 apart.

One row of the statement, control C05
C05control8.5Annex A number (our reading)Second factor on admin accountstitleyesappliesTreats R1whyimplementedstatusevidence/admins.txtproofC05control8.5Annex A number (our reading)Second factor on admin accountstitleyesappliesTreats R1whyimplementedstatusevidence/admins.txtproof

soa.csv

control,ref,theme,title,applicable,justification,status,risks,evidence,owner
C01,5.1,organisational,Policy set approved by management,yes,Contract with the school network,implemented,,policies/index.csv,Carys
C02,5.9,organisational,Inventory of assets with owners,yes,Base of the risk assessment,implemented,,assets.csv,Ben
C03,5.18,organisational,Quarterly review of access rights,yes,Treats R5,implemented,R5,access_decisions.csv,Carys
C04,6.5,people,Leaver procedure for accounts,yes,Treats R5,implemented,R5,evidence/users.txt,Ben
C05,8.5,technological,Second factor on admin accounts,yes,Treats R1,implemented,R1,evidence/admins.txt,Ben
C06,8.13,technological,Nightly backup and restore test,yes,Treats R2,implemented,R2,evidence/backup.log restore_test.json,Ben
C07,8.8,technological,Security updates within 30 days,yes,Contract with the school network,implemented,,evidence/patch-state.csv,Ben
C08,8.32,technological,Change approval with a rollback plan,yes,Treats R7,implemented,R7,changes.csv,Dev
C09,5.19,organisational,Supplier contracts and reviews,yes,Treats R4,implemented,R4,suppliers.csv,Efe
C10,8.24,technological,Disk encryption on laptops,yes,Treats R3,planned,R3,,Ben
C11,8.30,technological,Rules for outsourced development,no,No development work is given to outside parties,not_applicable,,,Carys
C12,6.3,people,Security awareness training,yes,Staff must know the policy,planned,,,Carys

2. Write the checker

theme_of is from annex_a.py (lesson 2). text.split() cuts a text at spaces into a list. set(...) makes a set, and a - b gives the values of set a that are not in set b. |= adds values to a set.

The rules: a ref, when given, is a number that Annex A has, in the stated theme. applicable is yes or no, with a justification in both cases. The status fits the decision. An applicable control has an owner. An implemented control names its evidence. A control names only risks that are in the register. Every risk with the treatment reduce or transfer has at least one applicable control.

soa_check.py

"""soa_check.py: check a statement of applicability against the risk register.

    python3 soa_check.py soa.csv risks.csv
"""
import sys
from collections import Counter

from annex_a import theme_of
from grc import finish, load

STATUS = {"yes": ["implemented", "planned"], "no": ["not_applicable"]}


def problems(soa_path, risks_path):
    risks = load(risks_path)
    known = {r["id"] for r in risks}
    covered = set()
    found = []
    for c in load(soa_path):
        name = c["control"]
        if c["ref"] and theme_of(c["ref"]) != c["theme"]:
            found.append(f"{name}: {c['ref']} is not a control of the theme {c['theme']}")
        if c["applicable"] not in STATUS:
            found.append(f"{name}: applicable must be yes or no")
            continue
        if not c["justification"]:
            found.append(f"{name}: no justification for applicable={c['applicable']}")
        if c["status"] not in STATUS[c["applicable"]]:
            found.append(f"{name}: status {c['status']} does not fit applicable={c['applicable']}")
        if c["applicable"] == "no":
            continue
        if not c["owner"]:
            found.append(f"{name}: no owner")
        if c["status"] == "implemented" and not c["evidence"]:
            found.append(f"{name}: implemented, but no evidence is named")
        linked = set(c["risks"].split())
        found += [f"{name}: risk {r} is not in the register" for r in sorted(linked - known)]
        covered |= linked
    for r in risks:
        if r["treatment"] in ("reduce", "transfer") and r["id"] not in covered:
            found.append(f"{r['id']}: treatment {r['treatment']}, but no control treats it")
    return found


if __name__ == "__main__":
    for status, count in sorted(Counter(c["status"] for c in load(sys.argv[1])).items()):
        print(f"{status:<15}{count}")
    finish(problems(sys.argv[1], sys.argv[2]))

3. Run it

python3 soa_check.py soa.csv risks.csv
implemented    9
not_applicable 1
planned        2
problems: 0

Nine controls are implemented, two are planned and one is excluded with a reason. Every treated risk reaches a control. R8 has the treatment avoid: the export was removed, so no control is needed. R6 is accepted.

4. Walk the trace by hand

Follow Jonas's first question with two commands. grep text file prints the lines that hold text. cut -d, -f1,4,7,9 prints the fields 1, 4, 7 and 9 of each line, with a comma as the separator.

grep "^R1," risks.csv | cut -d, -f1,3,6,8
grep "R1" soa.csv | cut -d, -f1,4,7,9
R1,Customer data is stolen with a stolen admin password,reduce,Second factor on every admin account
C05,Second factor on admin accounts,implemented,evidence/admins.txt

The risk R1 leads to the control C05, and C05 names evidence/admins.txt. That file does not exist yet. Lesson 6 collects it, and lesson 16 checks that every named file exists, is unchanged and is fresh.

5. Break the statement on purpose

Remove the control for R7, claim that the awareness training is implemented, and point C05 at a number that Annex A does not have.

grep -v "^C08" soa.csv > test-soa.csv
sed -i '/^C12/s/,planned,/,implemented,/' test-soa.csv
sed -i '/^C05/s/,8.5,/,8.50,/' test-soa.csv
python3 soa_check.py test-soa.csv risks.csv | tail -4
PROBLEM C05: 8.50 is not a control of the theme technological
PROBLEM C12: implemented, but no evidence is named
PROBLEM R7: treatment reduce, but no control treats it
problems: 3

The checker finds a risk with no control and a control with no evidence. These are the two gaps that an auditor looks for first. Remove the test file with rm test-soa.csv.

Your turn

Nadia wrote a statement for Marlow Physio. Save it and check it against marlow/risks.csv of lesson 4. There are no steps.

marlow/soa.csv

control,ref,theme,title,applicable,justification,status,risks,evidence,owner
N01,5.1,organisational,Policy set,yes,Required by the health regulator,implemented,,policies/index.csv,Nadia
N02,8.15,technological,Log of every record access,yes,Treats K1,implemented,K1,,Omar
N03,8.13,organisational,Backup of the booking data,yes,Treats K2,implemented,K2,backup.log,Omar
N04,8.8,technological,Automatic security updates,yes,Treats K3,planned,K3 K9,,Omar
N05,6.9,people,Clean desk rule for paper notes,yes,Treats K6,planned,K6,,Priya
N06,7.14,physical,Secure disposal of old devices,no,,not_applicable,,,Omar
N07,8.30,technological,Rules for outsourced development,no,The clinic builds no software,implemented,,,Nadia

Then look at N06 with the inventory of lesson 3 in mind. Write one sentence: why would an auditor not believe this exclusion?

Check yourself

Why does the statement of applicability ask for a reason when a control is left out?

The reason shows that the organisation considered the control and decided. Without it, a reader cannot tell a decision from an oversight. A good reason can be tested: "no development work is given to outside parties" is true or false.

C07, the security updates, treats no risk in the register. Is that a fault?

No. A control can come from a contract, a law or a business decision. The justification column says so: the contract with the school network asks for it. The fault would be a control with no justification at all. It may still be worth asking whether the register lacks a risk about unpatched systems.

The checker accepts C10 as "planned" with no evidence. What must happen so that this stays honest?

A planned control needs a date and a person, and the risk register has both for R3: Ben, 15 December. Once the date passes, the register's checker reports the open treatment. A control that stays "planned" for years is an accepted risk under another name.

An implemented control names an evidence file. What does that prove on its own?

Only that somebody typed a file name. The file must exist, must show the control at work, and must be recent. This lesson checks the first link of the chain. Lesson 6 collects and seals the evidence, and lesson 11 tests it by sampling.

Field notes

  • The SoA is the document that certification auditors ask for by name, together with the scope. They plan their audit from it, so an untrue "implemented" will be found.
  • Do not start from Annex A and tick every row. Start from the risks, choose controls, then compare with Annex A to catch what you forgot. The order matters for the justifications: "treats R5" is a better reason than "it was on the list".
  • Give the SoA a version and a date, and let top management approve it. Controls change when risks, contracts or systems change, and the old version is evidence of what was true before.
  • The numbers in the ref column are the course's own reading. Read the control text in ISO/IEC 27001 and the guidance in ISO/IEC 27002 before you rely on a reference.
  • One control often treats several risks, and one risk often needs several controls. Keep the links in the file, as here, so that a change of a control shows which risks move.