OwaspHeaders.Core 8.0.0

dotnet add package OwaspHeaders.Core --version 8.0.0
NuGet\Install-Package OwaspHeaders.Core -Version 8.0.0
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="OwaspHeaders.Core" Version="8.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OwaspHeaders.Core --version 8.0.0
#r "nuget: OwaspHeaders.Core, 8.0.0"
#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.
// Install OwaspHeaders.Core as a Cake Addin
#addin nuget:?package=OwaspHeaders.Core&version=8.0.0

// Install OwaspHeaders.Core as a Cake Tool
#tool nuget:?package=OwaspHeaders.Core&version=8.0.0

OwaspHeaders.Core

An ASP .NET Core middleware for injection OWASP recommended HTTP Headers for increased security. This project is designed against the OWASP Secure Headers Project.

Quick Starts

  1. Create a .NET (either Framework, Core, or 5+) project which uses ASP .NET Core

Example;

dotnet new webapi -n exampleProject
  1. Add a reference to the OwaspHeaders.Core NuGet package.

Example:

dotnet add package OwaspHeaders.Core
  1. Alter the Startup (pre .NET 6) or program (post .NET 6) class to include the following:
app.UseSecureHeadersMiddleware();

This will add a number of default HTTP headers to all responses from your server component.

The following is an example of the response headers from version 6.0.2 (taken on May 15th, 2023)

cache-control: max-age=31536000, private
strict-transport-security: max-age=63072000;includeSubDomains
x-frame-options: DENY
x-xss-protection: 0
x-content-type-options: nosniff
content-security-policy: script-src 'self';object-src 'self';block-all-mixed-content;upgrade-insecure-requests;
x-permitted-cross-domain-policies: none;
referrer-policy: no-referrer

Please note: The above example contains only the headers added by the Middleware.

Source Code Repo

The source code for this NuGet package can be found at: https://github.com/GaProgMan/OwaspHeaders.Core.

Issues and Bugs

Please raise any issues and bugs at the above mentioned source code repo.

Server Header: A Warning

The default configuration for this middleware removes the X-Powered-By header, as this can help malicious users to use targeted attacks for specific server infrastructure. However, since the Server header is added by the reverse proxy used when hosting an ASP .NET Core application, removing this header is out of scope for this middleware.

In order to remove this header, a web.config file is required, and the following should be added to it:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering removeServerHeader="true" />
        </security>
    </system.webServer>
</configuration>

The above XML is taken from this answer on ServerFault.

The web.config file will need to be copied to the server when the application is deployed.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on OwaspHeaders.Core:

Package Downloads
wjsz-base

wjsz基础库

Whipstaff.AspNetCore

Re-usable logic for working with ASP.NET Core.

OwaspHeaders.IsolatedFunction

A .NET Core middleware for injecting the Owasp recommended HTTP Headers into Azure Isolated Functions

DojoTools

Toolkit for microservices designing developed by Pod2 in Bakery Net Dojo at Globant - Aug 2022

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OwaspHeaders.Core:

Repository Stars
GaProgMan/OnionArch
A .NET Core demo application which uses the Onion Architecture
Version Downloads Last updated
8.0.0 19,119 12/3/2023
7.5.1 30,148 8/9/2023
7.5.0 24,004 6/7/2023
7.0.1 1,380 6/5/2023
7.0.0 160 6/5/2023
6.1.0 2,680 5/15/2023
6.0.5 359 5/15/2023
6.0.4 137 5/15/2023
6.0.3 143 5/15/2023
6.0.2 291 5/11/2023
6.0.1 135 5/11/2023
6.0.0 155 5/11/2023
5.0.0 184 5/11/2023
4.6.2 1,390 5/11/2023
4.6.1 141 5/11/2023
4.6.0 158 5/11/2023
4.5.1 178,817 5/15/2022
4.5.0 429 5/15/2022
4.4.0 40,304 4/8/2022
4.3.0 446 4/8/2022
4.2.0 414,327 12/31/2019
4.1.1 7,575 11/16/2019
4.1.0 1,906 10/23/2019
3.5.2 26,287 7/19/2019
3.5.1 552 7/19/2019
3.5.0 565 7/19/2019
3.4.1 556 7/19/2019
3.4.0 15,605 3/16/2019
3.3.2 27,865 5/1/2018
3.3.1 3,374 4/16/2018
3.3.0 1,945 4/16/2018
3.2.0 1,053 4/16/2018
3.1.2 1,071 4/16/2018
3.1.1 1,172 4/13/2018
3.1.0 1,135 4/7/2018
3.0.0.3 1,641 3/20/2018
3.0.0.2 1,075 3/20/2018
3.0.0.1 2,098 2/25/2018
3.0.0 1,131 2/17/2018
2.1.0 3,403 1/2/2018
2.0.0.1 1,466 11/23/2017
2.0.0 2,506 9/20/2017
1.6.0 1,120 8/15/2017
1.5.0 1,058 8/13/2017
1.0.1 1,208 7/25/2017
0.0.0.1 1,404 7/25/2017