CVE-2022-3102: Jwcrypto Authentication Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-gwp4-mcv4-w95j
Published
Advisory Summary

CVE-2022-3102 is a MODERATE authentication bypass vulnerability (General Security Weakness) affecting Jwcrypto libraries in the PyPI ecosystem. The issue involves jwcrypto token substitution can lead to authentication bypass. Remediation is available by upgrading affected packages to version 1.4.

CVE-2022-3102 at a Glance

CVE Identifier CVE-2022-3102
GHSA Identifier GHSA-gwp4-mcv4-w95j
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Jwcrypto
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2022-3102

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

jwcrypto fixed: 1.4
pip install jwcrypto>=1.4
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 jwcrypto

How to Check if You Are Affected

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

pip show jwcrypto

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Jwcrypto, 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

The JWT code can auto-detect the type of token being provided, and this can lead the application to incorrect conclusions about the trustworthiness of the token. Quoting the private disclosure we received : "Under certain circumstances, it is possible to substitute a [..] signed JWS with a JWE that is encrypted with the public key that is normally used for signature validation." This substitution attack can occur only if the validating application also have access to the private key, normally used to sign the tokens, available during validation of the received JWT. The significance of this attacks depends on the use of the token, it may lead to authentication bypass or authorization bypass (respectively if claims are used to authenticate or authorize certain actions), because the attacker has full control of the data placed in the JWE and can inject any desired claim value. Several mitigating factors exist that can protect applications from this issue: - If the private key corresponding to the public key used to encrypt the JWE is not available to the application an exception will be raised. - If the JWK is specified with the 'use' parameter set to 'sig' (as expected for keys used only for signing/verification) an exception will be raised. - If the JWK is specified with the 'key_ops' parameter set and it does not include the 'decrypt' operation an exception will be raised. - Applications may check the token type before validation, in this case they would fail to detect an expected JWS Normally, signing and validation are done by different applications, so this scenario should be unlikely. However it is possible to have applications that both sign and validate tokens and do not separate JWKs in use, or do not set a JWK 'use' type. Due to the mitigating factors, and the fact that specific operational constraints and conditions need to be in place to successfully exploit this issue to generate an authentication bypass, we rate this security issue as moderate. Other avenues may decide on a different rating based on use case, always verify what conditions apply to your use of the library to assess risk. Many thanks to Tom Tervoort of Secura for finding and reporting this issue.

CVE-2022-3102 Affected Jwcrypto Versions

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

References

Frequently Asked Questions

What is CVE-2022-3102?
CVE-2022-3102 is a security vulnerability in Jwcrypto involving jwcrypto token substitution can lead to authentication bypass under General Security Weakness.
Which Jwcrypto versions are affected?
Affected versions include releases prior to 1.4 across affected packages: jwcrypto.
What version fixes CVE-2022-3102?
Upgrading to 1.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is jwcrypto affected?
Yes, jwcrypto is affected in releases prior to 1.4. Upgrade your dependency to 1.4 or later.
What CWE is associated with CVE-2022-3102?
CVE-2022-3102 is classified under General Security Weakness.
How can I check PyPI dependencies for CVE-2022-3102?
Run the dependency tree command: 'pip show jwcrypto'. 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-gwp4-mcv4-w95j",
  "modified" : "2022-09-21T16:58:31Z",
  "published" : "2022-09-21T16:58:31Z",
  "aliases" : [ "CVE-2022-3102" ],
  "summary" : "jwcrypto token substitution can lead to authentication bypass",
  "details" : "The JWT code can auto-detect the type of token being provided, and this can lead the application to incorrect conclusions about the trustworthiness of the token.\nQuoting the private disclosure we received : \"Under certain circumstances, it is possible to substitute a [..] signed JWS with a JWE that is encrypted with the public key that is normally used for signature validation.\"\nThis substitution attack can occur only if the validating application also have access to the private key, normally used to sign the tokens, available during validation of the received JWT.\nThe significance of this attacks depends on the use of the token, it may lead to authentication bypass or authorization bypass (respectively if claims are used to authenticate or authorize certain actions), because the attacker has full control of the data placed in the JWE and can inject any desired claim value.\n\nSeveral mitigating factors exist that can protect applications from this issue:\n- If the private key corresponding to the public key used to encrypt the JWE is not available to the application an exception will be raised.\n- If the JWK is specified with the 'use' parameter set to 'sig' (as expected for keys used only for signing/verification) an exception will be raised.\n- If the JWK is specified with the 'key_ops' parameter set and it does not include the 'decrypt' operation an exception will be raised.\n- Applications may check the token type before validation, in this case they would fail to detect an expected JWS\n\nNormally, signing and validation are done by different applications, so this scenario should be unlikely. However it is possible to have applications that both sign and validate tokens and do not separate JWKs in use, or do not set a JWK 'use' type.\n\nDue to the mitigating factors, and the fact that specific operational constraints and conditions need to be in place to successfully exploit this issue to generate an authentication bypass, we rate this security issue as moderate. Other avenues may decide on a different rating based on use case, always verify what conditions apply to your use of the library to assess risk.\n\nMany thanks to Tom Tervoort of Secura for finding and reporting this issue.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "jwcrypto"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/latchset/jwcrypto/security/advisories/GHSA-gwp4-mcv4-w95j"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/latchset/jwcrypto/commit/f4e912f83cb578e2cd47f8a9398bf15f680bf558"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/latchset/jwcrypto"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/latchset/jwcrypto/releases/tag/v1.4.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-09-21T16:58:31Z",
    "nvd_published_at" : null
  }
}