CVE-2024-40647: Unintentional exposure of environment variables to subprocesses in sentry-sdk
sentry-sdk is the official Python SDK for Sentry.io. A bug in Sentry's Python SDK < 2.8.0 allows the environment variables to be passed to subprocesses despite the `env={}` setting. In Python's `subprocess` calls, all environment variables are passed to subprocesses by default. However, if you specifically do not want them to be passed to subprocesses, you may use `env` argument in `subprocess` calls. Due to the bug in Sentry SDK, with the Stdlib integration enabled (which is enabled by default), this expectation is not fulfilled, and all environment variables are being passed to subprocesses instead. The issue has been patched in pull request #3251 and is included in sentry-sdk==2.8.0. We strongly recommend upgrading to the latest SDK version. However, if it's not possible, and if passing environment variables to child processes poses a security risk for you, you can disable all default integrations.
Security readout for executives and security teams
Plain-English summary
This issue can cause Python applications using sentry-sdk before 2.8.0 to pass environment variables into child processes even when developers tried to block that with env={}. Business risk is secret exposure, such as tokens or credentials, if those child processes are less trusted, logged, crashed, or observable.
Executive priority
Treat this as a targeted secret-exposure risk, not an internet-wide emergency. Prioritize services that run subprocesses and store credentials in environment variables. Upgrade during the next security patch window, sooner for systems handling production secrets or untrusted subprocess output.
Technical view
With Sentry Python SDK Stdlib integration enabled by default, subprocess handling could ignore the caller's intent to provide an empty environment. Affected versions are sentry-sdk < 2.8.0. The vendor fixed the issue in PR #3251 and released it in sentry-sdk 2.8.0. The CVSS vector indicates local, high-complexity conditions requiring high privileges.
Likely exposure
Exposure is likely limited to Python services using sentry-sdk < 2.8.0 that launch subprocesses with sanitized or empty env settings. Risk increases when environment variables contain credentials and the child process is lower-trust, emits diagnostics, or can be observed by another party.
Exploitation context
The provided sources do not report active exploitation, and KEV is false. Exploitation depends on a vulnerable application invoking subprocesses under conditions where inherited environment variables can be read or leaked. This is not described as a remote unauthenticated flaw.
Researcher notes
Key condition is mismatch between Python subprocess env semantics and Sentry SDK instrumentation. Validate behavior around env replacement without publishing reproduction details. Evidence supports affected product/version, default Stdlib integration relevance, and fixed release, but not active exploitation or broader product impact.
Mitigation direction
Upgrade sentry-sdk to version 2.8.0 or later.
Prefer the latest supported sentry-sdk release where compatibility allows.
If upgrade is blocked, review Sentry guidance on disabling default integrations.
Assess whether subprocesses could receive sensitive environment variables.
Rotate exposed secrets only when logs or evidence indicate leakage.
Validation and detection
Inventory Python applications using sentry-sdk versions earlier than 2.8.0.
Identify code paths that call subprocess APIs with env={} or sanitized env values.
Confirm whether Sentry Stdlib/default integrations are enabled in those applications.
Review child process logs, crash output, and telemetry for environment leakage.
Verify package updates through lockfiles, runtime images, and deployed artifacts.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · medium confidence lookup
CWE-200: Information exposure and cloud metadata lookup
Information exposure and SSRF weaknesses can make discovery, cloud metadata, and credential material review relevant. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-200 · source CWE mapping
Exposure of Sensitive Information to an Unauthorized Actor
Exposure of Sensitive Information to an Unauthorized Actor represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.