Nitro Content Negotiation fails
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
nitro.config.js is
//https://nitro.unjs.io/config
export default defineNitroConfig({
srcDir: "server",
compressPublicAssets: true,
compatibilityDate: "2025-02-07"
});
Nitropack is 2.10.4
node --version
v20.18.0
Reproduction
https://github.com/paulcrussell/minimal-nitro
To reproduce you will need to have a chrome extension which strips the Accept-Encoding header.
Or you could request one of the public assets with Postman and omit the Accept-Encoding header.
Describe the bug
Nitro performs content negotiation however if the Accept-Encoding request header is stripped then the server returns the plain text version yet sets no Vary header in the response
This makes it possible for a client to poison a shared cache for all other clients with the plain text version
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal-nitro reproduction and the nitro.config.js configuration, then request a public asset without the Accept-Encoding header using Postman or the described Chrome extension. Inspect the content-negotiation response headers and verify that the plain-text response includes the appropriate Vary behavior so it cannot poison a shared cache.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100