URI parser's RFC3986 regular expression has poor performance when there are two # characters, leading to ReDoS
该报告还没有中文解读。
原文摘录
摘自原文(1640 字符中的一小部分)
Hello team, I hope you're doing well! The `URI` parser mishandles invalid URLs that have two `#` characters. It does correctly identify that they're invalid, but the regex performs very poorly and execution time grows much faster than the string length.
原文中的代码
require 'benchmark'
require 'uri'
def parse(n)
URI('https://example.com/dir/' + 'a' * n + '/##.jpg')
rescue URI::InvalidURIError
# Invalid URI because of the two #
end
n = 50000
Benchmark.bm(7) do |x|
x.report('Base length') { parse(n) }
x.report('Length x2 ') { parse(n * 2) } …默认不展示报告全文。以上为简短摘录,完整复现过程请阅读原文。版权归研究员与 Ruby 所有。
时间线
- 报告提交
- 公开披露
阅读 HackerOne 原文 ↗作者 @dee-see · 版权归作者与 Ruby 所有