dotnet / dotnet/aspnetcore

Reconsider default HSTS max-age value

Open
#50,605 4 comments 0 reactions 0 assignees View on GitHub
area-middleware
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

Currently, the default value for HTTP Strict Transport Security (HSTS) max-age is set to 30 days.
https://github.com/dotnet/aspnetcore/blob/410efd482f494d1ab05ce25b932b5788699c2308/src/Middleware/HttpsPolicy/src/HstsOptions.cs#L18

According to [hstspreload.org](https://hstspreload.org/), it is recommended that the minimum value should be at least 1 year, with a preferable value of 2 years.

The current default value may not align with modern security best practices, and it might be beneficial to reconsider it.

I propose that we reconsider the default value and update it to a more secure and recommended value, such as 1 year.

Also, setting a longer default max-age value will avoid additional configuration, as it is very common to reconfigure this value as follows:

```cs
builder.Services.AddHsts(options =>
{
options.MaxAge = TimeSpan.FromDays(365); // Common practice to set it to 1 year or more
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.