ByteGuard.SecurityHeaders
0.1.0
Prefix Reserved
See the version list below for details.
dotnet add package ByteGuard.SecurityHeaders --version 0.1.0
NuGet\Install-Package ByteGuard.SecurityHeaders -Version 0.1.0
<PackageReference Include="ByteGuard.SecurityHeaders" Version="0.1.0" />
<PackageVersion Include="ByteGuard.SecurityHeaders" Version="0.1.0" />
<PackageReference Include="ByteGuard.SecurityHeaders" />
paket add ByteGuard.SecurityHeaders --version 0.1.0
#r "nuget: ByteGuard.SecurityHeaders, 0.1.0"
#:package ByteGuard.SecurityHeaders@0.1.0
#addin nuget:?package=ByteGuard.SecurityHeaders&version=0.1.0
#tool nuget:?package=ByteGuard.SecurityHeaders&version=0.1.0
ByteGuard.SecurityHeaders 
ByteGuard.SecurityHeaders is a lightweight security-focused middleware package for adding a baseline set of security response headers to ASP.NET Core projects.
It gives you:
- A single
app.UseDefaultApiSecurityHeaders()call to apply sane defaults - OWASP-inspired header values based on the REST Security Cheat Sheet
- An
Enforceoption to ensure the standard values are applied even if set elsewhere
⚠️ Important: This package is one layer in a defense-in-depth strategy.
It does not replace proper authentication/authorization, input validation, TLS configuration, CORS hardening, or other security controls.
Features
- ✅ Add default security headers to every response
- ✅ OWASP-inspired defaults for REST APIs
- ✅ Non-breaking by default (does not override existing headers)
- ✅ Optional enforcement mode to overwrite existing values
- ✅ Minimal setup (
UseDefaultApiSecurityHeaders)
Getting Started
Installation
This package is published and installed via NuGet.
Reference the package in your project:
dotnet add package ByteGuard.SecurityHeaders
Usage
Basic Usage
Add the middleware early in your pipeline:
var app = builder.Build();
app.UseDefaultApiSecurityHeaders();
app.MapControllers();
app.Run();
Enforce standard header values
By default, the middleware will not override headers that are already present. If you want to ensure the standard values are always used (even if other middleware/controllers set them), enable enforcement:
app.UseDefaultApiSecurityHeaders(options =>
{
options.Enforce = true;
});
Headers Added
The middleware adds the following headers based on the OWASP REST Security Cheat Sheet:
Cache-Control: no-storeContent-Security-Policy: frame-ancestors 'none'X-Content-Type-Options: nosniffX-Frame-Options: DENY
Note:
Enforce = falseuses "add-if-missing" behavior.Enforce = trueoverwrites any existing value for the headers above.
When to use this package
- ✅ When building REST APIs and you want a consistent baseline across services
- ✅ When you want a simple “secure-by-default” middleware without a large configuration surface
- ✅ When you want the option to enforce standard values across an entire API
Disclaimer
ByteGuard.SecurityHeaders is an independent open-source project maintained by the ByteGuard community.
It is not affiliated with, endorsed by, or sponsored by OWASP or the OWASP Foundation.
OWASP® is a trademark or registered trademark of the OWASP Foundation.
Any references to OWASP materials are for informational, educational, and interoperability purposes only.
License
ByteGuard.SecurityHeaders is Copyright © ByteGuard Contributors - Provided under the MIT license.
| Product | Versions 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 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
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.1.1-dev-01005 | 255 | 12/18/2025 |
| 0.1.0 | 263 | 12/18/2025 |