VAITP Dataset

← Back to the dataset

CVE-2026-105782

Scrapy treats Referrer-Policy as import path, executing code, causing DoS.

  • CVSS 7.5
  • CWE-470
  • Input Validation and Sanitization
  • Remote

Scrapy is a high-level web crawling and scraping framework for Python. From 1.4.0 until 2.14.2, RefererMiddleware in scrapy/spidermiddlewares/referer.py treated a Referrer-Policy response-header value that resembled a Python import path as a referrer policy class, imported the referenced object, and called it. A malicious website could supply a callable such as sys.exit and terminate a crawler processing the response. This issue is fixed in version 2.14.2.

CVSS base score
7.5
Published
2026-10-06
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
Scrapy
Fixed by upgrading
Yes

Solution

Upgrade Scrapy to version 2.14.2 (or later).

Vulnerable code sample

import importlib
from scrapy import Request, Spider
from scrapy.http import Response

class RefererMiddleware:
    def process_response(self, request: Request, response: Response, spider: Spider):
        policy = response.headers.get(b'Referrer-Policy')
        if not policy:
            return response
        # VULNERABLE: imports and executes arbitrary callable from header value
        policy_path = policy.decode().strip()
        policy_cls = importlib.import_module(policy_path)
        policy_instance = policy_cls()
        # use policy_instance to modify request.referer (omitted)
        return response

Patched code sample

import importlib
from scrapy import Request, Spider
from scrapy.http import Response

class RefererMiddleware:
    def process_response(self, request: Request, response: Response, spider: Spider):
        policy = response.headers.get(b'Referrer-Policy')
        if not policy:
            return response
        # FIX: treat header as literal policy name, no import
        policy_name = policy.decode().strip().lower()
        allowed = {'no-referrer', 'origin', 'strict-origin', 'unsafe-url'}
        if policy_name not in allowed:
            return response
        # safe handling of known policies (omitted)
        return response

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026105782,
  title        = {{Scrapy treats Referrer-Policy as import path, executing code, causing DoS.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-105782},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-105782/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.