[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79QN2FCP7G2F744ZY0XM6KB":3,"skill-same:01M79QN2FCP7G2F744ZY0XM6KB":43},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":20,"frontMatter":21,"refName":22,"commitSha":23,"skillDirectory":24,"forksCount":13,"repositoryHtmlUrl":25,"repositoryHomepageUrl":6,"ownerHtmlUrl":26,"ownerBlogUrl":6,"ownerDescription":27,"updatedAt":28,"install":29,"resources":42},"01M79QN2FCP7G2F744ZY0XM6KB","web-cache-security-cheat-sheet",null,"JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fweb-cache-security-cheat-sheet\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"# Web Cache Security Cheat Sheet\n\n## Introduction\n\nHTTP caches improve performance by reusing stored responses in browsers, reverse proxies, content delivery networks (CDNs), and application data stores. A cache becomes a security boundary when it serves a response to a request other than the one that originally produced it. The [HTTP caching specification](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9111.html) defines the behavior of private and shared caches, while the [MDN HTTP caching guide](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FGuides\u002FCaching) provides practical examples of common directives.\n\nThis cheat sheet focuses on preventing sensitive data exposure, web cache poisoning, web cache deception, and cross-tenant data leakage. It applies to developers and operators configuring origin applications, reverse proxies, CDNs, and application-level caches.\n\n## Key Risks\n\nThe [security considerations in RFC 9111](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9111.html#name-security-considerations) describe caches as attractive attack targets because one stored response can affect many users. [OWASP's cache poisoning overview](https:\u002F\u002Fowasp.org\u002Fwww-community\u002Fattacks\u002FCache_Poisoning) also explains how a harmful cached response can be distributed to other visitors.\n\n- **Sensitive response exposure**: A shared cache stores a personalized or authenticated response and returns it to another user.\n- **Web cache poisoning**: An attacker-controlled request input changes a response but is excluded from the cache key. The harmful response is then served to other users.\n- **Web cache deception**: A dynamic or personalized URL is made to look like a static asset, causing an intermediary to cache sensitive content.\n- **Cache key confusion**: The cache and origin disagree about URL normalization, query parameters, headers, or request routing, causing unrelated requests to share an entry.\n- **Cross-tenant leakage**: An application cache omits the tenant or authorization context from its key.\n- **Stale security state**: Cached content remains accessible after permissions, account state, or the underlying resource changes.\n\n## Best Practices\n\nTreat cacheability and cache-key design as part of the application's authorization model. [RFC 9111](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9111.html) specifies how response directives, request inputs, and validation control whether a stored response can be reused.\n\n### 1. Classify Responses Before Caching\n\nDefine an explicit policy for every route. Default to preventing shared caching for authenticated, personalized, tenant-specific, or otherwise sensitive responses.\n\n- Use `Cache-Control: no-store` when a response must not be stored by any compliant cache.\n- Use `Cache-Control: private` when a response may be stored by a user's private cache but not by a shared cache.\n- Remember that `no-cache` permits storage but requires successful validation before reuse. It does not mean \"do not store.\"\n- Do not assume that cookies make a response private. A `Set-Cookie` header alone does not prevent caching.\n- Do not mark a response influenced by `Authorization` or session cookies as `public`, or give it an `s-maxage`, unless sharing the response has been deliberately designed and reviewed.\n- Purge previously stored entries when changing a route to `no-store`; the directive does not delete old entries.\n\nFor a response containing sensitive data:\n\n```http\nCache-Control: no-store\n```\n\nFor non-sensitive content that may be stored only in a private cache and must be revalidated:\n\n```http\nCache-Control: private, no-cache\n```\n\n### 2. Design a Complete Cache Key\n\nEvery request input that can change a cacheable response must either be represented in the cache key or be rejected for that route.\n\n- Include the request method, scheme, host, normalized path, and all relevant query parameters.\n- Use [`Vary`](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FReference\u002FHeaders\u002FVary) for representation-selecting headers such as `Accept-Encoding` or `Accept-Language`.\n- Do not use `Vary: Cookie` as a general authorization boundary. Prefer disabling shared caching for personalized responses.\n- Derive tenant and user identifiers from trusted, authenticated server-side context, not directly from an untrusted header or query parameter.\n- Apply the same URL normalization and parameter handling at the CDN, reverse proxy, and origin.\n- Reject ambiguous requests, including conflicting host information, duplicate parameters with inconsistent meanings, and malformed path encodings.\n\nFor an application-level cache, use a structured, versioned key:\n\n```text\n\u003Cenvironment>:\u003Cresource-version>:\u003Ctenant-id>:\u003Cresource-type>:\u003Cresource-id>\n```\n\nDo not put session tokens, API keys, or other secrets in cache keys because keys often appear in logs and administrative interfaces.\n\n### 3. Prevent Web Cache Poisoning\n\n[Cloudflare's cache poisoning guidance](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcache\u002Fcache-security\u002Favoid-web-poisoning\u002F) describes the central design rule: untrusted request inputs that are not part of the cache key must not influence a cacheable response.\n\n- Cache only routes that are explicitly intended to be shared.\n- Do not let unkeyed headers or a body on a `GET` request alter a cacheable response.\n- Trust `Forwarded` and `X-Forwarded-*` headers only when they were added or replaced by a trusted proxy.\n- Canonicalize the host and scheme before using them to generate links, redirects, or security-sensitive headers.\n- Do not reflect unvalidated request metadata into cached HTML, JSON, redirects, or response headers.\n- Separate static assets and dynamic application routes by hostname or an unambiguous path namespace where practical.\n- If poisoning occurs, purge every affected cache layer and fix the key or origin behavior before re-enabling caching.\n\n### 4. Prevent Web Cache Deception\n\nWeb cache deception occurs when an attacker causes a shared cache to store personalized content under a URL that appears cacheable. [Cache Deception Armor](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcache\u002Fcache-security\u002Fcache-deception-armor\u002F) documents one mitigation: verifying that the requested file extension agrees with the response `Content-Type`.\n\n- Base cache eligibility on an allowlisted route and response policy, not only on a file extension.\n- Make dynamic routes reject unexpected path segments and static-looking suffixes instead of silently routing them to the same handler.\n- Ensure that a request such as `\u002Faccount\u002Fprofile\u002Fimage.css` cannot resolve to the same personalized handler as `\u002Faccount\u002Fprofile`.\n- Verify that the URL extension and response `Content-Type` agree before caching a static asset.\n- Ignore or remove query parameters from a cache key only after proving that they cannot change routing, authorization, or response content.\n\n### 5. Coordinate Origin and Intermediary Policies\n\nA secure origin policy can be weakened by a CDN rule, reverse proxy override, or framework default. [MDN's caching guide](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FGuides\u002FCaching) recommends explicitly controlling caching rather than relying on heuristic behavior.\n\n- Define browser and shared-cache lifetimes independently with the appropriate directives.\n- Review CDN rules that override origin `Cache-Control` headers or cache responses by status code, path pattern, or file extension.\n- Give error pages, redirects, and authentication responses explicit cache policies.\n- Use consistent URL normalization at every layer. When a CDN normalizes its cache key, send the normalized form to the origin as well.\n- Maintain a tested purge mechanism for individual keys, tags, or narrowly scoped route groups.\n- Fail closed when a sensitive route has a missing, malformed, or conflicting cache policy.\n\n### 6. Protect Application-Level Caches\n\nIn-memory, database, and distributed caches can leak data even when HTTP caching is disabled. Authorization must still be enforced on every request before cached data is returned. See the [Authorization Cheat Sheet](Authorization_Cheat_Sheet.md) and [Multi-Tenant Security Cheat Sheet](Multi_Tenant_Security_Cheat_Sheet.md) for related controls.\n\n- Namespace keys by environment and application to prevent collisions.\n- Include tenant identity and every authorization-relevant resource dimension in the key.\n- Do not let a cache hit bypass object-level or tenant-level authorization.\n- Avoid caching final authorization decisions unless the key includes the complete subject, object, action, policy version, and a tightly bounded lifetime.\n- Version key formats so schema or permission-model changes cannot reuse incompatible entries.\n- Restrict administrative access to cache contents, configuration, statistics, and purge operations.\n\n### 7. Test the Complete Cache Path\n\nTest through the same CDN and proxy path used in production. The [Cloudflare cache-key documentation](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcache\u002Fhow-to\u002Fcache-keys\u002F) illustrates how scheme, host, path, query parameters, headers, and cookies can contribute to a cache key.\n\n- Request the same URL as two different users and tenants; neither response may contain the other's data.\n- Change one header, query parameter, cookie, or path component at a time and verify the expected cache behavior.\n- Append static-looking suffixes and unexpected path segments to authenticated routes and verify that they are rejected and not cached.\n- Test authorization changes, logout, content updates, and purge operations against already stored entries.\n- Monitor for unexpected cache hits on authenticated routes, abrupt hit-ratio changes, unusual forwarded headers, and repeated purge activity.\n- Log enough cache-status and routing metadata to investigate incidents, but never log secrets or full sensitive response bodies.\n\n## Do's and Don'ts\n\nUse these checks alongside the [HTTP caching requirements in RFC 9111](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9111.html) and the application's normal authorization review.\n\n**Do:**\n\n- Set an explicit `Cache-Control` policy on every security-relevant response.\n- Verify that every response-changing input is included in the cache key or rejected.\n- Keep cache and origin routing rules consistent.\n- Authorize the current request before returning cached application data.\n- Test with multiple identities and tenants through the production caching path.\n- Plan and test targeted cache invalidation before an incident occurs.\n\n**Don't:**\n\n- Assume that authentication, cookies, TLS, or `Set-Cookie` automatically prevents caching.\n- Cache every URL with a static-looking extension.\n- Allow unkeyed request metadata to influence shared responses.\n- Treat `Vary: Cookie` as a substitute for an authorization design.\n- Include credentials or session identifiers in keys, logs, or purge URLs.\n- Assume that purging a poisoned entry fixes the underlying vulnerability.\n\n## References\n\n- [RFC 9111: HTTP Caching](https:\u002F\u002Fwww.rfc-editor.org\u002Frfc\u002Frfc9111.html)\n- [MDN: HTTP Caching](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FHTTP\u002FGuides\u002FCaching)\n- [Cloudflare: Avoid Web Cache Poisoning](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fcache\u002Fcache-security\u002Favoid-web-poisoning\u002F)\n",{},"main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Fweb-cache-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":7,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill web-cache-security-cheat-sheet",{"tool":35,"command":36},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill web-cache-security-cheat-sheet",{"tool":38,"command":39},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill web-cache-security-cheat-sheet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fweb-cache-security-cheat-sheet\u002FSKILL.md",true,[],[44,50,56,62,68,74],{"skillNo":45,"name":46,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":47,"categories":48,"keywords":49,"publishedAt":18},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":51,"name":52,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":18},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]