Skip to content

Commit 593a1ae

Browse files
1 parent 2a12e1d commit 593a1ae

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-g92j-qhmh-64v2",
4+
"modified": "2024-07-18T17:18:46Z",
5+
"published": "2024-07-18T17:18:46Z",
6+
"aliases": [
7+
"CVE-2024-40647"
8+
],
9+
"summary": "Sentry's Python SDK unintentionally exposes environment variables to subprocesses",
10+
"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).\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 \n",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:L/I:N/A:N"
15+
},
16+
{
17+
"type": "CVSS_V4",
18+
"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"
19+
}
20+
],
21+
"affected": [
22+
{
23+
"package": {
24+
"ecosystem": "PyPI",
25+
"name": "sentry-sdk"
26+
},
27+
"ranges": [
28+
{
29+
"type": "ECOSYSTEM",
30+
"events": [
31+
{
32+
"introduced": "0"
33+
},
34+
{
35+
"fixed": "2.8.0"
36+
}
37+
]
38+
}
39+
]
40+
}
41+
],
42+
"references": [
43+
{
44+
"type": "WEB",
45+
"url": "https://github.com/getsentry/sentry-python/security/advisories/GHSA-g92j-qhmh-64v2"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/getsentry/sentry-python/pull/3251"
50+
},
51+
{
52+
"type": "WEB",
53+
"url": "https://github.com/getsentry/sentry-python/commit/763e40aa4cb57ecced467f48f78f335c87e9bdff"
54+
},
55+
{
56+
"type": "WEB",
57+
"url": "https://docs.python.org/3/library/subprocess.html"
58+
},
59+
{
60+
"type": "WEB",
61+
"url": "https://docs.sentry.io/platforms/python/integrations/default-integrations"
62+
},
63+
{
64+
"type": "WEB",
65+
"url": "https://docs.sentry.io/platforms/python/integrations/default-integrations/#stdlib"
66+
},
67+
{
68+
"type": "PACKAGE",
69+
"url": "https://github.com/getsentry/sentry-python"
70+
},
71+
{
72+
"type": "WEB",
73+
"url": "https://github.com/getsentry/sentry-python/releases/tag/2.8.0"
74+
}
75+
],
76+
"database_specific": {
77+
"cwe_ids": [
78+
"CWE-200"
79+
],
80+
"severity": "LOW",
81+
"github_reviewed": true,
82+
"github_reviewed_at": "2024-07-18T17:18:46Z",
83+
"nvd_published_at": null
84+
}
85+
}

0 commit comments

Comments
 (0)