{"id":"CVE-2021-41106","aliases":["CVE-2021-41106","GHSA-7322-jrq4-x5hf"],"related":[],"kind":"vulnerability","state":"published","title":"File reference keys leads to incorrect hashes on HMAC algorithms","summary":"JWT is a library to work with JSON Web Token and JSON Web Signature. Prior to versions 3.4.6, 4.0.4, and 4.1.5, users of HMAC-based algorithms (HS256, HS384, and HS512) combined with `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` as key are having their tokens issued/validated using the file path as hashing key - instead of the contents. The HMAC hashing functions take any string as input and, since users can issue and validate tokens, users are lead to believe that everything works properly. Versions 3.4.6, 4.0.4, and 4.1.5 have been patched to always load the file contents, deprecated the `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference`, and suggest `Lcobucci\\JWT\\Signer\\Key\\InMemory` as the alternative. As a workaround, use `Lcobucci\\JWT\\Signer\\Key\\InMemory` instead of `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` to create the instances of one's keys.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"JWT is a library to work with JSON Web Token and JSON Web Signature. Prior to versions 3.4.6, 4.0.4, and 4.1.5, users of HMAC-based algorithms (HS256, HS384, and HS512) combined with `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` as key are having their tokens issued/validated using the file path as hashing key - instead of the contents. The HMAC hashing functions take any string as input and, since users can issue and validate tokens, users are lead to believe that everything works properly. Versions 3.4.6, 4.0.4, and 4.1.5 have been patched to always load the file contents, deprecated the `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference`, and suggest `Lcobucci\\JWT\\Signer\\Key\\InMemory` as the alternative. As a workaround, use `Lcobucci\\JWT\\Signer\\Key\\InMemory` instead of `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` to create the instances of one's keys.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nUsers of HMAC-based algorithms (HS256, HS384, and HS512) combined with `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` as key are having their tokens issued/validated using the file path as hashing key - instead of the contents.\n\nThe HMAC hashing functions take any string as input and, since users can issue and validate tokens, people are lead to believe that everything works properly.\n\n### Patches\n\nAll versions have been patched to always load the file contents, deprecated the `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference`, and suggest `Lcobucci\\JWT\\Signer\\Key\\InMemory` as the alternative.\n\n### Workarounds\n\nUse `Lcobucci\\JWT\\Signer\\Key\\InMemory` instead of `Lcobucci\\JWT\\Signer\\Key\\LocalFileReference` to create the instances of your keys:\n\n```diff\n-use Lcobucci\\JWT\\Signer\\Key\\LocalFileReference;\n+use Lcobucci\\JWT\\Signer\\Key\\InMemory;\n\n-$key = LocalFileReference::file(__DIR__ . '/public-key.pem');\n+$key = InMemory::file(__DIR__ . '/public-key.pem');\n```","format":"markdown","source":"ghsa"},{"lang":"es","text":"JWT es una biblioteca para trabajar con JSON Web Token y JSON Web Signature. Antes de las versiones 3.4.6, 4.0.4 y 4.1.5, los usuarios de los algoritmos basados en HMAC (HS256, HS384 y HS512) combinados con \"Lcobucci\\JWT\\Signer\\Key\\LocalFileReference\" como clave están emitiendo/validando sus tokens usando la ruta del archivo como clave de hashing - en lugar del contenido. Las funciones de hashing HMAC aceptan cualquier cadena como entrada y, dado que los usuarios pueden emitir y comprobar tokens, los usuarios son llevados a creer que todo funciona correctamente. Las versiones 3.4.6, 4.0.4 y 4.1.5 han sido parcheadas para cargar siempre el contenido del archivo, desaprobando la función \"Lcobucci\\JWT\\Signer\\Key\\LocalFileReference\", y sugiriendo \"Lcobucci\\JWT\\Signer\\Key\\InMemory\" como alternativa. Como solución, use \"Lcobucci\\JWT\\SignerKey\\InMemory\" en lugar de \"Lcobucci\\JWT\\SignerKey\\LocalFileReference\" para crear las instancias de las claves propias","source":"nvd"}],"published":"2021-09-28T20:50:11.000Z","modified":"2026-07-08T06:27:26.757Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:N","score":4.4,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N","score":3.3,"rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:L/AC:L/Au:N/C:N/I:P/A:N","score":2.1,"rating":"LOW"}],"cwes":["CWE-345"],"affected":[{"ranges":[{"version":">= 3.4.0, < 3.4.6","status":"affected"},{"version":">= 4.0.0, < 4.0.4","status":"affected"},{"version":">= 4.1.0, < 4.1.5","status":"affected"}],"vendor":"lcobucci","product":"jwt","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.4.0","status":"affected","fixed":"3.4.6"}],"ecosystem":"Packagist","package":"lcobucci/jwt","purl":"pkg:composer/lcobucci/jwt","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"4.0.0","status":"affected","fixed":"4.0.4"}],"ecosystem":"Packagist","package":"lcobucci/jwt","purl":"pkg:composer/lcobucci/jwt","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"4.1.0","status":"affected","fixed":"4.1.5"}],"ecosystem":"Packagist","package":"lcobucci/jwt","purl":"pkg:composer/lcobucci/jwt","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"3.4.0","fixed":"3.4.6"},{"status":"affected","introduced":"4.0.0","fixed":"4.0.4"},{"status":"affected","introduced":"4.1.0","fixed":"4.1.5"}],"vendor":"lcobucci","product":"jwt","cpe":"cpe:2.3:a:lcobucci:jwt:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/lcobucci/jwt/security/advisories/GHSA-7322-jrq4-x5hf","tags":["patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/lcobucci/jwt/commit/8175de5b841fbe3fd97d2d49b3fc15c4ecb39a73","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/lcobucci/jwt/commit/c45bb8b961a8e742d8f6b88ef5ff1bd5cca5d01c","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41106","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/FriendsOfPHP/security-advisories/blob/master/lcobucci/jwt/CVE-2021-41106.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/lcobucci/jwt","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-41106","url":"https://www.cve.org/CVERecord?id=CVE-2021-41106","licence":"CVE Terms of Use","modified":"2024-08-04T02:59:31.511Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-7322-jrq4-x5hf","url":"https://github.com/advisories/GHSA-7322-jrq4-x5hf","licence":"CC-BY-4.0","modified":"2026-07-08T06:27:26.757Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-41106","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-41106","licence":"Public domain","modified":"2026-06-17T04:07:53.187Z"}],"updatedAt":"2026-11-25T22:58:04.204Z","epss":{"score":0.00205,"percentile":0.11131,"date":"2026-12-01T12:00:22.000Z"}}