Incorrect Authorization and Exposure of Sensitive Information to an Unauthorized Actor in scrapy
What fixes it
- 1.8.2scrapy, pipGitHub
- 2.6.0scrapy, pipGitHub
- 2.6.1scrapy/scrapyCVE List
- 1.8.2scrapy, PyPIOSV
pip install "scrapy>=1.8.2" - 2.6.0scrapy, PyPIOSV
pip install "scrapy>=2.6.0"
A fixed version on one release line is not the upgrade target for every line. Check your exact version and any vendor backports.
Description
Impact
If you manually define cookies on a [Request](https://docs.scrapy.org/en/latest/topics/request-response.html#scrapy.http.Request) object, and that Request object gets a redirect response, the new Request object scheduled to follow the redirect keeps those user-defined cookies, regardless of the target domain.
Patches
Upgrade to Scrapy 2.6.0, which resets cookies when creating Request objects to follow redirects¹, and drops the `Cookie` header if manually-defined if the redirect target URL domain name does not match the source URL domain name².
If you are using Scrapy 1.8 or a lower version, and upgrading to Scrapy 2.6.0 is not an option, you may upgrade to Scrapy 1.8.2 instead.
¹ At that point the original, user-set cookies have been processed by the cookie middleware into the global or request-specific cookiejar, with their domain restricted to the domain of the original URL, so when the cookie middleware processes the new (redirect) request it will incorporate those cookies into the new request as long as the domain of the new request matches the domain of the original request.
² This prevents cookie leaks to unintended domains even if the cookies middleware is not used.
Workarounds
If you cannot upgrade, set your cookies using a list of dictionaries instead of a single dictionary, as described in the [Request documentation](https://docs.scrapy.org/en/latest/topics/request-response.html#scrapy.http.Request), and set the right domain for each cookie.
Alternatively, you can disable cookies altogether, or limit target domains to domains that you trust with all your user-set cookies.
References
- Originally reported at huntr.dev
For more information
If you have any questions or comments about this advisory:
- Open an issue
- [Email us](mailto:opensource@zyte.com)
Text from GitHub Advisory Database
Affected versions 65
- scrapy, pip< 1.8.2GitHub
- scrapy, pip>= 2.0.0, < 2.6.0GitHub
- scrapy/scrapyaffected: unspecified before 2.6.1CVE List
- scrapy, PyPIfrom first release, fixed in 1.8.2OSV
- scrapy, PyPI0.10.4.2364OSV
- scrapy, PyPI0.12.0.2550OSV
- scrapy, PyPI0.14.1OSV
- scrapy, PyPI0.14.2OSV
- scrapy, PyPI0.14.3OSV
- scrapy, PyPI0.14.4OSV
- scrapy, PyPI0.16.0OSV
- scrapy, PyPI0.16.1OSV
- scrapy, PyPI0.16.2OSV
- scrapy, PyPI0.16.3OSV
- scrapy, PyPI0.16.4OSV
- scrapy, PyPI0.16.5OSV
- scrapy, PyPI0.18.0OSV
- scrapy, PyPI0.18.1OSV
- scrapy, PyPI0.18.2OSV
- scrapy, PyPI0.18.3OSV
- scrapy, PyPI0.18.4OSV
- scrapy, PyPI0.20.0OSV
- scrapy, PyPI0.20.1OSV
- scrapy, PyPI0.20.2OSV
- scrapy, PyPI0.22.0OSV
- scrapy, PyPI0.22.1OSV
- scrapy, PyPI0.22.2OSV
- scrapy, PyPI0.24.0OSV
- scrapy, PyPI0.24.1OSV
- scrapy, PyPI0.24.2OSV
- scrapy, PyPI0.24.3OSV
- scrapy, PyPI0.24.4OSV
- scrapy, PyPI0.24.5OSV
- scrapy, PyPI0.24.6OSV
- scrapy, PyPI0.7OSV
- scrapy, PyPI0.8OSV
- scrapy, PyPI0.9OSV
- scrapy, PyPI1.0.0OSV
- scrapy, PyPI1.0.0rc1OSV
- scrapy, PyPI1.0.0rc2OSV
- scrapy, PyPI1.0.0rc3OSV
- scrapy, PyPI1.0.1OSV
- scrapy, PyPI1.0.2OSV
- scrapy, PyPI1.0.3OSV
- scrapy, PyPI1.0.4OSV
- scrapy, PyPI1.0.5OSV
- scrapy, PyPI1.0.6OSV
- scrapy, PyPI1.0.7OSV
- scrapy, PyPI1.1.0OSV
- scrapy, PyPI1.1.0rc1OSV
- scrapy, PyPI1.1.0rc2OSV
- scrapy, PyPI1.1.0rc3OSV
- scrapy, PyPI1.1.0rc4OSV
- scrapy, PyPI1.1.1OSV
- scrapy, PyPIfrom 2.0.0, fixed in 2.6.0OSV
- scrapy, PyPI2.0.0OSV
- scrapy, PyPI2.0.1OSV
- scrapy, PyPI2.1.0OSV
- scrapy, PyPI2.2.0OSV
- scrapy, PyPI2.2.1OSV
- scrapy, PyPI2.3.0OSV
- scrapy, PyPI2.4.0OSV
- scrapy, PyPI2.4.1OSV
- scrapy, PyPI2.5.0OSV
- scrapy, PyPI2.5.1OSV
References 7
- github.com/scrapy/scrapy/commit/8ce01b3b76d4634f55067d6cfdf632ec70ba304aFixvia CVE List
- github.com/scrapy/scrapy/security/advisories/GHSA-cjvr-mfj7-j4j8Advisoryvia GitHub
- github.com/pypa/advisory-database/tree/main/vulns/scrapy/PYSEC-2022-159.yamlAdvisoryvia GitHub
- github.com/advisories/GHSA-cjvr-mfj7-j4j8Advisoryvia GitHub
- nvd.nist.gov/vuln/detail/CVE-2022-0577Referencevia GitHub
- huntr.dev/bounties/3da527b1-2348-4f69-9e88-2e11a96ac585Referencevia CVE List
- lists.debian.org/debian-lts-announce/2022/03/msg00021.htmlReferencevia CVE List