CVE-2024-1968: Scrapy Scrapy Leaks The Authorization Header Vulnerability

MODERATE
Advisory Identifier: GHSA-4qqq-9vqf-3h3f
CVSS 5.9
CWE-200
Published
Advisory Summary

CVE-2024-1968 is a MODERATE (CVSS 5.9) scrapy leaks the authorization header vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Scrapy libraries in the PyPI ecosystem. The issue involves scrapy leaks the authorization header on same-domain but cross-origin redirects. Remediation is available by upgrading affected packages to version 2.11.2.

CVE-2024-1968 at a Glance

CVE Identifier CVE-2024-1968
GHSA Identifier GHSA-4qqq-9vqf-3h3f
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Scrapy
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-1968

To remediate this vulnerability, upgrade all affected Scrapy dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Scrapy fixed: 2.11.2
pip install Scrapy>=2.11.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show Scrapy

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-1968, inspect your installed packages using pip:

pip show Scrapy

Analyze the terminal output to locate any version of Scrapy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.11.2), your application is affected.

Note: The pip show Scrapy command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Scrapy, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Since version 2.11.1, Scrapy drops the `Authorization` header when a request is redirected to a different domain. However, it keeps the header if the domain remains the same but the scheme (http/https) or the port change, all scenarios where the header should also be dropped. In the context of a man-in-the-middle attack, this could be used to get access to the value of that `Authorization` header ### Patches Upgrade to Scrapy 2.11.2. ### Workarounds There is no easy workaround for unpatched versions of Scrapy. You can replace the built-in redirect middlewares with custom ones patched for this issue, but you have to patch them yourself, manually. ### References This security issue was reported and fixed by @szarny at https://huntr.com/bounties/27f6a021-a891-446a-ada5-0226d619dd1a/.

CVE-2024-1968 Affected Scrapy Versions

1 component(s)
Fixed Versions:
2.11.2
Product / Package Ecosystem Affected Versions Fixed Version
Scrapy
PyPI
< 2.11.2
2.11.2

References

Frequently Asked Questions

What is CVE-2024-1968?
CVE-2024-1968 is a security vulnerability in Scrapy involving Scrapy leaks the authorization header on same-domain but cross-origin redirects under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Scrapy versions are affected?
Affected versions include releases prior to 2.11.2 across affected packages: Scrapy.
What version fixes CVE-2024-1968?
Upgrading to 2.11.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Scrapy affected?
Yes, Scrapy is affected in releases prior to 2.11.2. Upgrade your dependency to 2.11.2 or later.
What is the CVSS score of CVE-2024-1968?
CVE-2024-1968 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2024-1968?
CVE-2024-1968 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check PyPI dependencies for CVE-2024-1968?
Run the dependency tree command: 'pip show Scrapy'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4qqq-9vqf-3h3f",
  "modified" : "2024-05-20T20:22:55Z",
  "published" : "2024-05-14T20:14:33Z",
  "aliases" : [ "CVE-2024-1968" ],
  "summary" : "Scrapy leaks the authorization header on same-domain but cross-origin redirects",
  "details" : "### Impact\n\nSince version 2.11.1, Scrapy drops the `Authorization` header when a request is redirected to a different domain. However, it keeps the header if the domain remains the same but the scheme (http/https) or the port change, all scenarios where the header should also be dropped.\n\nIn the context of a man-in-the-middle attack, this could be used to get access to the value of that `Authorization` header\n\n### Patches\n\nUpgrade to Scrapy 2.11.2.\n\n### Workarounds\n\nThere is no easy workaround for unpatched versions of Scrapy. You can replace the built-in redirect middlewares with custom ones patched for this issue, but you have to patch them yourself, manually.\n\n### References\n\nThis security issue was reported and fixed by @szarny at https://huntr.com/bounties/27f6a021-a891-446a-ada5-0226d619dd1a/.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "Scrapy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.11.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/scrapy/scrapy/security/advisories/GHSA-4qqq-9vqf-3h3f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/scrapy/scrapy/commit/1d0502f25bbe55a22899af915623fda1aaeb9dd8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/scrapy/scrapy"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.com/bounties/27f6a021-a891-446a-ada5-0226d619dd1a"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-14T20:14:33Z",
    "nvd_published_at" : null
  }
}