Skip to content

Don't store Set-Cookie responses by default (cookie leak risk) #805

Description

@u5surf

Problem

Souin caches responses carrying Set-Cookie without stripping it, as long as they're otherwise cacheable. The stored Set-Cookie is then replayed to every client hitting the same key — e.g. Cache-Control: public, max-age=60 + Set-Cookie: session=abc leaks one user's session to others. Set-Cookie is only dropped if the origin sends Cache-Control: no-cache="Set-Cookie".

Spec

Not a violation — RFC 9111 §7.3 says Set-Cookie "does not inhibit caching" and leaves control to the origin. But it's the well-known cookie-leak pitfall, and most CDNs/proxies strip it by default.

Proposal

Make the safe default: skip storing (or strip Set-Cookie before storing) responses that contain it, with an opt-in to keep current behavior.

@darkweak Open to this? Skip-store or strip-on-store preferred? Happy to PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions