Skip to content

Cookies are sent to domains that are not allowed  #1758

@ShiraNagen

Description

@ShiraNagen

Describe the bug

I use superagent.agent() to run several requests. The cookies from set-cookies are sent to all domains without checking if the domain is the one that the set-cookie returned from.

Actual behavior

I send a request to httpbin.org that returns a header with set-cookie and then send a request to google.com and the cookie from httpbin is sent to google as well

Expected behavior

The cookie of google request should be empty

Code to reproduce

const superagent = require("superagent")
const request = superagent.agent();
const cookie = encodeURIComponent('_ga=s%3ACcsRO5I9SasTzV;Path=/;Expires=Sat,07Jan202313:53:43GMT')2023 13:53:43 GMT')
await request.get(`http://httpbin.org/response-headers?set-cookie=${cookie}`);
request.get('https://google.com').cookies;

This pull request solves that issue: #1757

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions