{"id":"CVE-2024-40647","aliases":["GHSA-g92j-qhmh-64v2","PYSEC-2026-1917"],"url":"https://o3.security/vulnerability/CVE-2024-40647","summary":"Unintentional exposure of environment variables to subprocesses in sentry-sdk","details":"### Impact\n\nThe bug in Sentry's Python SDK <2.8.0 results in the unintentional exposure of environment variables to subprocesses despite the `env={}` setting.\n\n### Details\n\nIn 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:\n\n```\n>>> subprocess.check_output([\"env\"], env={\"TEST\":\"1\"})\nb'TEST=1\\n'\n```\n\nIf you'd want to not pass any variables, you can set an empty dict:\n\n```\n>>> subprocess.check_output([\"env\"], env={})\nb''\n```\n\nHowever, 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](https://docs.sentry.io/platforms/python/integrations/default-integrations/#stdlib) integration is disabled. The Stdlib integration is enabled by default.\n\n### Patches\nThe issue has been patched in https://github.com/getsentry/sentry-python/pull/3251 and the fix released in [sentry-sdk==2.8.0](https://github.com/getsentry/sentry-python/releases/tag/2.8.0). The fix was also backported to [sentry-sdk==1.45.1](https://github.com/getsentry/sentry-python/releases/tag/1.45.1).\n\n### Workarounds\n\nWe 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:\n\n1. In your application, replace `env={}` with the minimal dict `env={\"EMPTY_ENV\":\"1\"}` or similar.\n\nOR\n\n2. Disable Stdlib integration:\n```\nimport sentry_sdk\n\n# Should go before sentry_sdk.init\nsentry_sdk.integrations._DEFAULT_INTEGRATIONS.remove(\"sentry_sdk.integrations.stdlib.StdlibIntegration\")\n\nsentry_sdk.init(...)\n```\n\n### References\n* Sentry docs: [Default integrations](https://docs.sentry.io/platforms/python/integrations/default-integrations/)\n* Python docs: [subprocess module](https://docs.python.org/3/library/subprocess.html)\n* Patch https://github.com/getsentry/sentry-python/pull/3251","published":"2024-07-18T16:51:23.539Z","modified":"2026-08-12T03:51:29.032748183Z","cvss":{"score":5.3,"severity":"MEDIUM","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:N/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"PyPI","name":"sentry-sdk","fixedVersion":"2.8.0"},{"ecosystem":"PyPI","name":"sentry-sdk","fixedVersion":"1.45.1"}],"fix":{"url":"https://github.com/getsentry/sentry-python/commit/763e40aa4cb57ecced467f48f78f335c87e9bdff","label":"getsentry/sentry-python@763e40a"},"references":[{"type":"WEB","url":"https://docs.python.org/3/library/subprocess.html"},{"type":"WEB","url":"https://docs.sentry.io/platforms/python/integrations/default-integrations"},{"type":"WEB","url":"https://docs.sentry.io/platforms/python/integrations/default-integrations/#stdlib"},{"type":"WEB","url":"https://github.com/getsentry/sentry-python/releases/tag/2.8.0"},{"type":"WEB","url":"https://lists.debian.org/debian-lts-announce/2026/06/msg00001.html"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2024/40xxx/CVE-2024-40647.json"},{"type":"ADVISORY","url":"https://github.com/getsentry/sentry-python/security/advisories/GHSA-g92j-qhmh-64v2"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-40647"},{"type":"FIX","url":"https://github.com/getsentry/sentry-python/commit/763e40aa4cb57ecced467f48f78f335c87e9bdff"},{"type":"FIX","url":"https://github.com/getsentry/sentry-python/pull/3251"},{"type":"PACKAGE","url":"https://github.com/getsentry/sentry-python"},{"type":"WEB","url":"https://github.com/getsentry/sentry-python/releases/tag/1.45.1"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:29.032748183Z"}}