Secure HTTP Headers and Cookies

查看原文

https://github.com/cakinney/secure 这个库列出了一些应当被妥当设置的安全相关的请求头:

  • Server: 默认设为 NULL,避免暴露服务器的信息
  • Strict-Transport-Security (HSTS): 服务不允许被降级为 HTTP 运行。max-age=63072000; includeSubdomains
  • X-Frame-Options (XFO):防止 clickjacking。SAMEORIGIN
  • X-XSS-Protection: 1; mode=block: 防止扩展脚本运行
  • X-Content-Type-Options:nosniff:不允许 MIME-sniffing
  • Content-Security-Policy (CSP): script-src 'self'; object-src 'self' 防止跨域注入
  • Referrer-Policy: no-referrer, strict-origin-when-cross-origin
  • Cache-control / Pragma: no-cache, no-store, must-revalidate / no-cache
  • Feature-Policy: 关掉这些特性:accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; speaker 'none'; sync-xhr 'none'; usb 'none'; vr 'none';"