CVE-2023-36617: ReDoS vulnerability in URI (Ruby)
The Ruby URI parser mishandles invalid URLs containing specific characters, causing a large increase in parsing time. An attacker could supply such a URL to cause a denial of service (ReDoS).
- Triaged in 11 hours
- Fixed in 30 days
- Paid in 30 days
- Disclosed after 30 days
Summary by the program
CVE-2023-36617: ReDoS vulnerability in URI
We have released the uri gem version 0.12.2, 0.10.3 that has a security fix for a ReDoS vulnerability. This vulnerability has been assigned the CVE identifier CVE-2023-36617.
Details A ReDoS issue was discovered in the URI component through 0.12.1 for Ruby. The URI parser mishandles invalid URLs that have specific characters. There is an increase in execution time for parsing strings to URI objects with rfc2396_parser.rb and rfc3986_parser.rb.
NOTE: this issue exists because of an incomplete fix for CVE-2023-28755.
The uri gem version 0.12.1 and all versions prior 0.12.1 are vulnerable for this vulnerability.
Recommended action We recommend to update the uri gem to 0.12.2. In order to ensure compatibility with bundled version in older Ruby series, you may update as follows instead:
For Ruby 3.0: Update to uri 0.10.3 For Ruby 3.1 and 3.2: Update to uri 0.12.2 You can use gem update uri to update it. If you are using bundler, please add gem "uri", ">= 0.12.2" (or other version mentioned above) to your Gemfile.
Affected versions uri gem 0.12.1 or before
Credits Thanks to ooooooo_q for discovering this issue. Thanks to nobu for fixing this issue.
Full security advisory: https://www.ruby-lang.org/en/news/2023/06/29/redos-in-uri-CVE-2023-36617/
The report
I made a report at https://hackerone.com/reports/1958260 .
https://www.ruby-lang.org/en/news/2023/06/29/redos-in-uri-CVE-2023-36617/
A ReDoS issue was discovered in the URI component through 0.12.1 for Ruby. The URI parser mishandles invalid URLs that have specific characters. There is an increase in execution time for parsing strings to URI objects with rfc2396_parser.rb and rfc3986_parser.rb.
NOTE: this issue exists because of an incomplete fix for CVE-2023-28755.
Impact
Parsing of URIs may cause ReDoS. Especially when using RFC2396_Parser, even Ruby 3.2.x is affected.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an inefficient regular expression in the URI parser that backtracks heavily on certain invalid URL strings, and the previous fix for CVE-2023-28755 was incomplete.
Impact
Parsing of URIs may cause ReDoS, potentially leading to denial of service, especially when using RFC2396_Parser even on Ruby 3.2.x.
What the attacker needed
Ability to supply a crafted URL to the parser
The fix
The vulnerability was fixed in uri gem versions 0.12.2 and 0.10.3; users should update to these versions.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A regular expression is a pattern used to match text. Some patterns can become extremely slow when given specially crafted input, which is called a ReDoS (regular expression denial of service). Here, the Ruby URI parser used such a pattern, so a malicious URL could make the program hang for a long time.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.