icy = createPolicyEngine({
name: 'nis2-access-control',
version: '1.0.0',
rules: [
{
id: 'mfa-enforcement',
condition: (ctx) => ctx.user.role !== 'service-account' && !ctx.session.mfaVerified,
effect: Effect.DENY,
message: 'MFA required for all human identities accessing production systems'
},
{
id: 'quarterly-access-review',
condition: (ctx) => {
const lastReview = ctx.user.lastAccessReviewDate;
const daysSince = (Date.now() - lastReview.getTime()) / (1000 * 60 * 60 * 24);
return daysSince > 90;
},
effect: Effect.REVIEW_REQUIRED,
message: 'Access privileges must be revalidated within 90 days'
},
{
id: 'offboarding-revocation',
condition: (ctx) => ctx.user.status === 'terminated',
effect: Effect.REVOKE_ALL,
message: 'Immediate credential and session revocation on termination'
}
]
});
**Rationale:** Policy-as-code enables version-controlled access rules that can be tested in CI/CD pipelines. Quarterly review triggers prevent privilege creep, while immediate revocation eliminates orphaned accounts that attackers routinely exploit.
### 2. Data & Infrastructure Hardening (Requirements 7, 10)
Encryption standards are explicitly defined: TLS 1.2 minimum (1.3 recommended) for transit, AES-256 for rest. Keys must be managed separately from encrypted data. Asset management requires a complete, continuously updated inventory of hardware and software components.
**Architecture Decision:** Decouple key management from application storage. Use a dedicated KMS or HSM with automated rotation. Implement automated asset discovery via CI/CD hooks and runtime agents.
```typescript
// crypto-baseline-config.ts
export const encryptionBaseline = {
transit: {
minimumProtocol: 'TLSv1.2',
recommendedProtocol: 'TLSv1.3',
cipherSuites: [
'TLS_AES_256_GCM_SHA384',
'TLS_CHACHA20_POLY1305_SHA256'
],
certificateRotationDays: 90
},
rest: {
algorithm: 'AES-256-GCM',
keyManagement: 'external-kms',
keySeparation: true,
autoRotationEnabled: true,
rotationIntervalDays: 30
},
assetInventory: {
discoveryMethod: 'agentless-scanner',
updateFrequency: 'continuous',
sbomGeneration: true,
complianceTag: 'nis2-asset-tracked'
}
};
Rationale: Hardcoding encryption parameters into configuration files ensures consistency across environments. External key management prevents catastrophic data exposure if storage volumes are compromised. Continuous asset discovery eliminates shadow IT and ensures every component is covered by security controls.
3. Incident & Continuity Operations (Requirements 2, 3)
NIS2 mandates a documented incident response plan with strict reporting windows: 24 hours for initial notification, 72 hours for detailed reporting to national authorities. Business continuity requires explicit RPO and RTO targets, documented backup procedures, and tested disaster recovery runbooks.
Architecture Decision: Classify incidents programmatically using severity thresholds. Automate reporting workflows with audit trails. Treat DR runbooks as executable code, not static documents.
// incident-classifier.ts
export interface IncidentReport {
id: string;
classification: 'low' | 'medium' | 'high' | 'critical';
detectedAt: Date;
affectedSystems: string[];
dataExposure: boolean;
operationalImpact: boolean;
}
export function classifyIncident(report: IncidentReport): {
severity: number;
reportingDeadline: Date;
requiresAuthorityNotification: boolean;
} {
const hoursSinceDetection = (Date.now() - report.detectedAt.getTime()) / 3.6e6;
const severityScore = (
(report.affectedSystems.length * 10) +
(report.dataExposure ? 40 : 0) +
(report.operationalImpact ? 30 : 0)
);
const isSignificant = severityScore >= 50 || hoursSinceDetection > 12;
return {
severity: severityScore,
reportingDeadline: new Date(Date.now() + (isSignificant ? 24 * 3600 * 1000 : 72 * 3600 * 1000)),
requiresAuthorityNotification: isSignificant
};
}
Rationale: Programmatic classification removes ambiguity around "significant incidents." The 24/72-hour windows are enforced by deadline calculators that integrate with compliance dashboards. DR runbooks should be stored as infrastructure-as-code templates that can be executed during tabletop exercises, ensuring RPO/RTO targets are validated under realistic conditions.
4. Supply Chain & Disclosure Governance (Requirements 4, 5, 9)
Third-party risk must be contractually enforced. Vulnerability disclosure requires a coordinated policy and accessible reporting channel. Staff training must be annual, measurable, and include phishing simulations.
Architecture Decision: Embed security requirements into vendor contracts via standardized clauses. Publish a machine-readable disclosure endpoint. Track training completion through HRIS integration with automated reminders.
// vendor-risk-contract.ts
export const supplyChainSecurityClause = {
mandatoryRequirements: [
'Annual third-party penetration test with remediation SLA',
'SBOM provision for all delivered software components',
'Incident notification within 24 hours of discovery',
'Data processing agreement with encryption-at-rest mandate'
],
complianceVerification: {
method: 'automated-attestation',
frequency: 'quarterly',
failureAction: 'access-suspension-until-remediation'
}
};
// disclosure-endpoint-config.ts
export const vulnerabilityDisclosureConfig = {
contact: 'security@organization.internal',
encryptionKey: 'https://keys.organization.internal/pgp-disclosure.pub',
preferredLanguages: ['en', 'de', 'fr'],
policyUrl: 'https://security.organization.internal/disclosure',
bountyProgram: false,
responseSla: '72-hours-initial-triage'
};
Rationale: Supply chain attacks bypass perimeter defenses. Contractual clauses with automated verification create enforceable security baselines for dependencies. A structured disclosure policy reduces researcher friction and accelerates patch cycles. Training completion tracking ensures human risk is quantified and addressed systematically.
Pitfall Guide
1. Treating Backups as Business Continuity
Explanation: Storing database dumps or volume snapshots does not satisfy NIS2 continuity requirements. Backups are recovery artifacts, not operational resilience.
Fix: Define explicit RPO and RTO targets per critical system. Document step-by-step DR runbooks. Execute quarterly tabletop exercises that simulate regional outages and validate recovery timelines against targets.
2. Vague Incident Classification Thresholds
Explanation: Without predefined criteria for "significant incidents," teams delay reporting or over-report minor events, triggering regulatory friction.
Fix: Implement a severity scoring matrix based on data exposure, system count, and operational impact. Automate deadline tracking for the 24-hour initial and 72-hour detailed reporting windows.
3. Hardcoded Secrets in Supply Chain Dependencies
Explanation: Third-party libraries or SaaS integrations often embed credentials or lack key separation, violating encryption and access control mandates.
Fix: Enforce externalized key management via KMS/HSM. Require vendor SBOMs and security attestations. Block deployments containing hardcoded secrets through pre-commit hooks and CI/CD scanners.
4. MFA Implemented at Application Level Only
Explanation: Application-layer MFA can be bypassed if identity tokens are leaked or legacy authentication protocols remain active.
Fix: Enforce MFA at the identity provider level. Disable legacy auth methods (basic auth, API keys without rotation). Apply conditional access policies that evaluate device compliance and session risk before token issuance.
5. Static Asset Inventories
Explanation: Manual spreadsheets or quarterly scans miss ephemeral workloads, container images, and shadow SaaS tools, leaving gaps in encryption and access coverage.
Fix: Deploy continuous asset discovery agents. Integrate inventory updates into CI/CD pipelines. Tag all resources with compliance metadata and automate drift detection against NIS2 baselines.
6. Ignoring SaaS Dependencies in Supply Chain Risk
Explanation: Teams often audit infrastructure vendors but overlook SaaS platforms that process customer data or integrate with internal APIs.
Fix: Extend vendor risk assessments to all third-party services. Require security clauses, incident notification SLAs, and data processing agreements. Verify compliance through automated attestation workflows.
7. Training Without Measurement or Simulation
Explanation: Annual slide decks do not reduce human risk. Without phishing simulations or completion tracking, organizations cannot prove awareness compliance.
Fix: Deploy quarterly phishing simulations with role-based difficulty. Track completion rates through HRIS integration. Require remedial training for repeated failures and document all records for audit readiness.
Production Bundle
Action Checklist
Decision Matrix
| Scenario | Recommended Approach | Why | Cost Impact |
|---|
| Early-stage startup (<50 employees, <€10M revenue) | Implement core controls (MFA, encryption, incident classification) with lightweight documentation | Below threshold but likely to cross it; early adoption prevents compliance debt | Low: Open-source tooling, internal policy documentation |
| Mid-market SaaS (50+ employees, €10M-€50M revenue) | Full NIS2 alignment with automated asset tracking, DR testing, and vendor risk scoring | Directly classified as "important entity"; fines scale with turnover | Medium: Policy-as-code investment, quarterly DR exercises, vendor audits |
| Enterprise cloud provider / MSP | Centralized identity governance, HSM-backed key management, automated SBOM generation, 24/7 SOC integration | High regulatory scrutiny; supply chain exposure amplifies risk | High: Dedicated compliance engineering team, automated audit pipelines, third-party assessments |
| Hybrid on-prem + cloud infrastructure | Unified asset discovery across environments, consistent encryption baselines, centralized incident reporting | Fragmented infrastructure creates visibility gaps and inconsistent controls | Medium-High: Cross-environment agents, unified policy engine, DR runbook standardization |
Configuration Template
# nis2-compliance-baseline.yaml
version: "2.1"
metadata:
framework: "NIS2-Article-21"
lastUpdated: "2024-10-15"
owner: "security-engineering"
identity:
mfa:
enforced: true
methods: ["totp", "webauthn", "push-notification"]
legacyAuthBlocked: true
accessControl:
model: "rbac"
reviewCycleDays: 90
offboarding: "immediate-revocation"
dataProtection:
transit:
minimumTls: "1.2"
recommendedTls: "1.3"
cipherPolicy: "strict"
rest:
algorithm: "AES-256-GCM"
keyManagement: "external-kms"
rotationDays: 30
incidentResponse:
classification:
significantThreshold: 50
initialReportHours: 24
detailedReportHours: 72
businessContinuity:
rpoTargets:
critical: "15m"
high: "1h"
standard: "4h"
drTestingFrequency: "quarterly"
supplyChain:
vendorAssessment:
required: true
frequency: "quarterly"
sbomMandatory: true
disclosure:
policyUrl: "https://security.internal/disclosure"
contact: "security@internal.domain"
responseSla: "72h"
training:
annualRequirement: true
phishingSimulation: true
completionTracking: "hris-integrated"
Quick Start Guide
- Run a control gap assessment: Map your current infrastructure, identity providers, and backup systems against the ten NIS2 requirements. Flag missing RPO/RTO targets, untested DR runbooks, and undocumented vendor contracts.
- Deploy policy-as-code for identity and encryption: Implement MFA enforcement at the identity provider level, disable legacy authentication, and configure external KMS with AES-256-GCM and automatic key rotation.
- Establish incident classification and reporting workflows: Define severity thresholds, automate 24-hour and 72-hour deadline tracking, and create a structured reporting template aligned with national authority requirements.
- Publish vulnerability disclosure and vendor security clauses: Host a machine-readable disclosure endpoint, draft standardized security addendums for all third-party contracts, and enable quarterly compliance attestation.
- Execute a tabletop disaster recovery exercise: Simulate a critical system failure, validate RPO/RTO targets against actual recovery times, document deviations, and update runbooks before the next compliance review cycle.