How to prevent framework leaks via the Vary header?
vary-header-framework-leakglobal
The Vary header specifies which request headers affect response caching. Framework-specific Vary values expose implementation details. Headers like X-Requested-With or Accept-Language combinations that are unique to specific frameworks create fingerprints that reveal the underlying technology stack.
What’s wrong
The Vary header contains values that are specific to a particular framework or library. These values are not standard HTTP headers but framework conventions. When a response includes Vary: X-Requested-With or other framework-specific headers, it signals which technology processes requests. This creates a passive information disclosure channel.
Why it matters
Framework identification reduces the cost of reconnaissance. Attackers skip generic probing and target known vulnerabilities in the identified framework. The disclosure is passive and continuous. Every cached response advertises the implementation choice. Information leakage compounds when combined with version-specific behaviors or other headers.
The correct change
Remove framework-specific headers from the Vary header list. Replace them with standard HTTP headers that serve the same caching purpose. If caching must vary by request type, use Accept or Content-Type headers which are protocol-standard. The end state is a Vary header that controls caching without exposing implementation details.
Scope
This condition applies globally. The Vary header is set at the response level by server or framework configuration. Changes affect all responses that include the header. Individual pages cannot override without broader configuration changes.
How to verify
- Validation confirms the condition is resolved:
- • Vary header contains only standard HTTP headers
- • No framework-specific header names appear in Vary values
- • X-Requested-With and similar framework conventions are absent
- • Caching behavior remains correct for dynamic content
- • Response headers do not fingerprint the technology stack
- • Security scanners no longer flag framework identification via Vary
Takeaway
- Framework-specific Vary values create passive information disclosure
- The header is visible on every response and cannot be hidden selectively
- Standard HTTP headers provide caching control without leaking implementation details
- Framework identification reduces attacker reconnaissance costs
FAQ
Does removing framework headers from Vary break caching?
Not if standard headers serve the same purpose. Accept and Content-Type control content negotiation without revealing implementation. Cache correctness depends on varying by semantically relevant headers, not framework conventions.
Can the Vary header reveal other information beyond framework choice?
Yes. Uncommon header combinations fingerprint specific configurations. A Vary header listing ten custom headers suggests complex middleware chains or specific platform choices. Even the order of headers can leak information.
What makes a Vary value framework-specific versus standard?
Standard headers are defined in HTTP specifications. X-Requested-With is a jQuery and AJAX library convention. Any X- prefixed header or framework documentation header indicates implementation choice rather than protocol requirement.
Does removing Vary headers entirely solve the problem?
No. Removing Vary when responses actually differ by request headers causes cache poisoning. The correct approach is using only standard headers that achieve the required caching semantics without disclosure.
How do CDNs affect Vary header information leakage?
CDNs forward or transform Vary headers from origin. Some CDNs add their own Vary values. The header remains visible in final responses. Origin configuration must prevent framework-specific values before they reach the CDN.
When does Vary-based framework detection matter operationally?
When the framework has known vulnerabilities or when reconnaissance reduction is part of defense in depth. The disclosure creates no immediate exploit but reduces the effort required for targeted attacks. It matters most for high-value targets.
The fix
Remove framework identification from the Vary header while maintaining correct caching behavior
Done when: Vary header uses only standard HTTP headers, preventing passive framework disclosure while preserving cache correctness
Do not
- Do not remove Vary entirely if responses legitimately differ by request headers
- Do not replace framework headers with other custom headers that also leak information
- Do not assume Vary values are invisible because they are caching metadata
- Do not add framework-specific values for debugging or analytics purposes
How to verify
- Vary header contains only standard HTTP headers
- No X- prefixed headers in Vary values
- No framework-specific header names present
- Caching behavior remains correct
- Security scanners clear framework detection flags
Find every page with this
probeo monitors this continuously across every page of your site, and records which pages passed, which failed, and which it could not determine.
Book a Call