The vulnerability is a logical denial-of-service in the fast-jwt library caused by the incorrect handling of stateful regular expressions. When a RegExp with a global (/g) or sticky (/y) flag is used in options like allowedAud, allowedIss, etc., the RegExp.prototype.test() method becomes stateful. The library reuses the same RegExp object for multiple validations without resetting the lastIndex property, which is mutated by test(). This results in an alternating PASS/FAIL validation for the same, valid JWT, leading to intermittent authentication failures.
The analysis of the provided patch 18d25904e4617e8753526d1b3ab5a2cccdea726a confirms this. The fix is in the ensureStringClaimMatcher function in src/verifier.js. This function is modified to wrap any RegExp object in a new object. This wrapper's test method resets the lastIndex of the original RegExp to 0 before calling its test method, thus ensuring the validation is deterministic.
The vulnerability description also explicitly identifies validateClaimValues as the function that performs the vulnerable action by calling a.test(v) on the stateful RegExp. Therefore, during runtime exploitation, validateClaimValues is the function where the non-deterministic behavior is exhibited, while ensureStringClaimMatcher is the function that creates the vulnerable condition during the verifier's setup.