Commit 7541585
committed
Fix ReDoS caused by very large character references using repeated 0s
This patch will fix the ReDoS that is caused by large string of 0s on a character reference (like `�...`).
## Proof of Concept
```ruby
require "rexml"
require "benchmark"
def test(benchmark, payload)
benchmark.report { begin REXML::Document.new(payload) rescue Exception end }
end
Benchmark.bm do |x|
test(x, '<test testing="&#' + "0" * 20000 + '"/>')
test(x, '<test testing="&#' + "0" * 40000 + '"/>')
test(x, '<test testing="&#' + "0" * 60000 + '"/>')
test(x, '<test testing="&#' + "0" * 80000 + '"/>')
test(x, '<test testing="&#' + "0" * 100000 + '"/>')
end
```1 parent 4ebf21f commit 7541585
2 files changed
+46
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
162 | 175 | | |
163 | | - | |
| 176 | + | |
164 | 177 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | 178 | | |
171 | 179 | | |
| 180 | + | |
| 181 | + | |
172 | 182 | | |
| 183 | + | |
| 184 | + | |
173 | 185 | | |
174 | 186 | | |
175 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments