CVE-2021-46743: Firebase/php jwt Firebase PHP-JWT Key/algorithm Type Confusion Vulnerability

CRITICAL
Advisory Identifier: GHSA-8xf4-w7qw-pjjw
CVSS 9.1
CWE-843 CWE-347
Published
Advisory Summary

CVE-2021-46743 is a CRITICAL (CVSS 9.1) firebase php-jwt key/algorithm type confusion vulnerability (CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')) affecting Firebase/php jwt libraries in the Packagist ecosystem. The issue involves firebase php-jwt key/algorithm type confusion. Remediation is available by upgrading affected packages to version 6.0.0.

CVE-2021-46743 at a Glance

CVE Identifier CVE-2021-46743
GHSA Identifier GHSA-8xf4-w7qw-pjjw
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')
Affected Product Firebase/php jwt
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 9.1

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
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-2021-46743

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

firebase/php-jwt fixed: 6.0.0
Upgrade firebase/php-jwt to 6.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:

inspect dependencies for firebase/php-jwt

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-46743, inspect your project dependencies for Firebase/php jwt:

inspect dependencies for firebase/php-jwt

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

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion'), where the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. In Firebase/php jwt, 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

In Firebase PHP-JWT before 6.0.0, an algorithm-confusion issue (e.g., RS256 / HS256) exists via the kid (aka Key ID) header, when multiple types of keys are loaded in a key ring. This allows an attacker to forge tokens that validate under the incorrect key. NOTE: this provides a straightforward way to use the PHP-JWT library unsafely, but might not be considered a vulnerability in the library itself.

CVE-2021-46743 Affected Firebase/php jwt Versions

1 component(s)
Fixed Versions:
6.0.0
Product / Package Ecosystem Affected Versions Fixed Version
firebase/php-jwt
Packagist
< 6.0.0
6.0.0

References

Frequently Asked Questions

What is CVE-2021-46743?
CVE-2021-46743 is a security vulnerability in Firebase/php jwt involving Firebase PHP-JWT key/algorithm type confusion under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion').
Which Firebase/php jwt versions are affected?
Affected versions include releases prior to 6.0.0 across affected packages: firebase/php-jwt.
What version fixes CVE-2021-46743?
Upgrading to 6.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is firebase/php-jwt affected?
Yes, firebase/php-jwt is affected in releases prior to 6.0.0. Upgrade your dependency to 6.0.0 or later.
What is the CVSS score of CVE-2021-46743?
CVE-2021-46743 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-46743?
CVE-2021-46743 is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion') (The product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.).
How can I check Packagist dependencies for CVE-2021-46743?
Run the dependency tree command: 'inspect dependencies for firebase/php-jwt'. 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-8xf4-w7qw-pjjw",
  "modified" : "2023-02-17T14:26:38Z",
  "published" : "2022-03-30T00:00:27Z",
  "aliases" : [ "CVE-2021-46743" ],
  "summary" : "Firebase PHP-JWT key/algorithm type confusion",
  "details" : "In Firebase PHP-JWT before 6.0.0, an algorithm-confusion issue (e.g., RS256 / HS256) exists via the kid (aka Key ID) header, when multiple types of keys are loaded in a key ring. This allows an attacker to forge tokens that validate under the incorrect key. NOTE: this provides a straightforward way to use the PHP-JWT library unsafely, but might not be considered a vulnerability in the library itself.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "firebase/php-jwt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-46743"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/firebase/php-jwt/issues/351"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/firebase/php-jwt/CVE-2021-46743.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/firebase/php-jwt"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/firebase/php-jwt/releases/tag/v6.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-347", "CWE-843" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-02-17T14:26:38Z",
    "nvd_published_at" : "2022-03-29T07:15:00Z"
  }
}