-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CVE-2021-27293: Fix NewDateRegex #1556
Comments
Previously it had exponential worst-case complexity and was vulnerable to REDoS.
Assigned CVE-2021-27293 |
@bcaller I can see a fix to this vulnerability, but on which version can we get this update? |
@abhijeet490 The patch has not reviewed or merged. If you want the fix anytime soon you may need to make a fork. |
I see that this issue has been closed, but the vulnerability still exists in version 106.11.7. On what version will this fix be released? |
106.11.8-alpha.0.13 😆 |
When could we expect a stable release which includes this fix? |
I'm honestly asking, is it the common practice to share CVE publicly before the fix was released and adopted? |
CVE's are already public knowledge. But its disappointing that its been since February without a patch. @b-c-ds This issue should not be closed. Can you please confirm whether an official release is planned? |
@gavinBurtonStoreFeeder I'm not a maintainer. It won't let me reopen the issue. Sorry. I only reported this issue and contributed one pull request. I don't think this project is super active so I wouldn't hold my breath waiting for a non-alpha release. |
This issue still exist when this will be fixed. |
The PR was included to 106.12.0 release |
This advisory was emailed to the maintainer. Posting here as an issue as requested.
Doyensec Vulnerability Advisory
SUMMARY
The .NET library RestSharp uses a regular expression which is vulnerable to Regular Expression Denial of Service (REDoS) when converting strings into DateTimes. If a server responds with a malicious string, the client using RestSharp will be stuck processing it for an exceedingly long time. This allows the remote server to trigger a Denial of Service.
TECHNICAL DESCRIPTION
The vulnerable regular expression is
NewDateRegex
inRestSharp.Extensions.StringExtensions
:RestSharp/src/RestSharp/Extensions/StringExtensions.cs
Line 28 in 0ed7b0a
It is used by the
ParseJsonDate
function when deserializing JSON responses into classes withDateTime
properties.Due to the
(-?\d+)*
part containing nested repeats, this regular expression has catastrophic backtracking when processing a long string of digits. The behaviour occurs as long as the digits are not followed immediately by a closing parenthesis ')'.An example of a REDoS payload is
new Date(12345678901234567890123456789012345
.The space between 'new' and 'Date' is required due to pre-processing in
ParseJsonDate
:RestSharp/src/RestSharp/Extensions/StringExtensions.cs
Lines 124 to 126 in 0ed7b0a
The complexity is exponential: increasing the length of the malicious string of digits by one makes processing take about twice as long. On my laptop, 27 digits takes about 16 seconds to process and 28 digits takes about 32 seconds, so a string with 54 digits should take approximately 68 years to process.
The vulnerable regular expression was first introduced in commit 373a0a3
REPRODUCTION STEPS
The REDoS can be triggered by calling
RestSharp.Extensions.StringExtensions.ParseJsonDate
directly, or by deserializing JSON responses into a class with a property of typeDateTime
.Example C# code to see the effect of the REDoS is attached below. Changing the length of the string of zeroes will change the processing time.
REMEDIATION
Fix
NewDateRegex
. We propose simply removing the asterisk:.
Doyensec (www.doyensec.com) is an independent security research and development company focused on vulnerability discovery and remediation. We work at the intersection of software development and offensive engineering to help companies craft secure code.
Copyright 2021 by Doyensec LLC. All rights reserved.
Permission is hereby granted for the redistribution of this advisory, provided that it is not altered except by reformatting it, and that due credit is given. Permission is explicitly given for insertion in vulnerability databases and similar, provided
that due credit is given. The information in the advisory is believed to be accurate at the time of publishing based on
currently available information, and it is provided as-is, as a free service to the community by Doyensec LLC. There are
no warranties with regard to this information, and Doyensec LLC does not accept any liability for any direct, indirect, or
consequential loss or damage arising from use of, or reliance on, this information.
The text was updated successfully, but these errors were encountered: