GHSA-466X-P45J-M4FX
Per-request http_user and http_pass credentials leaked on cross-domain redirects
Texto original en inglés · Ver en español
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-466X-P45J-M4FX divulgada · CVSS 8.2 (GitHub) | |
| Remediación | Parche 2.20.0 | Scrapy · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Impact
Since version 2.17.0, the `http_user` https://docs.scrapy.org/en/latest/topics/request-response.html#http-user and `http_pass` https://docs.scrapy.org/en/latest/topics/request-response.html#http-pass request meta keys let `HttpAuthMiddleware` https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware set the `Authorization` header of a request. When `http_auth_domain` https://docs.scrapy.org/en/latest/topics/request-response.html#http-auth-domain was not set as well, those credentials were sent to any URL.
`RedirectMiddleware` https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#scrapy.downloadermiddlewares.redirect.RedirectMiddleware removes the `Authorization` header on cross-domain redirects (GHSA-cw9j-q3vf-hrrv https://github.com/scrapy/scrapy/security/advisories/GHSA-cw9j-q3vf-hrrv), but the redirect request kept those meta keys, so `HttpAuthMiddleware` added the header again, sending the credentials to the redirect target. A website could redirect Scrapy to a host under its control to steal those credentials.
Patches
Upgrade to Scrapy 2.20.0+.
In Scrapy 2.20.0, when `http_auth_domain` is not set, `http_user` and `http_pass` are only sent to the origin (scheme, host and port) of the request where they were first used.
Workarounds
If you cannot upgrade to Scrapy 2.20.0, consider the following mitigations.
- Set `http_auth_domain`: Whenever you set `http_user` or `http_pass`, set `http_auth_domain` to the domain of the credentials. Its subdomains get the credentials as well. For example:
Request(
"https://example.com/api",
meta={
"http_user": "alice",
"http_pass": "secret",
"http_auth_domain": "example.com",
},
)- Set the header yourself: Instead of the meta keys, set the `Authorization` header with `basic_auth_header()`
https://w3lib.readthedocs.io/en/latest/w3lib.html#w3lib.http.basic_auth_header. `RedirectMiddleware` removes it on cross-domain redirects, and nothing adds it back. For example:
from w3lib.http import basic_auth_header
Request(
"https://example.com/api",
headers={"Authorization": basic_auth_header("alice", "secret")},
)Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypiScrapy |
Corregida | 2.20.0 | 0 d | 2.20.0 no afectada |
2.20.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/scrapy/scrapy/security/advisories/GHSA-466x-p45j-m4fxLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
