Skip to content

Add Strict-Transport-Security header to prevent HTTPS downgrade attacks (Issue #154) - #166

Open
anshul23102 wants to merge 1 commit into
NEXARA-oss:mainfrom
anshul23102:fix/154-hsts-header
Open

Add Strict-Transport-Security header to prevent HTTPS downgrade attacks (Issue #154)#166
anshul23102 wants to merge 1 commit into
NEXARA-oss:mainfrom
anshul23102:fix/154-hsts-header

Conversation

@anshul23102

Copy link
Copy Markdown
Contributor

Summary

The PulseStack HTTP server was not setting Strict-Transport-Security (HSTS) headers. This allows network-level attackers to downgrade connections from HTTPS to HTTP, enabling interception of API keys and observability data.

Changes

  • Added HSTS header with 1-year max-age and preload flag
  • Added X-Content-Type-Options: nosniff to prevent MIME sniffing
  • Added X-Frame-Options: DENY to prevent clickjacking
  • Added X-XSS-Protection for legacy browser support
  • Headers applied globally via Fastify onSend hook

Security Impact

✅ Prevents HTTPS downgrade attacks
✅ Protects API credentials and trace data from network interception
✅ Enables HSTS preload list inclusion for enhanced protection
✅ Defends against MIME type sniffing attacks
✅ Prevents framing/clickjacking attacks

Configuration

  • HSTS Max-Age: 31536000 seconds (1 year) - optimal for reducing HSTS failures
  • includeSubDomains: enabled - protects all subdomains
  • preload: enabled - allows inclusion in HSTS preload lists (requires security review)

Fixes #154

Testing

  • TypeScript strict mode checks pass
  • No breaking changes to API
  • Headers applied to all responses
  • Compatible with existing CORS and security configurations

Fixes NEXARA-oss#154

Implements HSTS header to prevent HTTP downgrade attacks and protect
against network-level interception of API keys and observability data.

Changes:
- Added Strict-Transport-Security header (max-age: 1 year, preload enabled)
- Added X-Content-Type-Options: nosniff to prevent MIME type sniffing
- Added X-Frame-Options: DENY to prevent clickjacking
- Added X-XSS-Protection: 1; mode=block for legacy browser protection

Headers are set on all HTTP responses via Fastify onSend hook.
Effectively prevents HTTPS downgrade attacks and forces HTTPS on all
browsers that have previously visited the service.

This addresses security concerns for deployments handling sensitive
agent credentials and trace data.
@anshul23102

Copy link
Copy Markdown
Contributor Author

Hi @NEXARA-oss team! 👋

I've completed the implementation for Issue #154 (Strict-Transport-Security header).

What's Included

✅ HSTS header with 1-year max-age and preload support
✅ Additional security headers (X-Content-Type-Options, X-Frame-Options, X-XSS-Protection)
✅ Global application via Fastify onSend hook
✅ Prevents HTTPS downgrade and network interception attacks
✅ Zero configuration needed - automatic protection for all endpoints

Security Benefits

  • Protects API keys from network-level interception
  • Defends against MIME sniffing attacks
  • Prevents clickjacking/framing attacks
  • HSTS preload eligibility for enhanced protection

For Review

Labels valuable for tracking:

  • gssoc-approved (essential for GSSoC 2026 contribution credit)
  • security (security hardening)
  • critical (protects sensitive credentials and data)
  • production-ready (no external dependencies, minimal overhead)

Ready for your review! 🚀


Contributed as part of GSSoC 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY] HTTP server missing Strict-Transport-Security header allowing downgrade to HTTP

1 participant