Skip to content

[Bug]: APIRequestContext cookie path matching is too permissive (RFC 6265 §5.1.4) #43160

Closed

Description

Version

main (1.65.0-next, 6936b23)

Steps to reproduce

  1. A response sets Set-Cookie: a=1; Path=/foo/. A subsequent request.get('http://host/foo') sends a=1.
  2. request.cookies('http://host/foobar') returns a cookie with Path=/foo.

Expected behavior

Per RFC 6265 §5.1.4 (and browser behavior), request path /foo does not path-match cookie path /foo/, and /foobar does not path-match /foo (the next char after the cookie path must be / unless the cookie path ends with /).

Actual behavior

  • pathMatches in server/cookieStore.ts appends / to the request path before comparing, so /foo matches /foo/ and the cookie is sent.
  • filterCookies in server/network.ts (used by cookies(urls)) uses a bare pathname.startsWith(c.path), so /foobar matches /foo.

Additional context

Pre-existing, but more visible now that APIRequestContext.cookies() is public (#43052). Low severity.

Environment

Playwright main @ 6936b230a (1.65.0-next). Found by code review of recent commits; not OS/browser specific.

Activity

  1. yury-s commented on Oct 6, 2026

    @yury-s
    Member

    This was fixed by #43148.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions