checkId: check.security.headers plugin: stellaops.doctor.security severity: warn tags: [security, headers, web]

Security Headers

What It Checks

Validates that HTTP security headers are properly configured. The check inspects the Security:Headers:* and Headers:* configuration sections for five critical headers:

HeaderSettingIssue if missing or misconfigured
HSTSHsts:EnabledNot enabled — browsers won’t enforce HTTPS
X-Frame-OptionsXFrameOptionsNot configured, or set to ALLOWALL — clickjacking risk with no protection
Content-Security-PolicyContentSecurityPolicy / CspNot configured — XSS and injection risks
X-Content-Type-OptionsXContentTypeOptionsNot enabled — MIME type sniffing vulnerability
Referrer-PolicyReferrerPolicyNot configured — referrer information leaks

The check reports a warning listing every unconfigured or weakened header.

Why It Matters

Security headers are a defense-in-depth measure that protects against common web attacks:

Common Causes

How to Fix

Docker Compose

Set security headers via environment variables:

environment:
  Security__Headers__Hsts__Enabled: "true"
  Security__Headers__XFrameOptions: "DENY"
  Security__Headers__ContentSecurityPolicy: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
  Security__Headers__XContentTypeOptions__Enabled: "true"
  Security__Headers__ReferrerPolicy: "strict-origin-when-cross-origin"

Bare Metal / systemd

Edit appsettings.json:

{
  "Security": {
    "Headers": {
      "Hsts": {
        "Enabled": true
      },
      "XFrameOptions": "DENY",
      "ContentSecurityPolicy": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'",
      "XContentTypeOptions": {
        "Enabled": true
      },
      "ReferrerPolicy": "strict-origin-when-cross-origin"
    }
  }
}

Kubernetes / Helm

Set in Helm values:

security:
  headers:
    hsts:
      enabled: true
    xFrameOptions: "DENY"
    contentSecurityPolicy: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
    xContentTypeOptions:
      enabled: true
    referrerPolicy: "strict-origin-when-cross-origin"

Alternatively, configure at the ingress level:

ingress:
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      add_header X-Frame-Options "DENY" always;
      add_header X-Content-Type-Options "nosniff" always;
      add_header Referrer-Policy "strict-origin-when-cross-origin" always;
      add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

Verification

stella doctor run --check check.security.headers