☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
Sentry logo [ WEBSITE ] [ VENDOR STATS ]
CVSS: 5.3 🐛 CWE-200
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2024-40647

CVE-2024-40647 Information Disclosure in Sentry
📅 PUBLISHED: 2024-07-18 16:51 UTC 🔄 UPDATED: 2026-09-23 20:31 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: CONFIRMED — 3+ independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.20%
👁️
0.20% probability
5.0× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Country: United States License: Freemium
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
5.3
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2024-40647 is a medium-severity information disclosure vulnerability in the official Sentry Python SDK (sentry-sdk) affecting versions prior to 2.8.0. The flaw resides in the Stdlib integration, which is enabled by default. When developers explicitly set env={} in Python's subprocess calls to prevent environment variable leakage to child processes, the Sentry SDK overrides this security measure, causing all environment variables to be passed to subprocesses. This can lead to accidental exposure of sensitive data such as API keys, database credentials, and cloud provider tokens.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

This vulnerability affects the PyPI package sentry-sdk. Organizations using this SDK in production environments should immediately upgrade to version 2.8.0 or later. The package is widely used for error tracking and performance monitoring, making this a supply chain risk for any Python application integrating Sentry.

CVSS Breakdown & Threat Level

  • CVSS Score: 5.3 (Medium)
  • Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
  • Attack Vector: Local (requires ability to execute code on the system)
  • Attack Complexity: Low
  • Privileges Required: Low
  • User Interaction: None
  • Scope: Unchanged
  • Confidentiality Impact: High (environment variables exposed)
  • Integrity Impact: None
  • Availability Impact: None

Deep Dive & Mechanics

The vulnerability is rooted in how the Sentry SDK's Stdlib integration wraps Python's subprocess.Popen and related functions. When a developer calls subprocess.Popen with env={}, the intention is to create a child process with an empty environment. However, the Sentry SDK's instrumentation intercepts this call and, due to a bug, does not respect the empty env dictionary. Instead, it passes the parent process's full environment to the child process.

The bug occurs because the SDK's wrapper code incorrectly merges the provided env with the parent's environment, rather than using the provided env as-is. This is a classic case of improper handling of default arguments in Python.

Vulnerable vs. Patched Code

Vulnerable Code (sentry-sdk < 2.8.0):

# Simplified representation of the bug
def instrument_subprocess():
    original_popen = subprocess.Popen
    def sentry_popen(*args, **kwargs):
        env = kwargs.get('env', os.environ)
        # Bug: env is merged with os.environ even if explicitly set to {}
        if env is not None:
            env = {**os.environ, **env}
        kwargs['env'] = env
        return original_popen(*args, **kwargs)
    subprocess.Popen = sentry_popen

Patched Code (sentry-sdk >= 2.8.0):

# Corrected implementation
def instrument_subprocess():
    original_popen = subprocess.Popen
    def sentry_popen(*args, **kwargs):
        # Respect the user's explicit env setting
        if 'env' in kwargs and kwargs['env'] is not None:
            env = kwargs['env']
        else:
            env = os.environ
        kwargs['env'] = env
        return original_popen(*args, **kwargs)
    subprocess.Popen = sentry_popen

Exploitation & Lab Setup

Red Team

Prerequisites:

  • Python environment with sentry-sdk < 2.8.0 installed
  • Ability to execute Python code on the target system

Exploitation Steps:

  1. Create a Python script that uses subprocess with env={}:
import subprocess
import sentry_sdk

sentry_sdk.init("https://examplePublicKey@o0.ingest.sentry.io/0")

# Intended to run with empty environment
proc = subprocess.Popen(['env'], env={}, stdout=subprocess.PIPE)
output = proc.communicate()[0].decode()
print(output)  # Will show all parent environment variables
  1. The output will contain all environment variables from the parent process, including sensitive data like AWS_SECRET_ACCESS_KEY, DATABASE_URL, etc.

Blue Team

Detection:

  • Monitor for unexpected environment variable leakage in logs or monitoring systems
  • Check for child processes that should not have inherited environment variables
  • Audit all Python applications using sentry-sdk for version < 2.8.0

Mitigation:

  • Upgrade to sentry-sdk >= 2.8.0 immediately
  • If upgrade is not possible, disable all default integrations:
import sentry_sdk
sentry_sdk.init("...", default_integrations=False)

Indicators of Compromise (IOCs)

  • File: Python scripts using subprocess.Popen with env={} while sentry-sdk < 2.8.0 is loaded
  • Process: Child processes unexpectedly inheriting parent environment variables
  • Log: Sentry SDK logs showing environment variable capture from subprocesses
  • Network: Unusual outbound connections from child processes that should have no network access

Detection Engineering

YARA Rule

rule sentry_sdk_env_leak_cve_2024_40647 {
    meta:
        description = "Detects vulnerable sentry-sdk versions (< 2.8.0) in Python packages"
        author = "Valters IT"
        date = "2024-01-01"
        cve = "CVE-2024-40647"
    strings:
        $sentry_init = "sentry_sdk.init" ascii wide nocase
        $version_check = "__version__" ascii wide
        $version_2_7 = "2.7" ascii wide
        $version_2_6 = "2.6" ascii wide
        $version_2_5 = "2.5" ascii wide
    condition:
        $sentry_init and ($version_check and ($version_2_7 or $version_2_6 or $version_2_5))
}

Sigma Rule

title: CVE-2024-40647 - Sentry SDK Environment Variable Leak
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects child processes that unexpectedly inherit parent environment variables due to vulnerable sentry-sdk
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        ParentImage|endswith: '\python.exe'
        CommandLine|contains: 'env'
    condition: selection
falsepositives:
    - Legitimate use of subprocess with env={} on patched SDK
level: medium

Suricata Rule

alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-40647 - Sentry SDK Environment Variable Leak"; flow:to_server,established; content:"sentry_sdk"; nocase; content:"env"; nocase; within:100; reference:cve,2024-40647; classtype:attempted-recon; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Upgrade sentry-sdk to version 2.8.0 or later:
pip install --upgrade sentry-sdk
  1. If upgrade is not possible, disable all default integrations:
import sentry_sdk
sentry_sdk.init("...", default_integrations=False)

Long-term Measures:

  • Implement runtime environment variable monitoring
  • Use secrets management solutions (e.g., HashiCorp Vault) instead of environment variables
  • Conduct regular dependency audits with tools like pip-audit or safety
  • Apply principle of least privilege to all subprocess calls

Detection:

  • Monitor for unexpected environment variable access in child processes
  • Review Sentry SDK logs for unusual subprocess activity
  • Implement network segmentation to limit blast radius of leaked credentials

Valters IT
Senior DevSecOps & Cyber Threat Intelligence Expert
This report is generated for educational and defensive purposes only.

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2024-40647/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.