Advisory

GHSA-g92j-qhmh-64v2

Also known as: CVE-2024-40647, PYSEC-2026-1917

Summary

Sentry's Python SDK unintentionally exposes environment variables to subprocesses

Details

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

Severity

Low Basis: The source's own band: LOW

Dates

Published
2024-07-18 17:18 UTC
Modified
2026-07-07 17:56 UTC

Affected packages and fixes

sentry-sdk

PyPI · All systems

Affected

  • introduced 2.0.0a1, fixed 2.8.0 (ecosystem)

Fixed versions

2.8.0

Fix

  • Fixed version 2.8.0
    pip install --upgrade sentry-sdk==2.8.0

sentry-sdk

PyPI · All systems

Affected

  • introduced 0, fixed 1.45.1 (ecosystem)

Fixed versions

1.45.1

Fix

  • Fixed version 1.45.1
    pip install --upgrade sentry-sdk==1.45.1

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences