SentinelAI.ApiFirewall 0.2.0-preview.1

This is a prerelease version of SentinelAI.ApiFirewall.
dotnet add package SentinelAI.ApiFirewall --version 0.2.0-preview.1
                    
NuGet\Install-Package SentinelAI.ApiFirewall -Version 0.2.0-preview.1
                    
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="SentinelAI.ApiFirewall" Version="0.2.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SentinelAI.ApiFirewall" Version="0.2.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="SentinelAI.ApiFirewall" />
                    
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 SentinelAI.ApiFirewall --version 0.2.0-preview.1
                    
#r "nuget: SentinelAI.ApiFirewall, 0.2.0-preview.1"
                    
#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 SentinelAI.ApiFirewall@0.2.0-preview.1
                    
#: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=SentinelAI.ApiFirewall&version=0.2.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SentinelAI.ApiFirewall&version=0.2.0-preview.1&prerelease
                    
Install as a Cake Tool

SentinelAI.ApiFirewall

A request firewall for ASP.NET Core APIs. It inspects what callers send (JSON, YAML, form fields, uploaded files and zip archives) for content that could make your server or its background workers run code or reach places they shouldn't. It runs before your endpoint does.

Preview. The API may change before 1.0.

Why

Attackers, including AI agents probing APIs at scale, rarely send an obvious exploit. They hide one in data your system processes later: a template expression in a field that should hold a number, a reference:// or file:// URL a loader will follow, a YAML tag an unsafe parser will turn into an object, a path that climbs out of its folder. The request looks like normal data; the damage happens later, in a worker.

Install

dotnet add package SentinelAI.ApiFirewall --prerelease
builder.Services.AddSentinelAI();   // reads sentinel.yaml
var app = builder.Build();
app.UseSentinelFirewall();          // early in the pipeline

What it checks

Check Catches
Schemas per endpoint (JSON Schema subset) Wrong types (a template where an integer belongs), unknown fields, oversized values
Template injection Jinja/Twig {{ }} {% %}, ERB <% %>, ${…} expression languages, JNDI lookups
Unsafe deserialization YAML language tags (!!python/…), $type/@class type hints, Java/.NET/pickle serialized objects
Dangerous URLs Non-web schemes (file, gopher, reference, jar…), URLs to loopback, private, link-local and cloud-metadata addresses (SSRF), including decimal-encoded IPs
Path traversal ../ segments, null bytes, absolute system paths, zip entries that escape their folder (zip slip)
Command injection Shell chaining and $( ). Recorded only by default, since legitimate text trips it more often
Limits Body and file size, nesting depth, value count (YAML alias bombs), zip bombs, duplicate JSON keys, content types

Every value is inspected wherever it sits: query string, body, form field, uploaded file, file inside a zip, including object keys. Values are unwrapped and re-inspected through URL-encoding, base64 and JSON-inside-a-string.

Policy

api_firewall:
  endpoints:
    - path: /datasets/*/config          # * = one segment, ** = any
      methods: [POST]
      content_types: [multipart/form-data]
      uploads:
        allowed_extensions: [.yaml, .json, .zip]
        max_bytes: 1048576
        schema_file: schemas/dataset-config.schema.json
    - path: /search
      schema_file: schemas/search.schema.json
    - path: /templates/**
      allow_detectors: [template_injection]   # this API legitimately accepts templates
  detectors:
    template_injection: quarantine           # block, but keep a copy for review
  urls:
    allowed_hosts: [internal-api.example.com]

Blocked requests get a 400 problem response with a trace id and no details, so attackers can't tune payloads against it. Set expose_details: true for internal APIs. Quarantined requests are saved to sentinel-quarantine/, or to your own IQuarantineStore. Use mode: audit to record decisions without blocking while you tune the policy. Every decision is an OpenTelemetry event (source SentinelAI).

Opt out with .SkipSentinelFirewall() on an endpoint or group, or decide per request with UseSentinelFirewall(o => o.ShouldInspect = ctx => …).

Limits

This reduces risk; it doesn't remove it. Pattern detection catches known techniques, not every new one. Strict schemas are the strongest control here, so define them for every endpoint that accepts structured data. Hostnames aren't resolved, so DNS-rebinding SSRF needs network-level egress controls. Above all, fix the processing code too: never render templates on user data, allowlist URL schemes in loaders, use safe YAML loaders, and process uploads in a sandbox.

More: https://sentinelaidotnet.com · https://github.com/surya3524/sentinelai-net

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 is compatible.  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.

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
0.2.0-preview.1 77 10/19/2026