CVE-2022-31142: Fastify bearer auth Fastify-bearer-auth Vulnerable To Timing Attack Vulnerability
HIGHCVE-2022-31142 is a HIGH (CVSS 7.5) fastify-bearer-auth vulnerable to timing attack vulnerability (CWE-203: Observable Discrepancy) affecting Fastify bearer auth libraries in the npm ecosystem. The issue involves fastify-bearer-auth vulnerable to timing attack vector. Remediation is available by upgrading affected packages to version 7.0.2, 8.0.1.
CVE-2022-31142 at a Glance
Security Impact
CVSS: 7.5
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:N/A:N).
How to Fix CVE-2022-31142
To remediate this vulnerability, upgrade all affected Fastify bearer auth dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install fastify-bearer-auth@Latest secure release
npm install @fastify/bearer-auth@7.0.2
npm install @fastify/bearer-auth@8.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls fastify-bearer-auth
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-31142, inspect your project dependencies using npm:
npm ls fastify-bearer-auth
Analyze the terminal output to locate any version of Fastify bearer auth in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.0.2), your application is affected.
Note: The npm ls fastify-bearer-auth command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-203: Observable Discrepancy, where the product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor. In Fastify bearer auth, 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
CVE-2022-31142 Affected Fastify bearer auth Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastify-bearer-auth
|
npm |
≥ 5.0.1
≤ 6.0.3
|
|
|
@fastify/bearer-auth
|
npm |
< 7.0.2
|
7.0.2
|
|
@fastify/bearer-auth
|
npm |
≥ 8.0.0
< 8.0.1
All 1 versions
8.0.0
|
8.0.1
|
References
Frequently Asked Questions
What is CVE-2022-31142?
Which Fastify bearer auth versions are affected?
What version fixes CVE-2022-31142?
Is fastify-bearer-auth affected?
Is @fastify/bearer-auth affected?
What is the CVSS score of CVE-2022-31142?
What CWE is associated with CVE-2022-31142?
How can I check npm dependencies for CVE-2022-31142?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-376v-xgjx-7mfr",
"modified" : "2022-07-21T15:57:26Z",
"published" : "2022-07-15T19:14:27Z",
"aliases" : [ "CVE-2022-31142" ],
"summary" : "fastify-bearer-auth vulnerable to Timing Attack Vector",
"details" : "### Impact\n\nfastify-bearer-auth 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.\n\nAll versions of fastify-bearer-auth are also affected.\n\n### Patches\n\nWe released:\n\n* v8.0.1 with a fix for the Fastify v4 line\n* v7.0.2 with a fix for the Fastify v3 line\n\n### Workarounds\n\nThere are no workarounds. Update your dependencies.\n\n### References\n\nhttps://hackerone.com/reports/1633287\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [https://github.com/fastify/fastify-bearer-auth](https://github.com/fastify/fastify-bearer-auth)\n* Email us at [hello@matteocollina.com](mailto:hello@matteocollina.com)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "fastify-bearer-auth"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.0.1"
}, {
"last_affected" : "6.0.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/bearer-auth"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "7.0.2"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "@fastify/bearer-auth"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "8.0.0"
}, {
"fixed" : "8.0.1"
} ]
} ],
"versions" : [ "8.0.0" ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-bearer-auth/security/advisories/GHSA-376v-xgjx-7mfr"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31142"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-bearer-auth/commit/0c468a616d7e56126dc468150f6a5a92e530b8e4"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-bearer-auth/commit/39353b15409ee99474545f615ffb16180cf3b716"
}, {
"type" : "WEB",
"url" : "https://github.com/fastify/fastify-bearer-auth/commit/f921a0582dc83112039004a9b5041141b50c5b3f"
}, {
"type" : "WEB",
"url" : "https://hackerone.com/reports/1633287"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fastify/fastify-bearer-auth"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-203", "CWE-208" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-07-15T19:14:27Z",
"nvd_published_at" : "2022-07-14T19:15:00Z"
}
}