Skip to content

Commit dd52fe6

Browse files
authored
docs: Add "Why Use LocalPortFiltering.AspNetCore" section to README for enhanced security context
1 parent 859fa99 commit dd52fe6

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ app.MapGet("/service2", () => "Welcome to Service 2");
4141
app.Run();
4242
```
4343

44+
## Why Use `LocalPortFiltering.AspNetCore`?
45+
46+
While ASP.NET Core provides options like `RequireHost` to filter requests based on the `Host` header, it can be vulnerable to **host header spoofing** attacks. This can allow malicious actors to bypass security measures by falsifying the `Host` header.
47+
48+
`LocalPortFiltering.AspNetCore` enhances security by relying on the actual network connection's **local port** (`ConnectionInfo.LocalPort`) for filtering requests, making it immune to host header spoofing.
49+
50+
### Key Benefits:
51+
- **Stronger security**: Prevents host header spoofing attacks by filtering based on the actual local port.
52+
- **Port-based filtering**: Allows you to enforce restrictions on which ports are allowed for specific routes, such as health checks, ensuring that only trusted internal traffic can access sensitive endpoints.
53+
- **Simple integration**: Easily integrates into your ASP.NET Core application, providing an extra layer of security for your health checks and other internal services.
54+
55+
For scenarios where you want to enforce stricter security and prevent potential attacks based on manipulated headers, `LocalPortFiltering.AspNetCore` is a highly recommended solution.
56+
4457
## Apply Filtering in Controllers
4558

4659
To restrict access to specific actions or controllers, use the `LocalPortFilteringAttribute`:
@@ -102,4 +115,4 @@ Contributions are welcome! Feel free to submit issues or pull requests to improv
102115

103116
## License
104117

105-
This project is licensed under the [MIT License](./LICENSE).
118+
This project is licensed under the [MIT License](./LICENSE).

0 commit comments

Comments
 (0)