Skip to content
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

fix ReDoS #600

Merged
merged 1 commit into from Jan 26, 2022
Merged

fix ReDoS #600

merged 1 commit into from Jan 26, 2022

Conversation

ooooooo-q
Copy link
Contributor

@ooooooo-q ooooooo-q commented Jan 10, 2022

In the process of investigating Rails regular expressions using Regexploit, I discovered that i18n sometimes had ReDoS problems.
ReDoS seems to occur when there is a code like below.

I18n.interpolate('%<0>' + '0' * 3456, :num => 1)

The problem occurs when there is a translation file like the one below, but it seems that there are few cases where an attacker can inject on it.

en:
  test: "%<0>000..." # 0 * 3456

Results of Regexploit

(?-mix:%%)|(?-mix:%\{([\w|]+)\})|(?-mix:%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps]))
Pattern: (?-mix:%%)|(?-mix:%\{([\w|]+)\})|(?-mix:%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps]))
---
Redos(starriness=3, prefix_sequence=SEQ{ [25:%] [3c:<] [WORD]{1+} [3e:>] }, redos_sequence=SEQ{ .{0+} [DIGIT]{0+} [2e:.]{0,1} [DIGIT]{0+} [B,E,G,i,o,p,s,u,X,x,[b-g]] }, repeated_character=[DIGIT], killer=None)
Worst-case complexity: 3 ⭐⭐⭐ (cubic)
Repeated character: [DIGIT]
Example: '%<0>' + '0' * 3456


(?-mix:%%)|(?-mix:%\{([\w|]+)\})|(?-mix:%<(\w+)>([^\d]*?\d*\.?\d*[bBdiouxXeEfgGcps]))
No ReDoS found.

@radar radar merged commit d763372 into ruby-i18n:master Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants