Description
joaquimserafim/json-web-token is a javascript library use to interact with JSON Web Tokens (JWT) which are a compact URL-safe means of representing claims to be transferred between two parties. Affected versions of the json-web-token library are vulnerable to a JWT algorithm confusion attack. On line 86 of the 'index.js' file, the algorithm to use for verifying the signature of the JWT token is taken from the JWT token, which at that point is still unverified and thus shouldn't be trusted. To exploit this vulnerability, an attacker needs to craft a malicious JWT token containing the HS256 algorithm, signed with the public RSA key of the victim application. This attack will only work against this library is the RS256 algorithm is in use, however it is a best practice to use that algorithm.
Remediation
References
https://github.com/joaquimserafim/json-web-token/security/advisories/GHSA-4xw9-cx39-r355
Related Vulnerabilities
CVE-2023-24456 Vulnerability in maven package org.jenkins-ci.plugins:keycloak
CVE-2018-18854 Vulnerability in maven package io.spray:spray-json_2.12
CVE-2022-25352 Vulnerability in npm package libnested
CVE-2017-16167 Vulnerability in npm package yyooopack
CVE-2023-43642 Vulnerability in maven package org.xerial.snappy:snappy-java