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 11 · 50 minutes

Run an internal audit and write findings with corrective actions

After this lesson you can
  • Plan an audit with a question, a population and a sample for each control
  • Tell a major nonconformity from a minor one and from an observation
  • Write findings with a root cause, a corrective action, an owner and a follow-up
Lab files of this lesson (65)

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

Brindle Books now has rules, a register, controls and evidence. Asha wants to know whether it all works before the school network's auditor returns in January. Imani, an accountant from outside the company, does the internal audit: she owns none of the controls, so she can judge them. She has one day. She cannot read every record, so she plans what to test, draws samples, and writes what she finds. You are her assistant: you run the tests and write the findings in a form that a checker accepts.

Recall

Lesson 10: what does a restore test prove that a backup log cannot?

That the data can be brought back, that it matches the checksums from backup time, and how much time and data the recovery costs. The log shows only that a job ran.

Lesson 6: why should the audited team hand over the whole population and not a sample of its own choice?

The person who chooses the rows controls the result. The auditor draws the sample by their own rule, so that every row had a chance to be picked.

The idea

An internal audit is a planned check, by somebody independent of the work, of whether the organisation does what its rules say and whether the rules work. It is the third line of lesson 1, and clause 9 of ISO/IEC 27001 asks for it. An audit has four parts.

  1. Plan. For each control to test: the question, the population (all the records that the control produced in the period), and how many records to look at.
  2. Sample and test. A sample is the part of the population that the auditor reads. A random sample with a recorded seed can be repeated by anybody. A small population is tested whole.
  3. Grade. Each result gets one of three labels.
  4. Correct and follow up. Each failure gets a cause, an action, an owner and a date, and somebody checks later that the action worked.
LabelMeaningRule in this course
Major nonconformityA requirement is not met, and the control fails as a whole or is absent20% or more of the tested records fail
Minor nonconformityA requirement is not met in single cases, and the control mostly worksSome records fail, under 20%
ObservationNo requirement is broken, and the auditor sees a weakness or a way to improveNo record fails

A nonconformity is the failure to meet a requirement. "Finding" is the general word for anything that the auditor writes down. The 20% line is a teaching rule: a real auditor judges by the kind of failure and its effect, not only by a share.

Two words about fixing are often mixed. A correction repairs the single case: disable the leaver's account. A corrective action removes the root cause, the reason why the failure could happen, so that it does not repeat: start the leaver procedure from the HR report. Ask "why?" until the answer is a missing or broken part of the process, not a person.

The audit loop
PlanSample and testFindingCorrective actionFollow-upquestion, population, sizeexceptions, gradedroot cause, owner, datea second person verifiesthe next audittests it againPlanSample and testFindingCorrective actionFollow-up12345
  1. Plan → Sample and test: question, population, size
  2. Sample and test → Finding: exceptions, graded
  3. Finding → Corrective action: root cause, owner, date
  4. Corrective action → Follow-up: a second person verifies
  5. Follow-up → Plan: the next audit tests it again

Worked example

Work in ~/krlab/security-governance.

1. Make the populations

The generator writes the folder audit with three populations of the last six months: 40 deployments from the deployment tool, the leaver report of HR with 6 people (four were temporary warehouse staff, who are not on the staff list of lesson 7), and the patch report of 24 devices. You do not need to read the generator: it writes invented data from a fixed seed. Save it, from the collapsed block or from the zip.

The finished file: make_audit.py

make_audit.py

"""make_audit.py: write audit/, the populations for the internal audit of Brindle Books. Every value is invented."""
import random
from datetime import date, timedelta
from pathlib import Path

rnd = random.Random(11)
out = Path("audit")
out.mkdir(exist_ok=True)

rows = ["id,implemented_by,approved_by,approved_on,implemented_on"]
for i in range(1, 41):
    live = date(2026, 5, 1) + timedelta(days=int(rnd.random() * 180))
    who = "Dev" if rnd.random() < 0.7 else "Ben"
    approver = who if i % 9 == 0 else ("Carys" if rnd.random() < 0.8 else "Asha")
    approved = live + timedelta(days=2 if i % 14 == 0 else -int(rnd.random() * 5))
    rows.append(f"D{i:02d},{who},{approver},{approved},{live}")
(out / "deployments.csv").write_text("\n".join(rows) + "\n")

(out / "leavers.csv").write_text("""id,person,left_on,disabled_on
L1,Ines,2026-10-30,
L2,Kofi,2026-08-14,2026-08-14
L3,Lars,2026-06-30,2026-07-01
L4,Mina,2026-07-17,2026-07-29
L5,Noor,2026-09-04,2026-09-04
L6,Otis,2026-05-22,2026-06-30
""")

rows = ["id,days_since_patch"]
for i in range(1, 25):
    rows.append(f"PC{i:02d},{47 if i == 5 else 1 + int(rnd.random() * 28)}")
(out / "patches.csv").write_text("\n".join(rows) + "\n")
print("wrote audit/deployments.csv, audit/leavers.csv, audit/patches.csv")
python3 make_audit.py
wrote audit/deployments.csv, audit/leavers.csv, audit/patches.csv

2. Write the audit plan

Each row is one test. sample is a number, or all for a small population.

audit_plan.csv

test,control,question,population,sample,auditor
approval,C08,Was each deployment approved by a second person before it went live?,deployments.csv,10,Imani
leaver,C04,Was each leaver's account disabled within one day?,leavers.csv,all,Imani
patch,C07,Was each device patched within 30 days?,patches.csv,8,Imani

3. Write the audit program

sample gives every row a random number from a generator with a fixed seed, sorts by it, and takes the first rows. Anybody with the seed gets the same sample. TESTS maps the name of a test to a rule: a lambda that is true when a record passes.

audit.py

"""audit.py: run the tests of an audit plan on a folder of populations.

    python3 audit.py audit_plan.csv audit
"""
import random
import sys
from pathlib import Path

from grc import day, load

SEED = 11
TESTS = {
    "approval": lambda r: r["approved_by"] not in ("", r["implemented_by"])
    and day(r["approved_on"]) <= day(r["implemented_on"]),
    "leaver": lambda r: r["disabled_on"] != "" and (day(r["disabled_on"]) - day(r["left_on"])).days <= 1,
    "patch": lambda r: int(r["days_since_patch"]) <= 30,
}


def sample(rows, size):
    if size == "all":
        return rows
    rnd = random.Random(SEED)
    return sorted(rows, key=lambda _: rnd.random())[:int(size)]


def grade(failed, tested):
    if failed == 0:
        return "conforms"
    return "major nonconformity" if failed / tested >= 0.2 else "minor nonconformity"


def run(plan_path, folder):
    """Return (test, control, population size, tested, ids of the records that failed) for each row of the plan."""
    results = []
    for t in load(plan_path):
        population = load(Path(folder) / t["population"])
        rows = sample(population, t["sample"])
        failed = sorted(r["id"] for r in rows if not TESTS[t["test"]](r))
        results.append((t["test"], t["control"], len(population), len(rows), failed))
    return results


if __name__ == "__main__":
    for test, control, size, tested, failed in run(sys.argv[1], sys.argv[2]):
        print(f"{control} {test:<9}tested {tested} of {size}, failed {len(failed)}: {' '.join(failed) or '-'}")
        print(f"    -> {grade(len(failed), tested)}")

4. Run the audit

python3 audit.py audit_plan.csv audit
C08 approval tested 10 of 40, failed 1: D27
    -> minor nonconformity
C04 leaver   tested 6 of 6, failed 3: L1 L4 L6
    -> major nonconformity
C07 patch    tested 8 of 24, failed 0: -
    -> conforms

Read the three results. The leaver control fails in half of all cases: a major nonconformity. The approval control fails in single sampled records: a minor one. The patch control passes on its sample. Look at the records behind the first two. grep -E "a|b" prints the lines that hold a or b.

grep -E "L1|L4|L6" audit/leavers.csv
L1,Ines,2026-10-30,
L4,Mina,2026-07-17,2026-07-29
L6,Otis,2026-05-22,2026-06-30

Ines still has a working account, three weeks after she left. Mina's was open for 12 days and Otis's for 39. This suggests a root cause, which Imani must confirm with IT: IT hears about leavers only by mail from the manager, and the mail is sometimes not sent. Ines is on the staff list and was missed too, and two of the four temporary staff were disabled on time, so the cause is the mail and not the kind of contract.

5. Write the findings

A finding has a statement of fact with numbers, the evidence, and for a nonconformity the root cause, the corrective action, an owner and a due date. F0 is from the audit in the spring: no restore test was on record. Lesson 10 produced one, Imani read it today, and she closes the finding: the follow-up. F3 is an observation, so it has no action. The drawing shows the life of F1.

Finding F1, from the audit to its closing
2026-11-21audit: 3 of 6 leavers kept a working account2026-11-21correction: Ben disables the account of Ines2026-12-19due: the leaver procedure starts from the HR reportafter thatfollow-up: Imani tests the next leavers, then closes F12026-11-21audit: 3 of 6 leavers kept a working account2026-11-21correction: Ben disables the account of Ines2026-12-19due: the leaver procedure starts from the HRreportafter thatfollow-up: Imani tests the next leavers,then closes F1

findings.csv

id,test,control,type,statement,evidence,root_cause,action,owner,due,status,verified_by,verified_on
F0,restore,C06,minor,No restore test was on record,Spring audit notes,Nobody was assigned to test restores,Restore test every quarter with a record,Ben,2026-11-30,closed,Imani,2026-11-21
F1,leaver,C04,major,3 of 6 leavers kept a working account for more than one day,audit/leavers.csv L1 L4 L6,IT learns of leavers only by mail and the mail is sometimes not sent,Start the leaver procedure from the HR leaver report,Ben,2026-12-19,open,,
F2,approval,C08,minor,1 of 10 sampled deployments was approved by the person who implemented it,audit/deployments.csv D27,The deployment tool does not demand a second person,Require a reviewer in the deployment tool,Dev,2027-01-15,open,,
F3,patch,C07,observation,All 8 sampled devices were patched within 30 days and the patch report names no owner for late devices,audit/patches.csv,,,,,open,,

6. Check the findings

The checker asks: a known type, a statement and evidence for every finding. A nonconformity has a root cause, an action, an owner and a due date. An open action is not past its date. A closed finding was verified, with a date, by a person other than the owner of the action.

findings_check.py

"""findings_check.py: check audit findings and their corrective actions. Usage: python3 findings_check.py findings.csv"""
import sys

from grc import TODAY, day, finish, load


def overdue(path):
    """Return the open nonconformities whose due date has passed."""
    return [f for f in load(path) if f["type"] != "observation" and f["status"] == "open"
            and f["due"] and day(f["due"]) < TODAY]


def problems(path):
    found = []
    for f in load(path):
        name = f["id"]
        if f["type"] not in ("major", "minor", "observation"):
            found.append(f"{name}: unknown type: {f['type'] or 'none'}")
            continue
        if not f["statement"] or not f["evidence"]:
            found.append(f"{name}: no statement or no evidence")
        if f["type"] != "observation" and not all(f[k] for k in ("root_cause", "action", "owner", "due")):
            found.append(f"{name}: a nonconformity needs a root cause, an action, an owner and a due date")
        if f["status"] == "closed" and (not f["verified_by"] or not f["verified_on"] or f["verified_by"] == f["owner"]):
            found.append(f"{name}: closed without verification by a second person")
    found += [f"{f['id']}: corrective action overdue since {f['due']} (owner {f['owner']})" for f in overdue(path)]
    return found


if __name__ == "__main__":
    finish(problems(sys.argv[1]))
python3 findings_check.py findings.csv
problems: 0

Your turn

Imani doubts two of her own results. Change the plan in a copy, audit_plan2.csv: test the approval control on a sample of 20, and the patch control on all devices. Run the audit again. There are no steps.

Then check the findings list that Marlow Physio wrote after its own audit.

marlow/findings.csv

id,test,control,type,statement,evidence,root_cause,action,owner,due,status,verified_by,verified_on
G1,access log,N02,major,No access log was reviewed in 3 of 3 sampled months,Review folder is empty,Nobody was named to review it,Name a reviewer and review monthly,Priya,2026-10-31,open,,
G2,updates,N04,minor,1 of 10 reception computers missed the updates,updates.csv,,Reinstall the computer,Omar,2026-12-15,open,,
G3,backup,N03,minor,The backup copy is in the same room as the server,Site visit,No off-site storage was ordered,Rent off-site storage,Omar,2026-09-30,closed,Omar,2026-10-02
G4,policy,N01,serious,The policy was approved by its owner,policies/index.csv,No second approver exists,Ask a partner to approve,Nadia,2026-12-01,open,,
G5,devices,N05,observation,Tablets are locked away at night and the key list is not written down,Site visit,,,,,open,,
G6,training,N08,minor,,,Training was cancelled twice,Book a new date,Nadia,2026-11-10,open,,

Last, write the finding for the late device as Imani would: a statement with numbers, the evidence, and a question about the root cause that you would ask Ben.

Check yourself

The patch test passed on a sample of 8 and failed when all 24 devices were tested. Was the first result wrong?

It was a correct statement about the sample and an uncertain one about the population. A sample can miss a rare failure, and that is called sampling risk. An auditor lowers it with a larger sample, with a whole-population test where a program can do it, and with words that say what was tested: "8 of 24 devices, none failed".

Ben disables the account of Ines on the day of the audit. Is finding F1 closed?

No. That is a correction: it repairs one case. The finding is about a process that misses leavers. It closes when the corrective action is in place (the procedure starts from the HR report) and a second person has verified that it works, for example by testing the next leavers.

What is the difference between a minor nonconformity and an observation?

A nonconformity breaks a requirement, even if only once: one deployment without a second approver breaks the change rule. An observation breaks nothing. It records a weakness or an idea, and the organisation may act on it or not. A nonconformity needs a corrective action, and an observation does not.

Why does the root cause of F1 name the process and not Ben or the managers?

"The manager forgot" explains one case and leads to a reminder, which will be forgotten too. "IT depends on a mail that nobody must send" explains why forgetting is possible and leads to a change of the process. A cause that a process change can remove is the useful one.

Field notes

  • An internal auditor needs independence from the work they audit, not a title. In a small firm, people from two teams can audit each other, or an outside person can do it. Record who audited what.
  • Plan the audits over the year so that every part of the scope and every clause is covered in a cycle, with the higher risks more often. The register of lesson 4 tells you where to look first.
  • Write findings as facts that the audited person can check: what was tested, how many, which failed, against which requirement. Leave adjectives out.
  • A certification auditor grades with the same words, and a major nonconformity can block a certificate until it is corrected. The exact rules are those of the certification body.
  • Findings, their actions and their follow-up go to the management review, with the metrics of lesson 13. Management cannot steer what it does not see.