CVE-2021-41125: HTTP authentication credential leak to target websites in scrapy

Published Oct 6, 2021
·
Updated

Impact

If you use HttpAuthMiddleware (i.e. the httpuser and httppass spider attributes) for HTTP authentication, all requests will expose your credentials to the request target.

This includes requests generated by Scrapy components, such as robots.txt requests sent by Scrapy when the ROBOTSTXTOBEY setting is set to True, or as requests reached through redirects.

Patches

Upgrade to Scrapy 2.5.1 and use the new httpauthdomain spider attribute to control which domains are allowed to receive the configured HTTP authentication credentials.

If you are using Scrapy 1.8 or a lower version, and upgrading to Scrapy 2.5.1 is not an option, you may upgrade to Scrapy 1.8.1 instead.

Workarounds

If you cannot upgrade, set your HTTP authentication credentials on a per-request basis, using for example the w3lib.http.basicauthheader function to convert your credentials into a value that you can assign to the Authorization header of your request, instead of defining your credentials globally using HttpAuthMiddleware.

For more information If you have any questions or comments about this advisory: Open an issue Email us

Other sources

Scrapy is a high-level web crawling and scraping framework for Python. If you use HttpAuthMiddleware (i.e. the httpuser and httppass spider attributes) for HTTP authentication, all requests will expose your credentials to the request target. This includes requests generated by Scrapy components, such as robots.txt requests sent by Scrapy when the ROBOTSTXTOBEY setting is set to True, or as requests reached through redirects. Upgrade to Scrapy 2.5.1 and use the new httpauthdomain spider attribute to control which domains are allowed to receive the configured HTTP authentication credentials. If you are using Scrapy 1.8 or a lower version, and upgrading to Scrapy 2.5.1 is not an option, you may upgrade to Scrapy 1.8.1 instead. If you cannot upgrade, set your HTTP authentication credentials on a per-request basis, using for example the w3lib.http.basicauthheader function to convert your credentials into a value that you can assign to the Authorization header of your request, instead of defining your credentials globally using HttpAuthMiddleware.

MITRE

Affected Software

5 affected componentsFixes available
pip/Scrapy>=2.0.0<2.5.1
2.5.1
pip/Scrapy<1.8.1
1.8.1
scrapy scrapy<1.8.1
scrapy scrapy>=2.0.0<2.5.1
Debian Debian Linux=9.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/Scrapy to a version that resolves this vulnerability.

    Fixed in 2.5.1
  2. Upgrade

    Upgrade pip/Scrapy to a version that resolves this vulnerability.

    Fixed in 1.8.1
  3. Upgrade

    Upgrade scrapy to a version that resolves this vulnerability.

    Fixed in 2.5.1
  4. Upgrade

    Upgrade scrapy to a version that resolves this vulnerability.

    Fixed in 1.8.1
  5. Configuration

    When using Scrapy HTTP authentication with HttpAuthMiddleware, upgrade to Scrapy 2.5.1 and set the new `http_auth_domain` spider attribute so only intended domains receive the configured HTTP authentication credentials.

    Scrapy spider http_auth_domain = (use new spider attribute to control allowed domains)
  6. Configuration

    If you cannot upgrade, stop defining HTTP authentication credentials globally via `HttpAuthMiddleware`; instead set HTTP authentication credentials per-request by generating an `Authorization` header value using `w3lib.http.basic_auth_header` and assigning it to each request’s `Authorization` header.

    Scrapy HttpAuthMiddleware usage HttpAuthMiddleware (global credentials) = (avoid for global exposure)

Event History

Oct 6, 2021
CVE Published
via MITRE·05:15 PM
Data Sourced
via MITRE·05:15 PM
DescriptionSeverityWeakness
Advisory Published
05:46 PM
Data Sourced
via NVD·06:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2021-41125?

CVE-2021-41125 is classified as a moderate severity vulnerability due to the exposure of HTTP authentication credentials.

2

How do I fix CVE-2021-41125?

To resolve CVE-2021-41125, upgrade Scrapy to version 2.5.1 or later, or to version 1.8.1.

3

What type of systems are affected by CVE-2021-41125?

CVE-2021-41125 affects specific versions of Scrapy and Debian Linux 9.0.

4

What is the nature of the vulnerability in CVE-2021-41125?

CVE-2021-41125 allows for the exposure of HTTP authentication credentials when using HttpAuthMiddleware.

5

Is there a workaround for CVE-2021-41125?

There are no known workarounds for CVE-2021-41125; upgrading to a fixed version is the recommended solution.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203