Nis2Shield.AspNetCore 1.1.4

dotnet add package Nis2Shield.AspNetCore --version 1.1.4
                    
NuGet\Install-Package Nis2Shield.AspNetCore -Version 1.1.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nis2Shield.AspNetCore" Version="1.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nis2Shield.AspNetCore" Version="1.1.4" />
                    
Directory.Packages.props
<PackageReference Include="Nis2Shield.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nis2Shield.AspNetCore --version 1.1.4
                    
#r "nuget: Nis2Shield.AspNetCore, 1.1.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nis2Shield.AspNetCore@1.1.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nis2Shield.AspNetCore&version=1.1.4
                    
Install as a Cake Addin
#tool nuget:?package=Nis2Shield.AspNetCore&version=1.1.4
                    
Install as a Cake Tool

NIS2 .NET Shield

NuGet .NET License: MIT Build

๐Ÿ›ก๏ธ Security-First Middleware for ASP.NET Core NIS2 Compliance

Companies subject to NIS2 Directive need demonstrable compliance. This middleware provides:

  1. Forensic logging with HMAC-SHA256 integrity and PII encryption (Art. 21.2.h)
  2. Rate limiting to prevent DoS/Brute Force attacks (Art. 21.2.e)
  3. Session Guard to detect hijacking via IP/User-Agent validation (Art. 21.2.a)
  4. Multi-SIEM Presets: Native connectors for Splunk, Datadog, Elasticsearch

Part of the NIS2 Shield Ecosystem: Use with @nis2shield/react-guard, @nis2shield/angular-guard, or @nis2shield/vue-guard for client-side protection and nis2shield/infrastructure for a full-stack implementation.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        Frontend                              โ”‚
โ”‚  @nis2shield/{react,angular,vue}-guard                      โ”‚
โ”‚  โ”œโ”€โ”€ SessionWatchdog (idle detection)                       โ”‚
โ”‚  โ”œโ”€โ”€ AuditBoundary (crash reports)                         โ”‚
โ”‚  โ””โ”€โ”€ โ†’ POST /api/nis2/telemetry/                           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                  Backend (NIS2 Adapter)                      โ”‚
โ”‚  **Nis2Shield.AspNetCore**                                  โ”‚
โ”‚  โ”œโ”€โ”€ ForensicLogger (HMAC signed logs)                     โ”‚
โ”‚  โ”œโ”€โ”€ RateLimiter, SessionGuard, TorBlocker                 โ”‚
โ”‚  โ””โ”€โ”€ โ†’ SIEM (Elasticsearch, Splunk, Datadog)               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚
                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Infrastructure                            โ”‚
โ”‚  nis2shield/infrastructure                                  โ”‚
โ”‚  โ”œโ”€โ”€ Centralized Logging (ELK/Splunk)                       โ”‚
โ”‚  โ””โ”€โ”€ Audited Deployment (Terraform/Helm)                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Installation

dotnet add package Nis2Shield.AspNetCore

โš™๏ธ Quick Start

Program.cs

var builder = WebApplication.CreateBuilder(args);

// 1. Register NIS2 Shield
builder.Services.AddNis2Shield(builder.Configuration);

var app = builder.Build();

// 2. Activate Middleware (before Auth)
app.UseNis2Shield();

app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();

app.Run();

appsettings.json

{
  "Nis2": {
    "Enabled": true,
    "IntegrityKey": "your-hmac-secret-key",
    "Logging": {
      "Enabled": true,
      "AnonymizeIp": true,
      "EncryptPii": true
    },
    "ActiveDefense": {
      "RateLimitEnabled": true,
      "RateLimitThreshold": 100,
      "RateLimitWindowSeconds": 60,
      "BlockTorExitNodes": true
    },
    "SessionGuard": {
      "Enabled": true,
      "SubnetTolerance": 24,
      "AllowUserAgentChange": false
    }
  }
}

๐Ÿ”’ Features

Forensic Logging

  • Standardized logs (NIS2-JSON-SCHEMA v1.0) with HMAC-SHA256 integrity signature
  • Automatic PII field encryption (GDPR compliant)
  • IP anonymization for privacy compliance

Active Defense

  • Rate Limiting: Sliding window protection against application-level DoS attacks
  • Session Guard: Session hijacking prevention via IP/User-Agent fingerprinting
  • Tor Blocker: Automatic blocking of Tor exit nodes

Multi-SIEM Integration

  • Elasticsearch: Bulk API with daily index rotation
  • Splunk: HTTP Event Collector (HEC) support
  • Datadog: Logs API v2 integration

Webhook Notifications

  • Real-time alerts to Slack, Microsoft Teams, Discord
  • Configurable event filtering

๐Ÿ“– Recipes

Banking App with Strict Security

builder.Services.AddNis2Shield(options =>
{
    options.IntegrityKey = Environment.GetEnvironmentVariable("NIS2_HMAC_KEY")!;
    
    // Rate Limiting
    options.ActiveDefense.RateLimitEnabled = true;
    options.ActiveDefense.RateLimitThreshold = 50;
    options.ActiveDefense.RateLimitWindowSeconds = 60;
    
    // Session Guard - strict mode
    options.SessionGuard.Enabled = true;
    options.SessionGuard.SubnetTolerance = 32; // exact IP match
    options.SessionGuard.AllowUserAgentChange = false;
});

Healthcare API with Full PII Protection

builder.Services.AddNis2Shield(options =>
{
    options.IntegrityKey = Environment.GetEnvironmentVariable("NIS2_HMAC_KEY")!;
    options.Logging.EncryptPii = true;
    options.Logging.AnonymizeIp = true;
    options.Logging.PiiFields = new List<string> { "email", "patient_id", "ssn" };
});

Enterprise with Splunk HEC

{
  "Nis2": {
    "IntegrityKey": "your-hmac-key",
    "Siem": {
      "Enabled": true,
      "Provider": "Splunk",
      "Endpoint": "https://splunk.company.com:8088/services/collector",
      "ApiKey": "your-hec-token",
      "IndexName": "nis2-security"
    }
  }
}

Slack Alert for Security Events

{
  "Nis2": {
    "Webhooks": {
      "Enabled": true,
      "Targets": [
        {
          "Name": "Security Alerts",
          "Url": "https://hooks.slack.com/services/xxx/yyy/zzz",
          "Provider": "Slack",
          "Events": ["rate_limit_exceeded", "tor_node_blocked", "session_hijack_detected"]
        }
      ]
    }
  }
}

๐Ÿงช Testing

dotnet test

๐Ÿ›ก๏ธ Security & Updates

Subscribe to our Security Mailing List to receive immediate alerts about:

  • Critical vulnerabilities (CVEs)
  • NIS2/DORA regulatory logic updates
  • Major breaking changes

For reporting vulnerabilities, see SECURITY.md.

๐Ÿ“„ License

MIT License - see LICENSE for details.

Project Technology Package
django-nis2-shield Django pip install django-nis2-shield
nis2-spring-shield Spring Boot Maven Central
@nis2shield/express-middleware Express npm install @nis2shield/express-middleware
@nis2shield/react-guard React npm install @nis2shield/react-guard

Documentation ยท NuGet ยท Changelog

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.4 82 1/4/2026
1.1.3 82 1/4/2026
1.1.2 82 1/3/2026
0.2.5 85 1/2/2026
0.2.3 83 1/2/2026