VYPR
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.

PackageAffected versionsPatched versions
hononpm
< 4.11.74.11.7

Affected products

1
  • Range: v0.0.1, v0.0.10, v0.0.11, …

Patches

1
12c511745b3f

Merge commit from fork

https://github.com/honojs/honoSimon KöckJan 27, 2026via ghsa
2 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

News mentions

0

No linked articles in our index yet.