Add security headers, pin AllowedHosts and honor forwarded headers
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- HTML
- Stars
- 10
- Forks
- 0
- Avg merge
- 2h 52m
- Merged PRs (30d)
- 20
Description
Tier 2 — security
Problem
- No security headers are emitted: no CSP,
X-Content-Type-Options,Referrer-PolicyorX-Frame-Options. AllowedHostsis"*", so the app answers to any Host header (host-header injection into generated links, cache poisoning).UseForwardedHeadersis not configured even though the app runs behind the App Service reverse proxy, so the scheme and client IP seen by the app are the proxy's — affecting redirects, logging and any future IP-based rate limiting.
Evidence
LearnStack/appsettings.json:11—"AllowedHosts": "*"LearnStack/Program.cs:76-95— no headers middleware, noUseForwardedHeaders
Proposed fix
- Add a middleware emitting the standard header set; start CSP in report-only mode since MudBlazor and Google Fonts need allowances, then enforce.
- Pin
AllowedHoststo the production domain(s). UseForwardedHeaderswithForwardedHeaders.XForwardedFor | XForwardedProtoearly in the pipeline.
Acceptance criteria
- securityheaders.com grade A or better
- Requests with an unexpected Host are rejected
- Logs show real client IPs and the correct scheme
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LearnStack/appsettings.json:11 and LearnStack/Program.cs:76-95; review the current request pipeline and App Service deployment settings. Define the production host allowlist and CSP allowances, then verify the requested headers, forwarded scheme and client IP, unexpected-Host rejection, and securityheaders.com grade.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100