Skip to content

Duplicated Strict-Transport-Security response header #1862

@davidni

Description

@davidni

Describe the bug

We return a duplicated Strict-Transport-Security response header when using the HSTS middleware (UseHsts) and the destination also includes a Strict-Transport-Security response header.

Producing this duplicated response header can be problematic, though it is generally benign (see: Is it fine to use duplicate response header with same value?)

To Reproduce

Proxy setup (pseudo-code):

app.UseHsts();
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapReverseProxy());

Destination setup:

  • Returns a Strict-Transport-Security response header.

Suggested fix

Do not return a duplicated Strict-Transport-Security value. Perhaps YARP should IGNORE the destination's response header when HSTS is already applied to the current response -- since the YARP-based server already owns TLS termination, it seems reasonable that it should also own the HSTS response.

Further technical details

Repro's with:

  • .NET 6.0.8
  • YARP 1.1.1

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't workinghelp wantedWe will welcome a contribution

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions