GitHub Advisoryadvisory · PyPI
GHSA-g92j-qhmh-64v2 Sentry's Python SDK unintentionally exposes environment variables to subprocesses
LOW
Official page ↗
- Aliases
- CVE-2024-40647
- Ecosystem
- PyPI
- Packages
- sentry-sdk
- Severity
- Low
- CVSS vector
- CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N
- Weaknesses
- CWE-200
- Reviewed
- 2024-07-18
Affected packages
• PyPI sentry-sdk: >= 2.0.0a1, < 2.8.0 → fixed in 2.8.0
• PyPI sentry-sdk: < 1.45.1 → fixed in 1.45.1
Description
Impact
The bug in Sentry's Python SDK >> subprocess.check_output(["env"], env={"TEST":"1"})
b'TEST=1\n'
```
If you'd want to not pass any variables, you can set an empty dict:
```
>>> subprocess.check_output(["env"], env={})
b''
```
However, the bug in Sentry SDK <2.8.0 causes all environment variables to be passed to the subprocesses when `env={}` is set, unless the Sentry SDK's Stdlib integration is disabled. The Stdlib integration is enabled by default.
Patches
The issue has been patched in https://github.com/getsentry/sentry-python/pull/3251 and the fix released in sentry-sdk==2.8.0. The fix was also backported to sentry-sdk==1.45.1.
Workarounds
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, there are two options:
1. In your application, replace `env={}` with the minimal dict `env={"EMPTY_ENV":"1"}` or similar.
OR
2. Disable Stdlib integration:
```
import sentry_sdk
Should go before sentry_sdk.init
sentry_sdk.integrations._DEFAULT_INTEGRATIONS.remove("sentry_sdk.integrations.stdlib.StdlibIntegration")
sentry_sdk.init(...)
```
References
• Sentry docs: Default integrations
• Python docs: subprocess module
• Patch https://github.com/getsentry/sentry-python/pull/3251
Related
Alias · CVE (1)
- CVE-2024-40647 sentry-sdk is the official Python SDK for Sentry.io. vulnerability
Weakness · CWE (1)
- CWE-200 Exposure of Sensitive Information to an Unauthorized Actor weakness
References
- https://github.com/getsentry/sentry-python/security/advisories/GHSA-g92j-qhmh-64v2 web
- https://nvd.nist.gov/vuln/detail/CVE-2024-40647 advisory
- https://github.com/getsentry/sentry-python/pull/3251 web
- https://github.com/getsentry/sentry-python/commit/763e40aa4cb57ecced467f48f78f335c87e9bdff web
- https://docs.python.org/3/library/subprocess.html web
- https://docs.sentry.io/platforms/python/integrations/default-integrations web
- https://docs.sentry.io/platforms/python/integrations/default-integrations/#stdlib web
- https://github.com/getsentry/sentry-python package
- https://github.com/getsentry/sentry-python/releases/tag/1.45.1 web
- https://github.com/getsentry/sentry-python/releases/tag/2.8.0 web
- https://lists.debian.org/debian-lts-announce/2026/06/msg00001.html web