CVE-2024-40647: Sentry sdk Sentry's Python SDK Unintentionally Exposes Vulnerability

LOW
Advisory Identifier: GHSA-g92j-qhmh-64v2
CVSS 2.5
CWE-200
Published
Advisory Summary

CVE-2024-40647 is a LOW (CVSS 2.5) sentry's python sdk unintentionally exposes vulnerability (CWE-200: Exposure of Sensitive Information to an Unauthorized Actor) affecting Sentry sdk libraries in the PyPI ecosystem. The issue involves sentry's python sdk unintentionally exposes environment variables to subprocesses. Remediation is available by upgrading affected packages to version 1.45.1, 2.8.0.

CVE-2024-40647 at a Glance

CVE Identifier CVE-2024-40647
GHSA Identifier GHSA-g92j-qhmh-64v2
Severity LOW
CVSS v3.1 Base Score 2.5
CWE Classification CWE-200: Exposure of Sensitive Information to an Unauthorized Actor
Affected Product Sentry sdk
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 2.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-40647

To remediate this vulnerability, upgrade all affected Sentry sdk dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

sentry-sdk fixed: 1.45.1
pip install sentry-sdk>=1.45.1
sentry-sdk fixed: 2.8.0
pip install sentry-sdk>=2.8.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show sentry-sdk

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-40647, inspect your installed packages using pip:

pip show sentry-sdk

Analyze the terminal output to locate any version of Sentry sdk in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.45.1), your application is affected.

Note: The pip show sentry-sdk command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. In Sentry sdk, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://docs.sentry.io/platforms/python/integrations/default-integrations/#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](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). ### 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](https://docs.sentry.io/platforms/python/integrations/default-integrations/) * Python docs: [subprocess module](https://docs.python.org/3/library/subprocess.html) * Patch https://github.com/getsentry/sentry-python/pull/3251

CVE-2024-40647 Affected Sentry sdk Versions

2 component(s)
Fixed Versions:
1.45.12.8.0
Product / Package Ecosystem Affected Versions Fixed Version
sentry-sdk
PyPI
< 1.45.1
1.45.1
sentry-sdk
PyPI
≥ 2.0.0a1
< 2.8.0
2.8.0

References

Frequently Asked Questions

What is CVE-2024-40647?
CVE-2024-40647 is a security vulnerability in Sentry sdk involving Sentry's Python SDK unintentionally exposes environment variables to subprocesses under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Which Sentry sdk versions are affected?
Affected versions include releases prior to 1.45.1, 2.8.0 across affected packages: sentry-sdk.
What version fixes CVE-2024-40647?
Upgrading to 1.45.1, 2.8.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sentry-sdk affected?
Yes, sentry-sdk is affected in releases prior to 1.45.1, 2.8.0. Upgrade your dependency to 1.45.1, 2.8.0 or later.
What is the CVSS score of CVE-2024-40647?
CVE-2024-40647 has a CVSS v3.1 base score of 2.5 (LOW) with vector string CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N.
What CWE is associated with CVE-2024-40647?
CVE-2024-40647 is classified under CWE-200: Exposure of Sensitive Information to an Unauthorized Actor (The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.).
How can I check PyPI dependencies for CVE-2024-40647?
Run the dependency tree command: 'pip show sentry-sdk'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g92j-qhmh-64v2",
  "modified" : "2026-06-01T09:31:10Z",
  "published" : "2024-07-18T17:18:46Z",
  "aliases" : [ "CVE-2024-40647" ],
  "summary" : "Sentry's Python SDK unintentionally exposes environment variables to subprocesses",
  "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",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:H/UI:N/VC:N/VI:N/VA:N/SC:L/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sentry-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0a1"
      }, {
        "fixed" : "2.8.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sentry-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.45.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "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" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/pull/3251"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/commit/763e40aa4cb57ecced467f48f78f335c87e9bdff"
  }, {
    "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" : "PACKAGE",
    "url" : "https://github.com/getsentry/sentry-python"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/releases/tag/1.45.1"
  }, {
    "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-18T17:18:46Z",
    "nvd_published_at" : "2024-07-18T17:15:05Z"
  }
}