{"answers":{"affected":"6 open source packages ship an affected version, including fastify-bearer-auth and @fastify/bearer-auth. It affects 1 product.","exploited":"There is no known exploitation of CVE-2022-31142 in the wild and no public exploit code.","fix":"Upgrade to a fixed version.","what":"CVE-2022-31142 is a high-severity vulnerability in fastify-bearer-auth, published on 14 Jul 2022. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for CVE-2022-31142 and fix it if it is affected.\n\nWhat it is: CVE-2022-31142 is a high-severity vulnerability in fastify-bearer-auth, published on 14 Jul 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of CVE-2022-31142 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- fastify-bearer-auth (npm): affected from 5.0.1 up to 6.0.3; no fix listed\n- fastify-bearer-auth (npm): affected from 5.0.1 up to 6.0.3; no fix listed\n- @fastify/bearer-auth (npm): affected all versions; fixed in 7.0.2\n- @fastify/bearer-auth (npm): affected all versions; fixed in 7.0.2\n- @fastify/bearer-auth (npm): affected from 8.0.0; fixed in 8.0.1\n- @fastify/bearer-auth (npm): affected from 8.0.0; fixed in 8.0.1\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2022-31142/ (Markdown: https://insights.sbomify.com/CVE-2022-31142/index.md)","id":"CVE-2022-31142","markdown":"https://insights.sbomify.com/CVE-2022-31142/index.md","name":"CVE-2022-31142","record":{"aliases":["GHSA-376v-xgjx-7mfr"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["data_read","security_bypass"],"network_reachable":"yes","non_default_config":false,"product_category":"Fastify bearer auth plugin","requires_auth":"none","summary":"A timing attack in the Fastify bearer auth plugin allows attackers to estimate valid token lengths, facilitating brute-force attacks against authentication.","user_interaction":"not_required","vuln_class":"information_disclosure"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"bearer-auth","vendor":"fastify"}],"cvss":{"score":7.5,"severity":"high","source":"cna","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N","version":"3.1"},"cwes":[{"id":"CWE-203","name":"Observable Discrepancy"},{"id":"CWE-208","name":"Observable Timing Discrepancy"}],"description":"@fastify/bearer-auth is a Fastify plugin to require bearer Authorization headers. @fastify/bearer-auth prior to versions 7.0.2 and 8.0.1 does not securely use crypto.timingSafeEqual. A malicious attacker could estimate the length of one valid bearer token. According to the corresponding RFC 6750, the bearer token has only base64 valid characters, reducing the range of characters for a brute force attack. Version 7.0.2 and 8.0.1 of @fastify/bearer-auth contain a patch. There are currently no known workarounds. The package fastify-bearer-auth, which covers versions 6.0.3 and prior, is also vulnerable starting at version 5.0.1. Users of fastify-bearer-auth should upgrade to a patched version of @fastify/bearer-auth.","ecosystems":["npm"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"none_known"},"has_fix":true,"headline":"Potential Timing Attack Vector in @fastify/bearer-auth","id":"CVE-2022-31142","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"npm","product":null,"products":[],"type":"information_disclosure","year":"2022"},"n_packages":6,"n_references":5,"next":{"headline":"Leak of sensitive information through login page error in GLPI","id":"CVE-2022-31143"},"packages":[{"ecosystem":"npm","fixed":["7.0.2"],"introduced":["0"],"last_affected":[],"package":"@fastify/bearer-auth","purl":null,"source":"GHSA-376v-xgjx-7mfr"},{"ecosystem":"npm","fixed":["7.0.2"],"introduced":["0"],"last_affected":[],"package":"@fastify/bearer-auth","purl":"pkg:npm/%40fastify/bearer-auth","source":"GHSA-376v-xgjx-7mfr"},{"ecosystem":"npm","fixed":["8.0.1"],"introduced":["8.0.0"],"last_affected":[],"package":"@fastify/bearer-auth","purl":null,"source":"GHSA-376v-xgjx-7mfr"},{"ecosystem":"npm","fixed":["8.0.1"],"introduced":["8.0.0"],"last_affected":[],"package":"@fastify/bearer-auth","purl":"pkg:npm/%40fastify/bearer-auth","source":"GHSA-376v-xgjx-7mfr"},{"ecosystem":"npm","fixed":[],"introduced":["5.0.1"],"last_affected":["6.0.3"],"package":"fastify-bearer-auth","purl":null,"source":"GHSA-376v-xgjx-7mfr"},{"ecosystem":"npm","fixed":[],"introduced":["5.0.1"],"last_affected":["6.0.3"],"package":"fastify-bearer-auth","purl":"pkg:npm/fastify-bearer-auth","source":"GHSA-376v-xgjx-7mfr"}],"prev":{"headline":"Valinor error messages leading to potential data exfiltration","id":"CVE-2022-31140"},"products":["fastify-bearer-auth"],"published":"2022-07-14","related":[],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":"yes","exploitation":"none","technical_impact":"partial"},"state":"PUBLISHED","updated":"2025-04-23","vendors":["fastify"]},"summary":"A timing attack in the Fastify bearer auth plugin allows attackers to estimate valid token lengths, facilitating brute-force attacks against authentication.","url":"https://insights.sbomify.com/CVE-2022-31142/"}