Moderate severityOSV Advisory· Published Jan 27, 2026· Updated Jan 27, 2026
Hono cache middleware ignores "Cache-Control: private" leading to Web Cache Deception
CVE-2026-24472
Description
Hono is a Web application framework that provides support for any JavaScript runtime. Prior to version 4.11.7, Cache Middleware contains an information disclosure vulnerability caused by improper handling of HTTP cache control directives. The middleware does not respect standard cache control headers such as Cache-Control: private or Cache-Control: no-store, which may result in private or authenticated responses being cached and subsequently exposed to unauthorized users. Version 4.11.7 has a patch for the issue.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
hononpm | < 4.11.7 | 4.11.7 |
Affected products
1Patches
12 files changed · +100 −4
src/middleware/cache/index.test.ts+83 −0 modified@@ -417,3 +417,86 @@ describe('Cache Middleware', () => { expect(res.headers.get('cache-control')).toBe(null) }) }) + +describe('Cache Skipping Logic', () => { + let putSpy: ReturnType<typeof vi.fn> + + beforeEach(() => { + putSpy = vi.fn() + const mockCache = { + match: vi.fn().mockResolvedValue(undefined), // Always miss + put: putSpy, // We spy on this + keys: vi.fn().mockResolvedValue([]), + } + + vi.stubGlobal('caches', { + open: vi.fn().mockResolvedValue(mockCache), + }) + }) + + afterEach(() => { + vi.restoreAllMocks() + }) + + it('Should NOT cache response if Cache-Control contains "private"', async () => { + const app = new Hono() + app.use('*', cache({ cacheName: 'skip-test', wait: true })) + app.get('/', (c) => { + c.header('Cache-Control', 'private, max-age=3600') + return c.text('response') + }) + + const res = await app.request('/') + expect(res.status).toBe(200) + // IMPORTANT: put() should NOT be called + expect(putSpy).not.toHaveBeenCalled() + }) + + it('Should NOT cache response if Cache-Control contains "no-store"', async () => { + const app = new Hono() + app.use('*', cache({ cacheName: 'skip-test', wait: true })) + app.get('/', (c) => { + c.header('Cache-Control', 'no-store') + return c.text('response') + }) + + await app.request('/') + expect(putSpy).not.toHaveBeenCalled() + }) + + it('Should NOT cache response if Cache-Control contains no-cache="Set-Cookie"', async () => { + const app = new Hono() + app.use('*', cache({ cacheName: 'skip-test', wait: true })) + app.get('/', (c) => { + c.header('Cache-Control', 'no-cache="Set-Cookie"') + return c.text('response') + }) + + await app.request('/') + expect(putSpy).not.toHaveBeenCalled() + }) + + it('Should NOT cache response if Set-Cookie header is present', async () => { + const app = new Hono() + app.use('*', cache({ cacheName: 'skip-test', wait: true })) + app.get('/', (c) => { + c.header('Set-Cookie', 'session=secret') + return c.text('response') + }) + + await app.request('/') + expect(putSpy).not.toHaveBeenCalled() + }) + + it('Should cache normal responses (Control Test)', async () => { + const app = new Hono() + app.use('*', cache({ cacheName: 'skip-test', wait: true })) + app.get('/', (c) => { + return c.text('response') + }) + + await app.request('/') + // IMPORTANT: put() SHOULD be called for normal responses + expect(putSpy).toHaveBeenCalled() + }) +})
src/middleware/cache/index.ts+17 −4 modified@@ -14,10 +14,23 @@ const defaultCacheableStatusCodes: ReadonlyArray<StatusCode> = [200] const shouldSkipCache = (res: Response) => { const vary = res.headers.get('Vary') - // Don't cache for Vary: * - // https://www.rfc-editor.org/rfc/rfc9111#section-4.1 - // Also note that some runtimes throw a TypeError for it. - return vary && vary.includes('*') + if (vary && vary.includes('*')) { + return true + } + + const cacheControl = res.headers.get('Cache-Control') + if ( + cacheControl && + /(?:^|,\s*)(?:private|no-(?:store|cache))(?:\s*(?:=|,|$))/i.test(cacheControl) + ) { + return true + } + + if (res.headers.has('Set-Cookie')) { + return true + } + + return false } /**
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-6wqw-2p9w-4vw4ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2026-24472ghsaADVISORY
- github.com/honojs/hono/commit/12c511745b3f1e7a3f863a23ce5f921c7fa805d1ghsax_refsource_MISCWEB
- github.com/honojs/hono/releases/tag/v4.11.7ghsax_refsource_MISCWEB
- github.com/honojs/hono/security/advisories/GHSA-6wqw-2p9w-4vw4ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.