CVE-2024-40647
Medium · 5.3CVSS
5.3
EPSS
0.2%
Published
Jul 18, 2024
CISA due date
—
Cloudanix analysis
Some Python applications may have accidentally shared hidden passwords or tokens with programs they launched, even when they were configured not to.
- Exploitation
- Local Privilege
- Attacker needs
- High Privilege
- Complexity
- High
- Impact
- Data Exposure
- Component
- Library
- Class
- Information Disclosure
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Affected versions of the Sentry Python SDK before 2.8.0 can unintentionally pass the parent Python process environment to child processes even when application code explicitly calls Python subprocess APIs with env={}. The issue occurs when the SDK's Stdlib integration is enabled, which is the default. This breaks the expected security boundary of subprocess environment isolation and can expose environment-stored secrets such as API keys, cloud credentials, database URLs, tokens, proxy credentials, and deployment metadata to spawned commands. The flaw does not by itself provide remote code execution; exploitation depends on an attacker already having a way to influence, execute, observe, or compromise a subprocess that was intended to run with an empty environment.
Why it matters to the business
Organizations using vulnerable sentry-sdk versions may have unintentionally exposed sensitive configuration and credentials to helper commands, plugins, build tools, scripts, or other subprocesses. If those subprocesses are less trusted, user-controlled, logged, sandboxed incorrectly, or able to make outbound network connections, leaked environment variables could lead to credential theft, cloud or SaaS account access, data exposure, or lateral movement. Public exploitation is not known, the CVE is not in CISA KEV, and EPSS is low, but the impact can still be serious where secrets are stored in environment variables and subprocesses are used for isolation.
How an attack unfolds
An attacker first needs a path to benefit from a child process receiving environment variables: for example, the ability to influence a command executed by the Python application, run code inside a helper process, read output from a subprocess, access logs produced by a subprocess, or compromise a lower-trust tool launched by the application. The vulnerable application initializes sentry-sdk before version 2.8.0 with default integrations enabled. Application code then calls subprocess functionality intending to clear the environment, such as subprocess.run(..., env={}). Because of the SDK bug, the child process still inherits the parent process environment. The attacker causes or waits for the child process to expose its environment through stdout, stderr, logs, crash output, network callbacks, temporary files, or behavior that uses inherited credentials. The attacker then uses any recovered secrets to access downstream services or escalate access.
How to fix it
Upgrade sentry-sdk to version 2.8.0 or later. The upstream fix is included in sentry-sdk==2.8.0 and in commit 6f4685e29b072d02edfb5c9def75120e88e600e4. Update direct and transitive dependency pins in requirements.txt, pyproject.toml, Poetry/Pipenv lock files, container images, serverless packages, and build artifacts. If immediate upgrade is not possible, disable Sentry default integrations where feasible, for example by initializing the SDK with default_integrations=False, because the vulnerable behavior is associated with the default Stdlib integration. As defense in depth, avoid storing long-lived secrets in process environment variables, minimize environment contents before application startup, use short-lived credentials, isolate untrusted subprocesses, restrict child process network access, and avoid launching user-controlled commands in processes that hold sensitive environment variables.
How to confirm the fix worked
Confirm that all deployed Python runtime artifacts use sentry-sdk 2.8.0 or later by checking dependency manifests, lock files, SBOMs, container layers, and runtime output such as pip show sentry-sdk or import sentry_sdk; print(sentry_sdk.VERSION). Verify that no vendored or bundled copy of sentry-sdk before 2.8.0 remains. For behavioral validation, run a controlled test in a non-production environment with a harmless marker environment variable set in the parent process, initialize sentry-sdk as the application does, and execute a subprocess with env={}; the child process must not receive or print the marker. Also review application code for subprocess calls that rely on env={} for secret isolation and confirm they behave correctly after the upgrade or mitigation.
Typical attack path
- Identify a Python application using sentry-sdk before 2.8.0 with the default Stdlib integration enabled.
- Find application functionality, jobs, plugins, worker tasks, CI steps, converters, scanners, or helper commands that spawn subprocesses with env={} or another expectation of a sanitized environment.
- Gain the ability to influence the subprocess, read its output, access its logs, or compromise the child command/tool.
- Trigger the subprocess so it runs under the vulnerable SDK instrumentation.
- Collect inherited environment variables from child process output, logs, temporary artifacts, crash reports, or network exfiltration.
- Use exposed credentials or tokens to access cloud services, internal APIs, databases, package registries, source repositories, or other connected systems.
How to detect it
There is no reliable universal network signature or exploit string for this issue because exploitation depends on local application behavior and the specific subprocesses launched. Investigate whether environment variables were exposed after subprocess execution in applications using sentry-sdk before 2.8.0. Review application logs, worker logs, CI/CD logs, container logs, Sentry event payloads and breadcrumbs, EDR process telemetry, auditd/Sysmon-style parent-child process records, shell command outputs, crash dumps, core dumps, and temporary files produced by subprocesses. Focus on time windows when vulnerable versions were deployed and on parent Python processes that spawned commands with intended empty or sanitized environments. Search for secret-like environment variable names and values appearing in stdout/stderr, exception traces, diagnostic dumps, uploaded artifacts, or outbound requests from child processes. Correlate any unexpected child process network connections or file writes with Python parent processes using vulnerable sentry-sdk versions. If secrets are found in child process artifacts, assume exposure and rotate them.
What your security team should do
- Inventory Python applications, workers, jobs, containers, and serverless functions that include sentry-sdk, prioritizing systems that store credentials in environment variables and spawn subprocesses.
- Upgrade sentry-sdk to 2.8.0 or later everywhere, including pinned lock files and rebuilt container images.
- Where upgrade is delayed, disable default Sentry integrations or otherwise remove the vulnerable Stdlib integration behavior, then regression-test subprocess behavior.
- Search code for subprocess usage with env={} or sanitized env dictionaries and treat those locations as higher risk until patched.
- Rotate secrets that may have been exposed to subprocesses, prioritizing long-lived cloud keys, database credentials, SaaS tokens, package registry tokens, and source control credentials where child processes were lower trust or logged their environment.
- Review logs and telemetry for evidence that environment variables or secrets appeared in child process output, Sentry events, application logs, CI logs, or temporary files.
- Add automated dependency policy checks to prevent sentry-sdk versions earlier than 2.8.0 from being introduced again.
The record
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.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | sentry-sdk | 0 | 1.45.1 |
| PyPI | sentry-sdk | 0 | 2.8.0 |
| PyPI | sentry-sdk | 2.0.0a1 | 2.8.0 |
| Debian:11 | sentry-python | 0 | No fix |
| Debian:12 | sentry-python | 0 | No fix |
| Debian:13 | sentry-python | 0 | 2.16.0-1 |
| Debian:14 | sentry-python | 0 | 2.16.0-1 |
| SUSE:Package Hub 15 SP5 | python-sentry-sdk | 0 | 0.14.4-bp155.3.3.1 |
| Ubuntu:20.04:LTS | sentry-python | 0 | No fix |
| Ubuntu:22.04:LTS | sentry-python | 0 | No fix |
| Ubuntu:24.04:LTS | sentry-python | 0 | No fix |
| Ubuntu:24.10 | sentry-python | 0 | No fix |
| Ubuntu:25.04 | sentry-python | 0 | No fix |
| Ubuntu:25.10 | sentry-python | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | sentry-python | 0 | No fix |
| openSUSE:Leap 15.5 | python-sentry-sdk | 0 | 0.14.4-bp155.3.3.1 |
| openSUSE:Tumbleweed | python-sentry-sdk | 0 | 2.10.0-1.1 |
| pypi | sentry-sdk | 2.0.0a1 | No fix |
Related vulnerabilities
- CVE-2026-62979 jack lets users share media libraries through their Radarr/Sonarr stack, peer-to-peer. CWE-200
- CVE-2026-55098 Arc is an open, SQL-native time-series database for telemetry. CWE-200
- CVE-2026-119331 Ladybird is a truly independent web browser. CWE-200
- CVE-2026-62264 PDF Reader MCP is a Model Context Protocol server for reading PDF documents. CWE-200
- CVE-2026-110305 The Advanced Custom Fields: Extended plugin for WordPress is vulnerable to Sensitive… CWE-200
- CVE-2026-61730 SOCFortress CoPilot focuses on providing a single pane of glass for all your security… CWE-200
- CVE-2026-119570 Parse Server from 9.7.0 before 9.10.5-alpha.7 contains an information disclosure… CWE-200
- CVE-2026-14467 An information disclosure vulnerability in the Forocoches comments editor that allows an… CWE-200