Scrapy authorization header leakage on cross-domain redirect
Scrapy's redirect middleware kept the Authorization header when following a cross-domain redirect, leaking credentials to the second domain. An attacker controlling a redirect target could obtain the header and use it to access the original service.
scrapy/scrapy
Originally disclosed on huntr
Impact
When you send a request with the Authorization header to one domain, and the response asks to redirect to a different domain, Scrapy’s built-in redirect middleware creates a follow-up redirect request that keeps the original Authorization header, leaking its content to that second domain.
The right behavior would be to drop the Authorization header instead, in this scenario.
Patches
Upgrade to Scrapy 2.11.1.
If you are using Scrapy 1.8 or a lower version, and upgrading to Scrapy 2.11.1 is not an option, you may upgrade to Scrapy 1.8.4 instead.
Workarounds
If you cannot upgrade, make sure that you are not using the Authentication header, either directly or through some third-party plugin.
If you need to use that header in some requests, add "dont_redirect": True to the request.meta dictionary of those requests to disable following redirects for them.
If you need to keep (same domain) redirect support on those requests, make sure you trust the target website not to redirect your requests to a different domain.
Acknowledgements
This security issue was reported by @ranjit-git through huntr.com.
From the GitHub Advisory Database (GHSA-cw9j-q3vf-hrrv, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the redirect middleware did not strip the Authorization header when the redirect target's domain differed from the original request's domain.
Impact
An attacker who controls a redirect target could obtain the Authorization header and use it to access the original service, though the text does not state that exploitation was demonstrated.
What the attacker needed
Scrapy before 2.11.1; request includes Authorization header; server redirects to another domain
The fix
The issue was fixed in Scrapy 2.11.1 (and 1.8.4 for older versions) by dropping the Authorization header on cross-domain redirects.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program follows a redirect to a different website, it should not send along secret login information meant for the first site. Scrapy did not remove this information, so the second site could see it. This could let someone impersonate the user on the first site.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.