Regex timeout in JwtTokenUtilities with long jwt
See original GitHub issueHi, I’ve got this basic code to read a quite big jwt (9MB). I’ve tried the same code in different machines. It’s working well in most of them, but it’s failing in two and there’s now way to make it works.
The error message is The RegEx engine has timed out while trying to match a pattern to an input string. This can occur for many reasons, including very large inputs or excessive backtracking caused by nested quantifiers, back-references and other factors.
I’ve checked the source code and the reason for this is in the class JwtTokenUtilities
.
In this line there’s an hardcoded 100ms timeout. I think that this was changed from 2s in 2015 and the decision was to make it not configurable.
Is there any other way or any other configuration (maybe in the os level… win10) to check/change in order to make this work?
Here is the test code:
var jwtHandler = new JwtSecurityTokenHandler { MaximumTokenSizeInBytes = 20000000 };
string text = System.IO.File.ReadAllText(@"long_jwt.txt");
var jwt = jwtHandler.ReadJwtToken(text); // throws regex timeout exception
Thanks for your help.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
It turned out that updating the project from .net core 2.1 to 2.2 fixes the issue.
@Riff451 good to hear. Sorry for the hassle.