Tham chiếu Cập nhật lần cuối: 2026-11-23
Bảng Tham Chiếu Header Bảo Mật HTTP
Tài liệu tham chiếu đầy đủ về các header bảo mật HTTP, CORS, cookie và cache kèm giá trị khuyến nghị cho môi trường thực tế và mức độ tác động.
| Header | Purpose | Recommended Value | Security Impact |
|---|---|---|---|
| Strict-Transport-Security | Enforces HTTPS connections and prevents protocol downgrade attacks | max-age=31536000; includeSubDomains; preload | High — blocks SSL stripping and plaintext HTTP fallback across subdomains |
| Content-Security-Policy | Restricts allowed origins for scripts, styles, frames, images, and network requests | default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none' | Critical — primary browser defense against XSS, script injection, and clickjacking |
| Content-Security-Policy-Report-Only | Tests strict CSP rules in production and reports violations without blocking resources | default-src 'self'; report-to csp-endpoint | Medium — enables zero-downtime CSP rollout before enforcement |
| X-Content-Type-Options | Prevents browsers from MIME-sniffing responses away from declared Content-Type | nosniff | High — stops uploaded text or JSON files from executing as scripts or HTML |
| X-Frame-Options | Controls whether the document may be embedded inside iframe, frame, or object tags | DENY (or SAMEORIGIN if embedded internally) | High — legacy defense against UI redressing and clickjacking attacks |
| Referrer-Policy | Controls how much URL path and origin information is sent in the Referer header | strict-origin-when-cross-origin | Medium — prevents token or private path leakage to third-party origins |
| Permissions-Policy | Disables or scopes sensitive browser APIs like camera, microphone, geolocation, and USB | camera=(), microphone=(), geolocation=(), payment=() | Medium — limits blast radius if third-party embeds or scripts run on page |
| Set-Cookie (Session) | Transports authentication cookies safely with JS isolation and transport flags | __Host-sid=token; Path=/; Secure; HttpOnly; SameSite=Lax | Critical — mitigates cookie theft via XSS, MitM, and cross-site CSRF |
| Cross-Origin-Opener-Policy | Isolates the top-level browsing context from cross-origin popups and openers | same-origin | High — protects against Spectre-class cross-origin memory leaks (enables COOP/COEP) |
| Cross-Origin-Embedder-Policy | Requires subresources to opt in explicitly via CORS or CORP before loading | require-corp (or credentialless) | Medium — pairs with COOP for cross-origin isolation and SharedArrayBuffer |
| Cross-Origin-Resource-Policy | Blocks unauthorized cross-origin reads of static images, scripts, and JSON assets | same-origin (or same-site) | Medium — prevents speculative side-channel reads across origins |
| Access-Control-Allow-Origin | Specifies which origin is permitted to read CORS responses via fetch/XHR | https://app.example.com (avoid * with credentials) | High — misconfigured origin reflection leaks private authenticated responses |
| Access-Control-Allow-Credentials | Allows browsers to expose responses when cookies or Authorization headers are sent | true (only with explicit origin allowlist) | High — never combine with wildcard or untrusted Origin echoing |
| Vary | Instructs shared caches and CDNs which request headers alter the response | Origin, Accept-Encoding | Medium — prevents cross-origin CORS cache poisoning on edge CDNs |
| Cache-Control (Private API) | Prevents proxies and shared browsers from storing personalized or sensitive responses | no-store, max-age=0 | High — stops sensitive user data from lingering in shared browser or CDN caches |
| Cache-Control (Static Assets) | Caches versioned bundles or semi-static feeds cleanly with background revalidation | public, max-age=3600, stale-while-revalidate=86400 | Low — optimizes edge performance without leaking private state |
| Clear-Site-Data | Instructs the browser to wipe cookies, storage, and cache on logout | "cache", "cookies", "storage" | Medium — guarantees complete client session teardown after sign-out |
| X-DNS-Prefetch-Control | Disables speculative DNS lookups for external links embedded in user content | off | Low — reduces passive tracking and internal hostname leakage |
| X-Permitted-Cross-Domain-Policies | Blocks legacy cross-domain policy files used by Flash or PDF embeds | none | Low — hardens legacy plugin cross-domain read vectors |
| Reporting-Endpoints | Defines named HTTPS endpoints for CSP, COOP, and deprecation violation reports | csp-endpoint="https://example.com/reports" | Medium — provides real-time telemetry on browser policy violations |
| Server / X-Powered-By | Legacy banner headers that advertise exact framework and runtime versions | Strip or minimize (omit X-Powered-By) | Low — reduces automated fingerprinting noise in vulnerability scans |
| Content-Type (Charset) | Explicitly declares media type and UTF-8 character encoding on API responses | application/json; charset=utf-8 | Medium — prevents charset-confusion XSS in older browsers and parsers |
No matching rows found
Try another search term or clear the filter to restore all rows.
Công cụ liên quan
Hướng dẫn liên quan
Tài liệu liên quan
Câu hỏi thường gặp
- Which HTTP security headers provide the strongest baseline defense?
- Strict-Transport-Security (HSTS) enforces HTTPS, Content-Security-Policy (CSP) mitigates XSS and script injection, X-Content-Type-Options: nosniff blocks MIME sniffing, and X-Frame-Options or CSP frame-ancestors prevents clickjacking.
- What flags should protect session cookies in Set-Cookie?
- Session cookies should include HttpOnly to block JavaScript access, Secure to require HTTPS transport, SameSite=Lax or Strict to mitigate CSRF, and the __Host- prefix with Path=/ to bind the cookie to the exact origin.
- Why should Vary: Origin be paired with dynamic CORS headers?
- When Access-Control-Allow-Origin returns a specific allowed origin rather than *, Vary: Origin instructs CDNs and shared proxies to key cached responses by Origin, preventing cross-origin CORS cache poisoning.