Skip to content

Add Helmet security headers middleware #210

Description

@meshackyaro

Description

main.ts (src/main.ts) configures CORS, a global ValidationPipe, Sentry, and Swagger, but never applies any HTTP security headers middleware (no Helmet or equivalent). There's no helmet dependency in package.json either. As a result the API ships without Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, a restrictive Content-Security-Policy for the Swagger UI it serves at /api/docs, and other standard hardening headers that are close to zero-cost to add for a NestJS/Express app.

Component

Backend

Difficulty

🟢 Easy

Tasks

  • Add the helmet package as a dependency
  • Apply it in bootstrap() (src/main.ts) before other middleware, with a CSP configuration compatible with the Swagger UI served at /api/docs
  • Add a smoke test (or e2e check) asserting security headers are present on a sample response

Acceptance Criteria

  • Responses from the API include standard Helmet security headers
  • /api/docs (Swagger UI) continues to render correctly with the new CSP in place

Estimated Time

3-4 hours

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions