CVE-2023-28117: Sentry sdk Sentry SDK Leaks Sensitive Session Vulnerability

HIGH
Advisory Identifier: GHSA-29pr-6jr8-q5jm
CVSS 7.6
CWE-209 CWE-201
Published
Advisory Summary

CVE-2023-28117 is a HIGH (CVSS 7.6) sentry sdk leaks sensitive session vulnerability (CWE-209: Generation of Error Message Containing Sensitive Information) affecting Sentry sdk libraries in the PyPI ecosystem. The issue involves sentry sdk leaks sensitive session information when `senddefaultpii` is set to `true`. Remediation is available by upgrading affected packages to version 1.14.0.

CVE-2023-28117 at a Glance

CVE Identifier CVE-2023-28117
GHSA Identifier GHSA-29pr-6jr8-q5jm
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-209: Generation of Error Message Containing Sensitive Information
Affected Product Sentry sdk
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.6

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

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

How to Fix CVE-2023-28117

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.14.0
pip install sentry-sdk>=1.14.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-2023-28117, 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.14.0), 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-209: Generation of Error Message Containing Sensitive Information, where the product generates an error message that includes sensitive information about its environment, users, or associated data. 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 When using the [Django integration](https://docs.sentry.io/platforms/python/guides/django/) of the Sentry SDK in a specific configuration it is possible to leak sensitive cookies values, including the session cookie to Sentry. These sensitive cookies could then be used by someone with access to your Sentry issues to impersonate or escalate their privileges within your application. The below must be true in order for these sensitive values to be leaked: 1. Your Sentry SDK configuration has `sendDefaultPII` set to `True` 2. You are using a custom name for either of the cookies below in your Django settings. - [`SESSION_COOKIE_NAME`](https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-SESSION_COOKIE_NAME) or - [`CSRF_COOKIE_NAME`](https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_COOKIE_NAME) Django settings 3. You are not configured in your organization or project settings to use [our data scrubbing features](https://docs.sentry.io/product/data-management-settings/scrubbing/) to account for the custom cookie names ### Patches As of version `1.14.0`, the Django integration of the `sentry-sdk` will detect the custom cookie names based on your Django settings and will remove the values from the payload _before_ sending the data to Sentry. ### Workarounds If you can not update your `sentry-sdk` to a patched version than you can use the SDKs filtering mechanism to remove the cookies from the payload that is sent to Sentry. For error events this can be done with the [before_send](https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-) callback method and for performance related events (transactions) you can use the [before_send_transaction](https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction-) callback method. If you'd like to handle filtering of these values on the server-side, you can also use our [advanced data scrubbing feature](https://docs.sentry.io/product/data-management-settings/scrubbing/advanced-datascrubbing/) to account for the custom cookie names. Look for the `$http.cookies`, `$http.headers`, `$request.cookies`, or `$request.headers` fields to target with your scrubbing rule. ### References - [Using Your Tools Against You (Chapter8 Blog Post)](https://medium.com/@tomwolters/using-your-tools-against-you-cea4d2482ebb) - [Sentry Python SDK Filtering](https://docs.sentry.io/platforms/python/configuration/filtering/) - [Sentry Data Scrubbing](https://docs.sentry.io/product/data-management-settings/scrubbing/advanced-datascrubbing/) ### Credits - [Tom Wolters (Chapter8)](https://chapter8.com)

CVE-2023-28117 Affected Sentry sdk Versions

1 component(s)
Fixed Versions:
1.14.0
Product / Package Ecosystem Affected Versions Fixed Version
sentry-sdk
PyPI
< 1.14.0
1.14.0

References

Frequently Asked Questions

What is CVE-2023-28117?
CVE-2023-28117 is a security vulnerability in Sentry sdk involving Sentry SDK leaks sensitive session information when `sendDefaultPII` is set to `True` under CWE-209: Generation of Error Message Containing Sensitive Information.
Which Sentry sdk versions are affected?
Affected versions include releases prior to 1.14.0 across affected packages: sentry-sdk.
What version fixes CVE-2023-28117?
Upgrading to 1.14.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.14.0. Upgrade your dependency to 1.14.0 or later.
What is the CVSS score of CVE-2023-28117?
CVE-2023-28117 has a CVSS v3.1 base score of 7.6 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N.
What CWE is associated with CVE-2023-28117?
CVE-2023-28117 is classified under CWE-209: Generation of Error Message Containing Sensitive Information (The product generates an error message that includes sensitive information about its environment, users, or associated data.).
How can I check PyPI dependencies for CVE-2023-28117?
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-29pr-6jr8-q5jm",
  "modified" : "2023-03-22T21:49:38Z",
  "published" : "2023-03-21T22:31:19Z",
  "aliases" : [ "CVE-2023-28117" ],
  "summary" : "Sentry SDK leaks sensitive session information when `sendDefaultPII` is set to `True`",
  "details" : "### Impact\n\nWhen using the [Django integration](https://docs.sentry.io/platforms/python/guides/django/) of the Sentry SDK in a specific configuration it is possible to leak sensitive cookies values, including the session cookie to Sentry. These sensitive cookies could then be used by someone with access to your Sentry issues to impersonate or escalate their privileges within your application.\n\nThe below must be true in order for these sensitive values to be leaked:\n1. Your Sentry SDK configuration has `sendDefaultPII` set to `True`\n2. You are using a custom name for either of the cookies below in your Django settings.\n  - [`SESSION_COOKIE_NAME`](https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-SESSION_COOKIE_NAME) or \n  - [`CSRF_COOKIE_NAME`](https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_COOKIE_NAME) Django settings\n3. You are not configured in your organization or project settings to use [our data scrubbing features](https://docs.sentry.io/product/data-management-settings/scrubbing/) to account for the custom cookie names\n\n### Patches\nAs of version `1.14.0`, the Django integration of the `sentry-sdk` will detect the custom cookie names based on your Django settings and will remove the values from the payload _before_ sending the data to Sentry.\n\n### Workarounds\n\nIf you can not update your `sentry-sdk` to a patched version than you can use the SDKs filtering mechanism to remove the cookies from the payload that is sent to Sentry. For error events this can be done with the [before_send](https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-) callback method and for performance related events (transactions) you can use the [before_send_transaction](https://docs.sentry.io/platforms/python/configuration/filtering/#using-platformidentifier-namebefore-send-transaction-) callback method.\n\nIf you'd like to handle filtering of these values on the server-side, you can also use our [advanced data scrubbing feature](https://docs.sentry.io/product/data-management-settings/scrubbing/advanced-datascrubbing/) to account for the custom cookie names. Look for the `$http.cookies`, `$http.headers`, `$request.cookies`, or `$request.headers` fields to target with your scrubbing rule.\n\n### References\n- [Using Your Tools Against You (Chapter8 Blog Post)](https://medium.com/@tomwolters/using-your-tools-against-you-cea4d2482ebb)\n- [Sentry Python SDK Filtering](https://docs.sentry.io/platforms/python/configuration/filtering/)\n- [Sentry Data Scrubbing](https://docs.sentry.io/product/data-management-settings/scrubbing/advanced-datascrubbing/)\n\n### Credits\n- [Tom Wolters (Chapter8)](https://chapter8.com)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sentry-sdk"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.14.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/security/advisories/GHSA-29pr-6jr8-q5jm"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-28117"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/pull/1842"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/getsentry/sentry-python"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry-python/releases/tag/1.14.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-201", "CWE-209" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-03-21T22:31:19Z",
    "nvd_published_at" : "2023-03-22T20:15:00Z"
  }
}