CVE-2022-31142 Potential Timing Attack Vector in @fastify/bearer-auth

High 7.5 Published Updated

A timing attack in the Fastify bearer auth plugin allows attackers to estimate valid token lengths, facilitating brute-force attacks against authentication.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2022-31142?

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.

Official 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.

Weakness: CWE-203, CWE-208

Which versions are affected by CVE-2022-31142?

6 open source packages ship an affected version, including fastify-bearer-auth and @fastify/bearer-auth. It affects 1 product.

PackageAffectedFixed in
fastify-bearer-auth npmFrom 5.0.1 to 6.0.3None
fastify-bearer-auth npmFrom 5.0.1 to 6.0.3None
@fastify/bearer-auth npmAll versions7.0.2
@fastify/bearer-auth npmAll versions7.0.2
@fastify/bearer-auth npmFrom 8.0.08.0.1
@fastify/bearer-auth npmFrom 8.0.08.0.1

Products include Fastify Bearer-Auth.

How do I fix CVE-2022-31142?

Upgrade to a fixed version.

Is CVE-2022-31142 being exploited?

There is no known exploitation of CVE-2022-31142 in the wild and no public exploit code.

Sources

Also known as GHSA-376v-xgjx-7mfr.

Is CVE-2022-31142 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free