CVE-2023-39349: Sentry Privilege Escalation Vulnerability

HIGH
Advisory Identifier: GHSA-9jcq-jf57-c62c
CVSS 8.1
CWE-284
Published
Advisory Summary

CVE-2023-39349 is a HIGH (CVSS 8.1) privilege escalation vulnerability (CWE-284: Improper Access Control) affecting Sentry libraries in the PyPI ecosystem. The issue involves privilege escalation via apitokensendpoint. Remediation is available by upgrading affected packages to version 23.7.2.

CVE-2023-39349 at a Glance

CVE Identifier CVE-2023-39349
GHSA Identifier GHSA-9jcq-jf57-c62c
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-284: Improper Access Control
Affected Product Sentry
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

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

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

How to Fix CVE-2023-39349

To remediate this vulnerability, upgrade all affected Sentry 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 fixed: 23.7.2
pip install sentry>=23.7.2
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

How to Check if You Are Affected

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

pip show sentry

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In Sentry, 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 An attacker with access to a token with few or no scopes can query `/api/0/api-tokens/` for a list of all tokens created by a user, including tokens with greater scopes, and use those tokens in other requests. There is no evidence that the issue was exploited on https://sentry.io. For self-hosted users, it is advised to rotate user auth tokens via `https://your-self-hosted-sentry-installation/settings/account/api/auth-tokens/`. ### Patches The issue was fixed in https://github.com/getsentry/sentry/pull/53850 and is available in the release 23.7.2 of [sentry](https://github.com/getsentry/sentry/releases/tag/23.7.2) and [self-hosted](https://github.com/getsentry/self-hosted/releases/tag/23.7.2). ### Workarounds There are no known workarounds.

CVE-2023-39349 Affected Sentry Versions

1 component(s)
Fixed Versions:
23.7.2
Product / Package Ecosystem Affected Versions Fixed Version
sentry
PyPI
≥ 22.1.0
< 23.7.2
23.7.2

References

Frequently Asked Questions

What is CVE-2023-39349?
CVE-2023-39349 is a security vulnerability in Sentry involving Privilege escalation via ApiTokensEndpoint under CWE-284: Improper Access Control.
Which Sentry versions are affected?
Affected versions include releases prior to 23.7.2 across affected packages: sentry.
What version fixes CVE-2023-39349?
Upgrading to 23.7.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is sentry affected?
Yes, sentry is affected in releases prior to 23.7.2. Upgrade your dependency to 23.7.2 or later.
What is the CVSS score of CVE-2023-39349?
CVE-2023-39349 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2023-39349?
CVE-2023-39349 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check PyPI dependencies for CVE-2023-39349?
Run the dependency tree command: 'pip show sentry'. 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-9jcq-jf57-c62c",
  "modified" : "2023-08-08T20:46:12Z",
  "published" : "2023-08-08T20:46:12Z",
  "aliases" : [ "CVE-2023-39349" ],
  "summary" : "Privilege escalation via ApiTokensEndpoint",
  "details" : "### Impact\nAn attacker with access to a token with few or no scopes can query `/api/0/api-tokens/` for a list of all tokens created by a user, including tokens with greater scopes, and use those tokens in other requests.\n\nThere is no evidence that the issue was exploited on https://sentry.io. For self-hosted users, it is advised to rotate user auth tokens via `https://your-self-hosted-sentry-installation/settings/account/api/auth-tokens/`.\n\n### Patches\nThe issue was fixed in https://github.com/getsentry/sentry/pull/53850 and is available in the release 23.7.2 of [sentry](https://github.com/getsentry/sentry/releases/tag/23.7.2) and [self-hosted](https://github.com/getsentry/self-hosted/releases/tag/23.7.2).\n\n### Workarounds\nThere are no known workarounds.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "sentry"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "22.1.0"
      }, {
        "fixed" : "23.7.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry/security/advisories/GHSA-9jcq-jf57-c62c"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-39349"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry/pull/53850"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry/commit/fad12c1150d1135edf9666ea72ca11bc110c1083"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/self-hosted/releases/tag/23.7.2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/getsentry/sentry"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/getsentry/sentry/releases/tag/23.7.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-284" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-08T20:46:12Z",
    "nvd_published_at" : "2023-08-07T19:15:11Z"
  }
}