Compliance Automation and Tooling Questions
Using technology to make compliance continuous rather than point-in-time. Covers GRC platforms and control libraries (build versus buy, one control set mapped to many regulations, requirement-to-evidence traceability, risk roll-ups), compliance-as-code and policy-as-code checks mapped to framework controls (including testing, versioning and retiring the rules, and turning local legal and privacy obligations such as retention and masking into machine-checkable tests), continuous control monitoring and drift alerts, automated evidence collection and tamper-evident evidence pipelines for auditors, automated compliance and privacy reporting with traceable lineage (including regulatory SLA tracking such as DSAR deadlines), and wiring compliance checks into engineering pipelines without slowing teams. Focuses on what to automate first, how to map controls to machine-checkable tests, where to place checks, and the limits of automation. Does not cover designing or testing the controls themselves, the content of individual frameworks, hands-on security mechanics such as secrets, IAM, scanning or logging pipelines, or conducting the audit.
The monthly compliance report is assembled by hand from several systems and is always late and occasionally wrong. How would you automate it end to end, what would you build in so a bad upstream feed does not silently produce a confident-looking report, and who would you let see and edit it?
Sample Answer
Direct answer
Replace the hand assembly with a scheduled pipeline that pulls each source through a data contract (a written agreement between the team that owns a feed and the team that consumes it: which fields, what format, how fresh, delivered when), runs data-quality gates, computes metrics from versioned definitions and publishes a dated report. The key design choice is that the pipeline fails closed, meaning that when it cannot be sure the data is good it refuses to present a final result instead of carrying on: when a feed is stale, empty or malformed, the report is marked incomplete and says why, rather than printing a tidy number built on bad data.
Step 1: Inventory the manual process
List every source system, who exports it, which spreadsheet formulas touch it and which numbers have been wrong before. Those past errors become the first automated tests.
Step 2: Build the pipeline
- Ingest from each system by API or scheduled export into a staging area, keeping the raw copy untouched.
- Validate each feed before use (see the next section).
- Transform with metric definitions in version control, each with an owner and a written definition.
- Publish a dated report plus a manifest (inputs used, row counts, definition versions, run time), on a schedule a day or two before the deadline so a failure can be fixed before it is late.
Step 3: Guards so a bad feed cannot hide
| Guard | What it catches |
|---|---|
| Freshness check | Feed last updated before the expected window |
| Volume check | Row count far from the recent norm (a feed that normally has 1,200 rows and arrives with 0 trips a 50% floor of 600 rows) |
| Schema check | Renamed or missing columns, changed types |
| Reconciliation | Total in the report disagrees with an independent control total (a headline figure the source system reports on its own, such as "1,213 active employees", which the report's own count must also match) |
| Per-section status | Each section shows complete, partial or missing, so one bad feed taints only its own section |
If any blocking guard fails, the report is stamped DRAFT: INCOMPLETE with the failing feed named, the owner is alerted, and nobody can publish it as final without a recorded override. The override requires a reason and a named approver.
Step 4: Who sees and edits
- View: audience-based roles (compliance team, executives, auditors), read-only. Sensitive detail (individual names, incident narratives) is restricted to people who need it.
- Edit: nobody edits the output. People change inputs at the source or change definitions through a reviewed change. The only manual path is a logged override with a reason.
- Approve: the report owner signs off on each period; that approval is stored with the manifest.
Worked example
Six feeds feed the monthly report. On the 3rd, the HR export arrives with 0 rows. The volume check (floor 600, because the usual is 1,200) fails. The old process would have shown "0 leavers without access revoked", which looks excellent and is wrong. The new pipeline marks the joiner-mover-leaver section (the part covering people who join the company, change roles or leave, and whether their access was granted, changed or removed on time) missing, sends the HR-data owner an alert, and the report goes out on schedule, stamped DRAFT: INCOMPLETE, with five sections complete and one flagged missing; it can be released as final only through the recorded override.
Trade-offs and pitfalls
- Over-tight thresholds create alert fatigue (so many alerts that people stop reading them); seed them from recent history and review them quarterly.
- Automation cannot tell that a definition is wrong, only that it is applied consistently. Keep a human review of definition changes.
- Keep the old manual report in parallel for one or two cycles and diff them, which finds the hand-assembly errors.
An auditor asks you to trace one requirement to the control that meets it, to the implementation, and to the evidence, and to show what changed since last audit. How would you model that traceability in your GRC tooling so these reports are generated rather than assembled by hand, and what breaks when a framework or a system is revised?
Sample Answer
Direct answer
Model the chain as linked, versioned records (requirement to control to implementation to test to evidence) with effective dates on every record, so any report is a query, not a document assembled by hand. "What changed since last audit" is a query on version and effective-date fields between two dates.
The model
| Entity | Key fields | Notes |
|---|---|---|
| Requirement | framework, version, clause id, text | Never edited; a revision is a new row |
| Control | control id, version, statement, owner, effective-from (the date this version takes effect) | Each change is a new version |
| Mapping | requirement, control, strength (full or partial), reviewer | Many to many |
| Implementation | control, system, check name | Where the control lives |
| Evidence | control, control version tested, system, collected-at, result, artifact hash | Append-only (rows are only ever added, never edited or deleted) |
Worked example (code run, output pasted)
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE requirement (req_id TEXT, framework TEXT, version TEXT, clause TEXT, text TEXT, PRIMARY KEY (req_id, version));
CREATE TABLE control (control_id TEXT, version INT, statement TEXT, owner TEXT, effective_from TEXT, PRIMARY KEY (control_id, version));
CREATE TABLE mapping (req_id TEXT, req_version TEXT, control_id TEXT, strength TEXT);
CREATE TABLE implementation (control_id TEXT, system TEXT, check_name TEXT);
CREATE TABLE evidence (control_id TEXT, control_version INT, system TEXT, collected_at TEXT, result TEXT, artifact_sha TEXT);
""")
db.executemany("INSERT INTO requirement VALUES (?,?,?,?,?)", [
("NIST-IA-2.1", "NIST SP 800-53", "r5", "IA-2(1)", "MFA for privileged accounts")])
db.executemany("INSERT INTO control VALUES (?,?,?,?,?)", [
("CTL-MFA-ADMIN", 1, "Admins use MFA", "iam-team", "2024-01-01"),
("CTL-MFA-ADMIN", 2, "Admins use phishing-resistant MFA", "iam-team", "2025-03-01")])
db.execute("INSERT INTO mapping VALUES ('NIST-IA-2.1','r5','CTL-MFA-ADMIN','full')")
db.execute("INSERT INTO implementation VALUES ('CTL-MFA-ADMIN','idp-prod','admin_mfa_enforced')")
db.executemany("INSERT INTO evidence VALUES (?,?,?,?,?,?)", [
("CTL-MFA-ADMIN",2,"idp-prod","2025-06-30","pass","a1f09c"),
("CTL-MFA-ADMIN",2,"idp-prod","2025-07-01","pass","b72e44")])
print("TRACE: requirement -> control -> implementation -> latest evidence")
for r in db.execute("""
SELECT m.req_id, m.control_id, i.system, i.check_name, e.collected_at, e.result, e.artifact_sha
FROM mapping m JOIN implementation i USING (control_id)
JOIN evidence e ON e.control_id=m.control_id AND e.system=i.system
WHERE e.collected_at = (SELECT MAX(collected_at) FROM evidence WHERE control_id=m.control_id)"""):
print(r)
LAST_AUDIT = "2025-01-01"
print("CHANGED since last audit (", LAST_AUDIT, ")")
for r in db.execute("SELECT control_id, version, statement, effective_from FROM control WHERE effective_from > ?", (LAST_AUDIT,)):
print(r)
Output:
TRACE: requirement -> control -> implementation -> latest evidence
('NIST-IA-2.1', 'CTL-MFA-ADMIN', 'idp-prod', 'admin_mfa_enforced', '2025-07-01', 'pass', 'b72e44')
CHANGED since last audit ( 2025-01-01 )
('CTL-MFA-ADMIN', 2, 'Admins use phishing-resistant MFA', '2025-03-01')
One query returns the whole chain for NIST SP 800-53 IA-2(1), and a second returns the control that tightened in March. A real "changed" report would also diff mappings, implementations and test definitions, not only the control statement.
Reading the code in plain language. The trace query starts from the mapping row and attaches the implementation with JOIN ... USING (control_id), which means "pair rows that share the same control_id value". It then attaches evidence rows for the same control and system (each evidence row also records which control version it tested, here version 2, so a report can separate evidence gathered against the old wording from proof of the new wording; this short trace query does not filter on that column, and a production version would add a condition that the evidence's control_version equals the control's latest version). The final WHERE keeps only the newest evidence row: for each mapping row, the inner SELECT MAX(collected_at) looks up the latest collection date for that control, and only evidence collected on that date survives (a subquery that depends on the outer row like this is called a correlated subquery). That is why the 2025-06-30 row is dropped and the 2025-07-01 row printed. In the schema, PRIMARY KEY (control_id, version) allows many versions of one control but never the same version twice, so rewriting a control means inserting version 3, not editing version 2. The change query simply lists control versions whose effective date is later than the last audit date; ISO-formatted dates sort correctly as text.
Generating the reports
- Traceability report: for each requirement in scope, list its controls, systems, latest result and evidence link. Coverage is computed: a requirement counts as covered if it has an approved mapping to an active control whose latest test is within its freshness window (the maximum age, for example 7 days, at which a result still counts as current).
- Change report: all rows with a version or effective date after the last audit date, grouped by entity, with reviewer and reason.
- Gaps first: list requirements with no mapping, controls with no test, and tests with stale or missing evidence. These matter more to an auditor than the covered rows.
What breaks when something is revised
| Change | Failure | Defence |
|---|---|---|
| Framework revision (renumbering, new or withdrawn clauses) | Mappings point at old clause ids, new requirements are unmapped, withdrawn ones leave orphan controls | Version requirements, carry mappings forward as proposed, review the diff, report unmapped and orphaned items |
| System renamed, migrated or retired | Test points at a resource that no longer exists, so no evidence arrives | Treat missing evidence as a failure, not a pass; alert on no-data |
| Control rewritten | Old evidence no longer proves the new wording | Evidence references control version; re-test after change |
| Many mappings at scale | Recomputing coverage over the whole catalog is slow | Recompute only the subgraph touched by a change (the connected slice of requirements, controls and tests reachable from the changed row), keep a materialized coverage table (a stored, precomputed result refreshed when inputs change, instead of recalculated on every report) |
A concrete renumbering. In the ISO/IEC 27001 move from the 2013 to the 2022 edition, the control "A.9.4.2 Secure log-on procedures" became "A.8.5 Secure authentication". With versioned requirements, the 2022 row is added, the old mapping to CTL-MFA-ADMIN is carried forward as proposed, and a reviewer approves it. A withdrawn clause that nothing replaces leaves a control with no requirement pointing at it, which is an orphan control in the table above, and it appears in the gaps list for a human decision.
Pitfalls
- Editing rows in place destroys the "what changed" answer; append and version instead.
- A green coverage number built on stale evidence is the same silent-failure problem as an unchecked dashboard, so show freshness next to coverage.
Your company runs separate risk registers per product line and region, so leadership cannot see aggregate risk or compliance posture. How would you design the data model and ingestion for a GRC platform that rolls these up automatically, how would you keep scoring consistent across teams, and which executive views would you build from it?
Sample Answer
Direct answer
Build one canonical model (business unit, risk, control, link between them) with a single taxonomy (one shared list of risk categories) and a single anchored scoring rubric (a scoring guide that ties each level from 1 to 5 to concrete descriptions, so two people land on the same number), and ingest each local register through a mapping layer that normalizes into it. Roll up with worst-case and counts, never averages: nine risks scored 2 and one scored 15 average 3.3, which looks harmless, while the worst case (15) and the count of high risks (1) show the problem. Put three executive views on top. The hard part is not the tables. It is getting teams to score the same way and keeping the data fresh.
Data model (core record fields)
- business_unit: product line and region.
- risk: taxonomy category, owner, status (open, treating, accepted, closed), inherent likelihood and impact, residual likelihood and impact (inherent is before controls, residual after), last reviewed date, source system and source id.
- control and a risk_control link: last test result and date.
- history: a snapshot taken daily so trends exist.
Ingestion
- Extract from each register (spreadsheet, ticket tool, an existing GRC tool) on a schedule or via API.
- Map local categories to the shared taxonomy through a mapping table owned by risk management. An unmapped category is quarantined (held in a review queue) with an alert, not dropped.
- Validate: scores 1 to 5, owner present, review date present. Rejects go back to the register owner.
- Upsert (insert a new row, or update it if it already exists) keyed by source system plus source id, so reruns do not duplicate rows.
- Link duplicates: one vendor risk appearing in three products should point to a parent risk so the roll-up does not triple count it.
Consistent scoring
Use one 5x5 grid where score = likelihood x impact and high means 15 or above. Anchor each level with descriptors (for impact, ranges of financial loss, records exposed or downtime that leadership approved), run calibration sessions (meetings where teams score the same sample risks, compare, and discuss each difference until they converge), and have risk management re-score a small random sample each quarter. Show both the team's score and the re-scored one, so disagreement is visible rather than argued over. Roll-up uses ordinal scores (numbers that only rank risks, where the gaps between levels are not equal amounts), so do not sum them (ten minor risks scoring 2 each sum to 20, which would wrongly outrank one severe risk scoring 15), and do not mix them with quantified loss estimates from units that use FAIR (a method that estimates loss in money).
Worked roll-up
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE business_unit (id TEXT PRIMARY KEY, product_line TEXT, region TEXT);
CREATE TABLE risk (
id TEXT PRIMARY KEY, unit_id TEXT REFERENCES business_unit(id),
category TEXT, -- from the shared taxonomy
owner TEXT, status TEXT, -- open / treating / accepted / closed
likelihood INTEGER CHECK (likelihood BETWEEN 1 AND 5),
impact INTEGER CHECK (impact BETWEEN 1 AND 5),
residual_likelihood INTEGER CHECK (residual_likelihood BETWEEN 1 AND 5),
residual_impact INTEGER CHECK (residual_impact BETWEEN 1 AND 5),
last_reviewed TEXT
);
CREATE TABLE control (id TEXT PRIMARY KEY, last_test_result TEXT); -- pass / fail
CREATE TABLE risk_control (risk_id TEXT, control_id TEXT);
""")
db.executemany("INSERT INTO business_unit VALUES (?,?,?)", [
("BU1", "payments", "EU"), ("BU2", "payments", "US"), ("BU3", "lending", "EU")])
db.executemany("INSERT INTO risk VALUES (?,?,?,?,?,?,?,?,?,?)", [
("R1", "BU1", "third_party", "ana", "open", 4, 5, 3, 5, "2026-09-20"),
("R2", "BU2", "third_party", "bo", "treating", 3, 4, 2, 4, "2026-06-01"),
("R3", "BU3", "data_privacy", "cy", "open", 5, 3, 3, 3, "2026-09-28"),
("R4", "BU1", "access", "ana", "accepted", 2, 5, 2, 5, "2026-09-01"),
])
db.executemany("INSERT INTO control VALUES (?,?)", [("C1","pass"),("C2","fail")])
db.executemany("INSERT INTO risk_control VALUES (?,?)", [("R1","C1"),("R2","C2"),("R3","C1")])
print("Residual score = residual_likelihood x residual_impact; HIGH means score >= 15")
q = """
SELECT b.product_line, b.region, r.category,
COUNT(*) AS risks,
MAX(r.residual_likelihood * r.residual_impact) AS worst_residual,
SUM(r.residual_likelihood * r.residual_impact >= 15) AS high_count,
SUM(julianday('2026-10-04') - julianday(r.last_reviewed) > 90) AS stale_reviews
FROM risk r JOIN business_unit b ON b.id = r.unit_id
WHERE r.status <> 'closed'
GROUP BY b.product_line, b.region, r.category
ORDER BY worst_residual DESC, b.product_line, b.region
"""
for row in db.execute(q):
print(row)
print("Open risks with no linked control, or only failing controls:")
q2 = """
SELECT r.id, r.status FROM risk r
WHERE r.status <> 'closed' AND NOT EXISTS (
SELECT 1 FROM risk_control rc JOIN control c ON c.id = rc.control_id
WHERE rc.risk_id = r.id AND c.last_test_result = 'pass')
ORDER BY r.id
"""
for row in db.execute(q2):
print(row)
Residual score = residual_likelihood x residual_impact; HIGH means score >= 15
('payments', 'EU', 'third_party', 1, 15, 1, 0)
('payments', 'EU', 'access', 1, 10, 0, 0)
('lending', 'EU', 'data_privacy', 1, 9, 0, 0)
('payments', 'US', 'third_party', 1, 8, 0, 1)
Open risks with no linked control, or only failing controls:
('R2', 'treating')
('R4', 'accepted')
How the SQL works: the comparison inside SUM(...) is true (counted as 1) or false (counted as 0) for each row, so summing it counts how many rows meet the condition, here scores of 15 or more or reviews older than 90 days. julianday turns a date into a day number so that subtracting two dates gives the number of days between them. GROUP BY produces one output row per product line, region and category, with MAX giving the worst score in each group. The second query lists open risks for which no linked control has a passing test.
Reading the output: payments in the EU has one high residual risk (R1 scores 3 x 5 = 15, inherent 4 x 5 = 20). R2 is the only stale one: reviewed on 2026-06-01, 125 days before 2026-10-04, against a 90-day rule. R2 and R4 have no passing control: R2's only control failed its test, and R4 is accepted with no control, so its acceptance record is what the platform should surface.
Executive views
- Residual heat map (a grid colored by likelihood and impact) by product line and region, showing count of high risks and the worst score (not the mean).
- Top risks above appetite (risk appetite is the level of risk leadership agrees to accept; here, a residual score of 15 or more is above it), with owner, age, treatment status and next date.
- Control health and data quality: failed controls, risks with no passing control, share of risks with an owner, share reviewed in the last 90 days.
Limits
A rolled-up number is only as honest as its inputs. A register with stale reviews will look calm, which is why staleness is a first-class metric. Automatic aggregation cannot tell whether a team under-scored, which is what calibration is for.
A global enterprise wants one control library that maps to many regulations and frameworks, and regulations keep changing. How would you decide between buying a GRC platform and building your own, how would you structure the crosswalk so one change updates everything affected, and which systems would you integrate first?
Sample Answer
Direct answer
I would buy a GRC platform for the workflow, evidence collection and auditor-facing views, and build a thin layer of my own for what must stay portable: the unified control library and the crosswalk, stored as structured data I own and can export. Buy the commodity, own the model. That avoids a year of building ticket-and-workflow software while avoiding lock-in on the part that encodes the company's own control decisions.
Key terms
- GRC (governance, risk and compliance): software that holds controls, risks, policies, evidence and audit workflows.
- Crosswalk: a mapping that links one control to every framework requirement it satisfies.
- Unified control library: one set of company controls, each with one owner and one test, mapped to many frameworks, instead of separate control sets per framework.
- SOC 2: an auditor's report on whether a company's security controls work, issued under the American Institute of CPAs (AICPA) criteria. ISO 27001: the international standard for running an information security management system. NIST SP 800-53: a US government catalog of security controls, where IA-2(1) is the entry requiring multi-factor authentication (a second proof of identity beyond a password) for privileged accounts.
- Lock-in: being unable to leave a vendor without losing, or having to rebuild, your own data and decisions.
Buy versus build
| Factor | Leans buy | Leans build |
|---|---|---|
| Frameworks | Several common published ones (the SOC 2, ISO 27001 and NIST frameworks above) | Unusual or internal-only |
| Team | Small compliance team, few engineers to spare | Strong platform team, existing data stack |
| Integrations | Vendor has connectors for your systems | Mostly homegrown systems |
| Time to first audit | Soon | Flexible |
| Cost | License plus administration | Engineers plus maintenance forever |
| Lock-in | Can export controls and mappings | Full control |
Illustrative cost, same annual basis: buy is a 120k license plus half an administrator at 150k loaded (salary plus benefits and overhead), which is 75k, 195k per year; build is 1.5 engineers at 150k, 225k per year, before the cost of maintenance and not shipping product work. The numbers are invented for the comparison; the point is that costs are close, so capability and time decide. I would flip to build if the estate is mostly custom systems the vendor cannot connect to, or no vendor can model the company's frameworks.
Crosswalk structure so one change updates everything
Keep four linked layers, each versioned:
- Framework requirement: framework, version, clause id, text.
- Mapping (many to many: one requirement can map to several controls, and one control to several requirements): requirement to unified control, with strength (full or partial), reviewer and date.
- Unified control: statement, owner, test, systems in scope.
- Test and evidence: result, timestamp, artifact.
Filled in for one control (illustrative values), the four layers look like this:
| Layer | Row |
|---|---|
| Requirement | NIST SP 800-53 r5, IA-2(1), "multi-factor authentication for access to privileged accounts" |
| Requirement | ISO/IEC 27001:2022, Annex A 8.5, secure authentication |
| Requirement | SOC 2, CC6.1, logical access security |
| Mapping | IA-2(1) to CTL-MFA-ADMIN, full, reviewer j.doe, 2026-09-12 |
| Mapping | A.8.5 to CTL-MFA-ADMIN, full, reviewer j.doe, 2026-09-12 |
| Mapping | CC6.1 to CTL-MFA-ADMIN, partial (CC6.1 also needs other controls), reviewer j.doe, 2026-09-12 |
| Control | CTL-MFA-ADMIN, "All administrator accounts require MFA", owner iam-team, test admin_mfa_enforced, systems idp-prod |
| Test and evidence | 2026-10-03, pass, 0 of 41 admins without MFA, artifact a1f09c |
If a framework later renumbers A.8.5, only that requirement row and its mapping row change. The control, its test and the evidence history stay untouched.
Because requirements point at controls rather than at each other, changing one control's test updates every framework it supports. A new framework revision adds new requirement rows, and the diff immediately lists controls with unmapped new requirements. Where available, export in an open format; NIST's OSCAL (Open Security Controls Assessment Language) offers machine-readable catalogs, baselines and assessment data in XML, JSON and YAML.
Using automation to suggest mappings
A language model or text-similarity tool can propose candidate mappings. Store them as suggested, never approved. A person reviews each one; ambiguous requirements are marked partial and escalated to the control owner, counsel or the auditor, who decides what counts. Track the acceptance rate (the share of suggested mappings that reviewers approve), since a low rate means the suggestions are noise.
Which systems to integrate first
- Identity provider: access, MFA and joiner-leaver evidence supports many controls.
- Cloud account and asset inventory: defines scope and supplies configuration checks.
- Ticketing and change management: remediation and approval evidence.
- SIEM (security event log platform): logging and detection evidence, after the basics.
The reason is coverage per integration: identity and inventory feed the most controls for the least effort.
Worked example
Unified control "admins use multi-factor authentication" maps to NIST SP 800-53 IA-2(1) and to the matching SOC 2 (CC6.1) and ISO 27001 (Annex A 8.5) requirements, as the three mapping rows above show. One check against the identity provider updates all three.
Pitfall
Starting with per-framework control lists inside the tool, which recreates the duplication the unified library exists to remove.
An auditor challenges your team: how can they be sure the automated evidence you hand over was not altered between collection and review? Design the evidence pipeline so integrity and provenance can be verified independently by the auditor, and explain what you would still not be able to prove.
Sample Answer
Direct answer
I would make the evidence tamper-evident and independently verifiable by signing it at the point of collection, chaining every record to the one before, storing it where it cannot be deleted, and giving the auditor the public key and periodic head hashes directly so they can verify without trusting us. Tamper-evident means alteration cannot happen unnoticed, which is weaker than "cannot happen". I would also tell the auditor plainly what this does not prove.
Threat model first
Who could alter evidence: a collector administrator, a storage administrator, a pipeline bug, or the team that owns the failing control. The design must hold even against our own admins.
Two building blocks
A hash (here SHA-256, a standard hash function) is a short fingerprint computed from data: the same data always gives the same fingerprint, and changing one character gives a completely different one, so a fingerprint shows whether data was changed but not who changed it. A digital signature is made with a private key that only the signer holds and checked with the matching public key, which can be shared freely. A valid signature shows the signed data is unchanged since signing and that the signer held the private key. The design below uses hashes to link records and a signature to anchor the chain. The core of the answer is three things: a hash chain, a signature by someone other than the evidence administrators, and a copy of the latest hash held outside our control. The rest (compliance versus governance mode, a timestamp authority, break-glass access) sets how strongly or how long those three hold.
The pipeline
- Collect with a read-only service identity, and record source, time and tool version.
- Hash and chain. Each record's hash covers its own content plus the previous record's hash, so changing one record breaks every later link.
- Sign the chain head (the newest hash, which depends on every record before it) with a private key held in a key management service or HSM (hardware security module, a tamper-resistant key device), controlled by a different team than the evidence administrators.
- Store immutably. S3 Object Lock in compliance mode (a write-once-read-many setting) means a protected object version cannot be overwritten or deleted by any user, including the account root user, until its retention date. Governance mode can be bypassed by someone holding a special permission, so it is weaker.
- Anchor externally. Send head hashes at period close to the auditor, or to an RFC 3161 time-stamping authority (a trusted third party that signs a hash with a time, proving the data existed before that time).
- Give the auditor a verifier and the public key. They run it themselves.
CloudTrail (the AWS activity log) has a built-in example of the same idea, log file integrity validation: SHA-256 hashes for each log file, an hourly digest file referencing them, signed with SHA-256 with RSA (a widely used signature scheme), with each digest containing the previous digest's signature. In plain terms, CloudTrail fingerprints each log file, signs an hourly list of those fingerprints, and links each list to the one before it, which is the chain-plus-signature pattern above.
Runnable demonstration of the chain and the verifier
import hashlib, json
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
def sha256(b): return hashlib.sha256(b).hexdigest()
# --- collector side -------------------------------------------------------
signing_key = Ed25519PrivateKey.generate()
public_key = signing_key.public_key() # given to the auditor out of band
items = [
("2025-03-01T02:00:00Z", "iam-users", {"users_without_mfa": 0}),
("2025-03-02T02:00:00Z", "iam-users", {"users_without_mfa": 1}),
("2025-03-03T02:00:00Z", "iam-users", {"users_without_mfa": 0}),
]
manifest, prev = [], "0" * 64
for ts, check, result in items:
body = json.dumps({"ts": ts, "check": check, "result": result}, sort_keys=True)
entry_hash = sha256((prev + body).encode()) # each entry commits to the one before
manifest.append({"body": body, "prev": prev, "hash": entry_hash})
prev = entry_hash
signature = signing_key.sign(prev.encode()) # signs the head of the chain
# --- auditor side: needs only manifest, signature, public key ------------
def verify(manifest, signature, public_key):
prev = "0" * 64
for i, e in enumerate(manifest):
if e["prev"] != prev or sha256((prev + e["body"]).encode()) != e["hash"]:
return f"FAIL: chain broken at entry {i}"
prev = e["hash"]
try:
public_key.verify(signature, prev.encode())
except Exception:
return "FAIL: head signature invalid"
return f"OK: {len(manifest)} entries, head {prev[:12]}"
print(verify(manifest, signature, public_key))
# tamper with the middle record (the failing MFA check) and re-verify
tampered = json.loads(json.dumps(manifest))
tampered[1]["body"] = tampered[1]["body"].replace('"users_without_mfa": 1', '"users_without_mfa": 0')
print(verify(tampered, signature, public_key))
# attacker also rebuilds every hash after the edit; only the signature stops this
prev = "0" * 64
for e in tampered:
e["prev"] = prev
e["hash"] = sha256((prev + e["body"]).encode())
prev = e["hash"]
print(verify(tampered, signature, public_key))
# deleting the newest entry leaves a valid chain, but the signed head no longer matches
print(verify(manifest[:-1], signature, public_key))
Real output:
OK: 3 entries, head 673b90aca7e9
FAIL: chain broken at entry 1
FAIL: head signature invalid
FAIL: head signature invalid
Plain walkthrough of the demo. Each entry stores the hash of the entry before it, so the three entries form a chain. When the middle record is edited, its recomputed hash no longer equals the stored one, so verification fails at entry 1. To hide that, an attacker must recompute entry 1's hash, which changes what entry 2 must store as its previous hash, which changes entry 2's hash, and so on, so every later hash changes. That is what the third case does. The chain is then consistent again, but its head is a different value from the one the signature was made over, and the attacker does not hold the private key to produce a new signature, so the signature check fails.
The first check verifies. The fourth check, deleting the newest entry, leaves a consistent chain but a different head from the one the signature covers, so it also fails. The demo needs the cryptography package. Ed25519, used in it, is a modern digital-signature algorithm; any standard signature scheme would show the same behavior.
Other sources, retention and access
- Endpoints, containers and network devices: have a local agent or the ingesting collector sign the record with a per-source identity, and produce a signed attestation report (a signed statement of what was collected from which source).
- Retention and disposition: retention is set per evidence class by the longest applicable requirement, with counsel confirming. When evidence is deleted after retention, a deletion record is written into the chain so the absence is explained.
- Access control: auditors get a read-only role, writers cannot delete, admins are separate, and every read is logged.
- Break-glass access: reading is allowed through a named role that opens an incident, expires, and is logged. It does not allow deletion, since compliance-mode retention blocks that regardless.
What I still could not prove
- That the source was true at collection. A compromised source or collector is faithfully signed.
- That nothing was left unrecorded. The chain shows that nothing recorded was changed, not that every check that should have run was recorded. A schedule of expected runs covers this.
- That the check logic is adequate for the control objective.
- The exact time. A timestamp authority proves the hash existed before that time, not that the collector clock was accurate.
- Key honesty. Someone holding the signing key who also controls storage could rebuild and re-sign everything, which is why key custody is separate and head hashes go outside our control early. The demo's signature check protects only while the key is held by someone other than the attacker.
Unlock Full Question Bank
Get access to all 7 Compliance Automation and Tooling interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.