Low

Sentry's Python SDK unintentionally exposes environment variables to subprocesses

  • Disclosed: 18.07.2024
  • Updated: 11.10.2026 13:19

Impact

The bug in Sentry's Python SDK <2.8.0 results in the unintentional exposure of environment variables to subprocesses despite the env={} setting.

Details

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, like in this example:

>>> 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

  1. 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

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) sentry-sdk >= 2.0.0a1, < 2.8.0, < 1.45.1 2.8.0, 1.45.1

References

CVSS score 2.5/10
CVSS vector
CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N
Weakness (CWE)
CWE-200
Platform
Python (PyPI)
Package
sentry-sdk
Disclosed
18.07.2024
Updated
11.10.2026 13:19

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-1917 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-g92j-qhmh-64v2 - CC BY 4.0

Vulnerability history: sentry-sdk

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
2
First → latest
03.2023 07.2024
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 1
  • Low 1

Disclosures per year

  1. 2023: 1
  2. 2024: 1
  3. 2025: 0
  4. 2026: 0
  1. Sentry's Python SDK unintentionally exposes environment variables to subprocesses this entry
    Low · 2.5 CVE-2024-40647 >= 2.0.0a1, < 2.8.0, < 1.45.1 2.8.0, 1.45.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.