ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Cookies are sent to domains that are not allowed #1758

Closed ShiraNagen closed 1 year ago

ShiraNagen commented 1 year ago

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: https://github.com/ladjs/superagent/pull/1757

Checklist

titanism commented 1 year ago

v8.0.8 released

https://github.com/ladjs/superagent/releases/tag/v8.0.8