Skip to content

Add helmet and broader HTTP hardening middleware #336

@Oluwaseyi89

Description

@Oluwaseyi89

Summary

Integrate the helmet middleware and implement comprehensive HTTP hardening in the backend service to enforce secure HTTP headers and protect against common web vulnerabilities, moving beyond basic CORS and Swagger-based protections.

Social Media Link

Let's collaborate on Discord. And ensure to star our repo.

Technical Context

  • Motivation: The current backend setup relies primarily on CORS and Swagger configuration for HTTP security, leaving the service exposed to a range of well-known web attacks (e.g., XSS, clickjacking, MIME sniffing, information leakage). Adopting industry-standard HTTP hardening middleware like helmet ensures robust, default protections and simplifies future security audits.
  • Current State: No global HTTP header hardening middleware is in place. Security headers are inconsistently set, and some attack surfaces (e.g., frame embedding, content sniffing, referrer policy) are not addressed.

Requirements

Backend Changes

  • Integrate the helmet middleware at the NestJS application level.
  • Enable and configure all relevant helmet protections, including:
    • Content-Security-Policy (CSP)
    • X-Frame-Options
    • X-Content-Type-Options
    • Strict-Transport-Security (HSTS)
    • Referrer-Policy
    • Cross-Origin-Resource-Policy
    • Cross-Origin-Opener-Policy
    • Cross-Origin-Embedder-Policy
    • X-DNS-Prefetch-Control
    • Expect-CT
    • Permissions-Policy
  • Document and justify any disabled or custom-configured headers (e.g., for Swagger or specific endpoints).
  • Ensure Swagger UI and CORS configuration remain functional and compatible with the new security headers.

Acceptance Criteria

  • All HTTP responses from the backend include the expected security headers with production-safe values.
  • Swagger UI and API documentation remain accessible and functional.
  • Security header configuration is documented and reviewed.
  • Automated tests or manual verification confirm the presence and correctness of headers.

Definition of Done

  • PR with middleware integration, configuration, and documentation
  • Security headers verified in staging/production environments
  • Team review completed

Working Directory

corporate-platform/corporate-platform-backend

Metadata

Metadata

Assignees

Labels

Nest.jsThis issue is to be implemented with Nest.js frameworkStellar WaveIssues in the Stellar wave programTypescriptThis issue is to be implemented with TypescriptbackendThis issue is about building backend API services.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions