-
Notifications
You must be signed in to change notification settings - Fork 38
Security hardening: Helmet, CORS allowlist, and HTTPS enforcement #168
Copy link
Copy link
Open
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignCampaign: Third CampaignbackendBackend related issuesBackend related issuesdifficulty:hardHard difficulty issuesHard difficulty issuespriority:highHigh priority issuesHigh priority issuessecuritySecurity improvementsSecurity improvements
Description
Activity
Metadata
Metadata
Assignees
Labels
GrantFox OSSIssue tracked in GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignCampaign: Third CampaignbackendBackend related issuesBackend related issuesdifficulty:hardHard difficulty issuesHard difficulty issuespriority:highHigh priority issuesHigh priority issuessecuritySecurity improvementsSecurity improvements
What
Add Helmet.js for security headers, replace the permissive CORS configuration with an environment-driven allowlist, and add HTTPS enforcement middleware to the NestJS backend.
Why
The backend currently has three security gaps:
app.enableCors({ origin: true })allows requests from any origin — this is acceptable in development but dangerous in production for a health-data platformThese are OWASP Top 10 adjacent issues (A05:2021 Security Misconfiguration) and should be addressed before any production deployment.
Scope
In scope:
@nestjs/helmetin the backendapp.enableCors({ origin: true })with environment-variable-driven CORS allowlist (CORS_ORIGINSenv var, comma-separated)ENABLE_HTTPS_REDIRECTenv var)CORS_ORIGINSandENABLE_HTTPS_REDIRECTto.env.exampleOut of scope:
Acceptance Criteria
@nestjs/helmetis installed and applied inmain.tsCORS_ORIGINSenv var (comma-separated list)http://localhost:3000by defaultENABLE_HTTPS_REDIRECT=true.env.exampleincludes the new env vars with commentscurl -I)Technical Context
backend/src/main.tsapp.enableCors({ origin: true })— replace this linenpm install @nestjs/helmet helmetapp.enableCors({ origin: origins.split(',') })pattern