CVE-2021-41125: HTTP authentication credentials potentially leaked to target websites in scrapy

scrapy Updated 02 Oct 2025

Summary

06/10/2021
Yes i
Moderate
5.7

CVE-2021-41125: Scrapy HTTP authentication credentials potentially leaked to target websites. Affects scrapy across 2 version ranges.

< 1.8.1 >= 2.0.0, < 2.5.1

Fixed in 1.8.1 or 2.5.1, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-41125 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Scrapy is an open-source web crawling framework written in Python. It provides a set of tools and libraries for extracting data from websites. Scrapy allows users to define spiders that navigate websites and extract structured data. It supports various features like handling cookies, handling redirects, and HTTP authentication. However, a vulnerability has been identified in Scrapy that can potentially leak HTTP authentication credentials to target websites.

Vulnerability Detail

The vulnerability arises when using the HttpAuthMiddleware in Scrapy for HTTP authentication. If the spider attributes http_user and http_pass are used for authentication, all requests made by Scrapy, including robots.txt requests and requests reached through redirects, will expose the credentials to the target website. This can lead to unauthorized access to sensitive information or misuse of the credentials by malicious actors.

How To Fix

Latest published version: 2.19.0 as of 22 Oct 2026

pip install --upgrade "scrapy==2.19.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.8.1 1.8.1
    pip install --upgrade "scrapy==1.8.1"
  • >= 2.0.0, < 2.5.1 2.5.1
    pip install --upgrade "scrapy==2.5.1"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If upgrading Scrapy is not feasible, a workaround is to set the HTTP authentication credentials on a per-request basis. This can be done by using the w3lib.http.basic_auth_header function to convert the credentials into a value that can be assigned to the Authorization header of each request. Here's an example of how to implement this workaround in Python:

import scrapy
from w3lib.http import basic_auth_header

class MySpider(scrapy.Spider):
    name = 'myspider'
    start_urls = ['http://example.com']

    def start_requests(self):
        credentials = (self.http_user, self.http_pass)
        auth_header = basic_auth_header(*credentials)
        headers = {'Authorization': auth_header}
        for url in self.start_urls:
            yield scrapy.Request(url, headers=headers)

    def parse(self, response):
        # Parse the response here
        pass

Conclusion

The vulnerability in Scrapy allows HTTP authentication credentials to be potentially leaked to target websites. To mitigate this issue, it is crucial to upgrade to Scrapy 2.5.1 or higher and use the new http_auth_domain spider attribute. If upgrading is not feasible, setting the credentials on a per-request basis using the w3lib.http.basic_auth_header function can serve as a workaround. For further assistance on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for scrapy →

Share this vulnerability

FAQ

Scrapy is an open-source web crawling framework written in Python. It provides tools and libraries for extracting data from websites.

HTTP authentication is a method of providing credentials (username and password) to access protected resources on a website.

The vulnerability occurs when using the HttpAuthMiddleware in Scrapy. If the spider attributes http_user and http_pass are used for authentication, all requests made by Scrapy will expose the credentials to the target website.

The vulnerability can lead to unauthorized access to sensitive information or misuse of the exposed credentials by malicious actors.

To fix the vulnerability, it is recommended to upgrade to Scrapy 2.5.1 or higher. Alternatively, you can upgrade to Scrapy 1.8.1 if upgrading to the latest version is not possible. Another workaround is to set the HTTP authentication credentials on a per-request basis using the w3lib.http.basic_auth_header function.

Related vulnerabilities

Recent vulnerabilities recorded for scrapy.

How To Fix

Latest published version: 2.19.0 as of 22 Oct 2026

pip install --upgrade "scrapy==2.19.0"

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.8.1 1.8.1
    pip install --upgrade "scrapy==1.8.1"
  • >= 2.0.0, < 2.5.1 2.5.1
    pip install --upgrade "scrapy==2.5.1"

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback