CVE-2022-31027: Oauthenticator Authorization Bypass Through User-Controlled Key Vulnerability

MODERATE
Advisory Identifier: GHSA-r7v4-jwx9-wx43
CVSS 4.2
CWE-639
Published
Advisory Summary

CVE-2022-31027 is a MODERATE (CVSS 4.2) authorization bypass through user-controlled key vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Oauthenticator libraries in the PyPI ecosystem. The issue involves authorization bypass through user-controlled key when using cilogonoauthenticator oauthenticator. Remediation is available by upgrading affected packages to version 15.0.0.

CVE-2022-31027 at a Glance

CVE Identifier CVE-2022-31027
GHSA Identifier GHSA-r7v4-jwx9-wx43
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-639: Authorization Bypass Through User-Controlled Key
Affected Product Oauthenticator
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.2

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

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

How to Fix CVE-2022-31027

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

oauthenticator fixed: 15.0.0
pip install oauthenticator>=15.0.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 oauthenticator

How to Check if You Are Affected

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

pip show oauthenticator

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Oauthenticator, 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

# Background CILogon is a federated auth provider that allows users to authenticate themselves via a number of Identity Providers (IdP), focused primarily on educational and research institutions (such as Universities). More traditional and open IdPs such as GitHub, ORCID, Google, Microsoft, etc are also supported. CILogonOAuthenticator is provided by the OAuthenticator package, and lets users log in to a JupyterHub via CILogon. This is primarily used to restrict a JupyterHub only to users of a given institute. The allowed_idps configuration trait of CILogonOAuthenticator is documented to be a list of domains that indicate the institutions whose users are authorized to access this JupyterHub. This authorization is validated by ensuring that the *email* field provided to us by CILogon has a *domain* that matches one of the domains listed in `allowed_idps`. # Impact If `allowed_idps` contains `berkeley.edu`, you might expect only users with valid current credentials provided by University of California, Berkeley to be able to access the JupyterHub. However, CILogonOAuthenticator does *not* verify which provider is used by the user to login, only the email address provided. So a user can login with a GitHub account that has email set to `<something>@berkeley.edu`, and that will be treated exactly the same as someone logging in using the UC Berkeley official Identity Provider. This has two consequences: 1. Since GitHub (and most other providers we tested) only require you to verify your email once, a user can access a JupyterHub even if their access to the institution's IdP has been revoked or expired. 2. CILogon supports hundreds of identity providers - if even one of them allows users to set any email ids without verifying, that can be used to impersonate *any* user on any other identity provider! While CILogon itself has a stellar security record, this particular method of doing authorization means an attacker would only need to compromise a single identity provider to compromise all of CILogon We currently do not know of any identity provider that provides *unverified* email addresses to CILogon, so this is not a severe known vulnerability. However, there are hundreds of IdPs, and we could not try them all. # Patches This patch makes a *breaking change* in how `allowed_idps` is interpreted. It's no longer a list of domains, but configuration representing the `EntityID` of the IdPs that are allowed, picked from the [list maintained by CILogon](https://cilogon.org/idplist/). So instead of `berkeley.edu`, you would specify `urn:mace:incommon:berkeley.edu` to allow logins from users currently with `berkeley.edu` accounts. GitHub users with a verified `berkeley.edu` email will no longer be allowed to log in. For details on how to transition your CILogonOAuthenticator configuration to the patched version 15.0.0 or above, see [the migration](https://oauthenticator.readthedocs.io/en/latest/migrations.html) documentation.

CVE-2022-31027 Affected Oauthenticator Versions

1 component(s)
Fixed Versions:
15.0.0
Product / Package Ecosystem Affected Versions Fixed Version
oauthenticator
PyPI
< 15.0.0
15.0.0

References

Frequently Asked Questions

What is CVE-2022-31027?
CVE-2022-31027 is a security vulnerability in Oauthenticator involving Authorization Bypass Through User-Controlled Key when using CILogonOAuthenticator oauthenticator under CWE-639: Authorization Bypass Through User-Controlled Key.
Which Oauthenticator versions are affected?
Affected versions include releases prior to 15.0.0 across affected packages: oauthenticator.
What version fixes CVE-2022-31027?
Upgrading to 15.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is oauthenticator affected?
Yes, oauthenticator is affected in releases prior to 15.0.0. Upgrade your dependency to 15.0.0 or later.
What is the CVSS score of CVE-2022-31027?
CVE-2022-31027 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2022-31027?
CVE-2022-31027 is classified under CWE-639: Authorization Bypass Through User-Controlled Key (The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.).
How can I check PyPI dependencies for CVE-2022-31027?
Run the dependency tree command: 'pip show oauthenticator'. 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-r7v4-jwx9-wx43",
  "modified" : "2022-06-06T21:21:40Z",
  "published" : "2022-06-06T21:21:40Z",
  "aliases" : [ "CVE-2022-31027" ],
  "summary" : "Authorization Bypass Through User-Controlled Key when using CILogonOAuthenticator oauthenticator",
  "details" : "# Background\n\nCILogon is a federated auth provider that allows users to authenticate\nthemselves via a number of Identity Providers (IdP), focused primarily on educational and\nresearch institutions (such as Universities). More traditional and open IdPs\nsuch as GitHub, ORCID, Google, Microsoft, etc are also supported.\n\nCILogonOAuthenticator is provided by the OAuthenticator package, and lets users log\nin to a JupyterHub via CILogon. This is primarily used to restrict a JupyterHub\nonly to users of a given institute. The allowed_idps configuration trait of\nCILogonOAuthenticator is documented to be a list of domains that indicate the\ninstitutions whose users are authorized to access this JupyterHub. This authorization\nis validated by ensuring that the *email* field provided to us by CILogon has a\n*domain* that matches one of the domains listed in `allowed_idps`.\n\n# Impact\n\nIf `allowed_idps` contains `berkeley.edu`, you might expect only users with valid\ncurrent credentials provided by University of California, Berkeley to be able to\naccess the JupyterHub. However, CILogonOAuthenticator does *not* verify which provider\nis used by the user to login, only the email address provided. So a user can login\nwith a GitHub account that has email set to `<something>@berkeley.edu`, and that will\nbe treated exactly the same as someone logging in using the UC Berkeley official\nIdentity Provider. This has two consequences:\n\n1. Since GitHub (and most other providers we tested) only require you to verify\n   your email once, a user can access a JupyterHub even if their access to\n   the institution's IdP has been revoked or expired.\n2. CILogon supports hundreds of identity providers - if even one of them allows\n   users to set any email ids without verifying, that can be used to impersonate\n   *any* user on any other identity provider! While CILogon itself has a stellar\n   security record, this particular method of doing authorization means an attacker\n   would only need to compromise a single identity provider to compromise all of\n   CILogon\n\nWe currently do not know of any identity provider that provides *unverified*\nemail addresses to CILogon, so this is not a severe known vulnerability. However,\nthere are hundreds of IdPs, and we could not try them all.\n\n# Patches\n\nThis patch makes a *breaking change* in how `allowed_idps` is interpreted. It's\nno longer a list of domains, but configuration representing the `EntityID` of the\nIdPs that are allowed, picked from the [list maintained by CILogon](https://cilogon.org/idplist/).\nSo instead of `berkeley.edu`, you would specify `urn:mace:incommon:berkeley.edu` to\nallow logins from users currently with `berkeley.edu` accounts. GitHub users\nwith a verified `berkeley.edu` email will no longer be allowed to log in.\n\nFor details on how to transition your CILogonOAuthenticator configuration to the patched version 15.0.0 or above, see [the migration](https://oauthenticator.readthedocs.io/en/latest/migrations.html) documentation.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "oauthenticator"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "15.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/jupyterhub/oauthenticator/security/advisories/GHSA-r7v4-jwx9-wx43"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31027"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jupyterhub/oauthenticator/commit/5cd2d1816f90dc5c946e6e38fd2d0ba535624c5c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jupyterhub/oauthenticator"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/oauthenticator/PYSEC-2022-206.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-639" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-06T21:21:40Z",
    "nvd_published_at" : "2022-06-09T13:15:00Z"
  }
}