Potential Timing Attack Vector in @fastify/bearer-auth
@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.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2022-31142
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 3 Nov 2026, 17:43 UTC · Revision 1
Source evidence
Potential Timing Attack Vector in @fastify/bearer-auth
core-osv · Original sourcePublished 14 Jul 2022, 18:55 UTC
@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.
osv:CVE-2022-31142
Complete source record
{
"id": "ab52dcbe282fd91f6bb12886a59e83176d16f2dad9bf3c86522d0c86b39a4c5b",
"url": "https://osv.dev/vulnerability/CVE-2022-31142",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "Potential Timing Attack Vector in @fastify/bearer-auth",
"summary": "@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.",
"evidence": "osv:CVE-2022-31142",
"products": [],
"severity": "high",
"structured": {
"id": "CVE-2022-31142",
"aliases": [
"CVE-2022-31142",
"GHSA-376v-xgjx-7mfr"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/fastify/fastify-bearer-auth",
"type": "GIT",
"events": [
{
"introduced": "307a6503ec18342b212a3530877912f8e30d1b5f"
},
{
"fixed": "0c468a616d7e56126dc468150f6a5a92e530b8e4"
},
{
"introduced": "b103ba14d7fe05df5b531ae79ba587466e733929"
},
{
"fixed": "39353b15409ee99474545f615ffb16180cf3b716"
},
{
"fixed": "f921a0582dc83112039004a9b5041141b50c5b3f"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:fastify:bearer-auth:*:*:*:*:*:node.js:*:*",
"range": [
{
"introduced": "5.0.1"
},
{
"fixed": "7.0.2"
}
],
"source": "CPE_RANGE"
},
{
"cpe": "cpe:2.3:a:fastify:bearer-auth:8.0.0:*:*:*:*:node.js:*:*",
"range": [
{
"introduced": "8.0.0"
},
{
"last_affected": "8.0.0"
}
],
"source": "CPE_STRING"
},
{
"range": [
{
"fixed": "0c468a616d7e56126dc468150f6a5a92e530b8e4"
}
],
"source": "REFERENCES_COMMIT"
},
{
"range": [
{
"fixed": "39353b15409ee99474545f615ffb16180cf3b716"
}
],
"source": "REFERENCES_COMMIT"
},
{
"range": [
{
"fixed": "f921a0582dc83112039004a9b5041141b50c5b3f"
}
],
"source": "REFERENCES_COMMIT"
}
]
}
}
],
"versions": [
"8.0.0",
"= 8.0.0",
"v7.0.1",
"v8.0.0",
"v7.0.0",
"v6.2.0",
"v6.1.0",
"v6.0.0",
"v5.1.0",
"v5.0.2",
"v5.0.1"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2022-31142.json"
}
}
],
"modified": "2026-10-28T02:30:31.266536094Z",
"provider": "osv",
"references": [
"https://hackerone.com/reports/1633287",
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/31xxx/CVE-2022-31142.json",
"https://github.com/fastify/fastify-bearer-auth/security/advisories/GHSA-376v-xgjx-7mfr",
"https://nvd.nist.gov/vuln/detail/CVE-2022-31142",
"https://github.com/fastify/fastify-bearer-auth/commit/0c468a616d7e56126dc468150f6a5a92e530b8e4",
"https://github.com/fastify/fastify-bearer-auth/commit/39353b15409ee99474545f615ffb16180cf3b716",
"https://github.com/fastify/fastify-bearer-auth/commit/f921a0582dc83112039004a9b5041141b50c5b3f"
],
"provider_metadata": {
"cwe_ids": [
"CWE-208"
],
"cna_assigner": "GitHub_M",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/31xxx/CVE-2022-31142.json"
}
},
"related_cves": [
{
"value": "CVE-2022-31142",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 497971,
"published_at": "2022-07-14T18:55:11+00:00"
}