Cached form fields In axios-cache-interceptor
Description
axios-cache-interceptor Vulnerable to Cache Poisoning via Ignored HTTP Vary Header
Summary
When a server calls an upstream service using different auth tokens, axios-cache-interceptor returns incorrect cached responses, leading to authorization bypass.
Details
The cache key is generated only from the URL, ignoring request headers like Authorization. When the server responds with Vary: Authorization (indicating the response varies by auth token), the library ignores this, causing all requests to share the same cache regardless of authorization.
Impact
Affected: Server-side applications (APIs, proxies, backend services) that:
Use axios-cache-interceptor to cache requests to upstream services
Handle requests from multiple users with different auth tokens
Upstream services replies on Vary to differentiate caches
Not affected: Browser/client-side applications (single user per browser session).
Services using different auth tokens to call upstream services will return incorrect cached data, bypassing authorization checks and leaking user data across different authenticated sessions.
Solution
After v1.11.1, automatic Vary header support is now enabled by default.
When server responds with Vary: Authorization, cache keys now include the authorization header value. Each user gets their own cache.
// v1.11.1+ (automatic, no config needed) // User 123: key = hash(url + {authorization: 'Bearer 123'}) // User 456: key = hash(url + {authorization: 'Bearer 456'}) // ✓ Different caches, no poisoning
Remediation
Upgrade to v1.11.1 or later. No code changes required, protection is automatic
Proof of Concept
const http = require('node:http'); const axios = require('axios'); const { setupCache } = require('axios-cache-interceptor'); // Server that returns different responses based on Authorization const server = http.createServer((req, res) => { const auth = req.headers.authorization; ...
All 10 responses return "Hello, user 123!" even when using "Bearer 456" - users receive each other's cached data.
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
npm | 1.11.1 |
Aliases
References