Impact
This issue describes a ReDOS bug found within the figure caption extension (pymdownx.blocks.caption ).
In systems that take unchecked user content, this could cause long hanges when processing the data if a malicious payload was crafted.
Patches
This issue is patched in Release 10.16.1.
Workarounds
Some possible workarounds
If you are concerned about this vulnerability and process unknown user content without timeouts or other safeguards in place to prevent really large, malicious content being aimed at systems, the use of pymdownx.blocks.caption could be avoided until the library is updated to 10.16.1+.
References
The original issue #2716.
Description
The original issue came through our normal issue tracker instead of our security flow: #2716. Because this came through our normal issue flow, we handled this as a normal issue. In the future, we will ensure such issues, even if prematurely made public through the normal issue flow, are redirected through our security process.
The regular expression pattern in question is as follows:
RE_FIG_NUM = re.compile(r'^(\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)')
The POC was provided by @ShangzhiXu
import re
import time
regex_pattern = re.compile(r'^(\^)?([1-9][0-9]*(?:.[1-9][0-9]*)*)(?= |$)')
for i in range(50, 500, 50):
long_string = '1' * i + 'a'
start_time = time.time()
match = re.match(regex_pattern, long_string)
end_time = time.time()
print(f"long_string execution time: {end_time - start_time:.6f} s")
The issue with the above pattern is that we used . which accepts any character when we meant to use \.. The fix was to update the pattern to:
RE_FIG_NUM = re.compile(r'^(\^)?([1-9][0-9]*(?:\.[1-9][0-9]*)*)(?= |$)')
Relevant PR with fix: #2717
Version(s) & System Info
- Operating System: Any
- Python Version: Any
Impact
This issue describes a ReDOS bug found within the figure caption extension (
pymdownx.blocks.caption).In systems that take unchecked user content, this could cause long hanges when processing the data if a malicious payload was crafted.
Patches
This issue is patched in Release 10.16.1.
Workarounds
Some possible workarounds
If you are concerned about this vulnerability and process unknown user content without timeouts or other safeguards in place to prevent really large, malicious content being aimed at systems, the use of
pymdownx.blocks.captioncould be avoided until the library is updated to 10.16.1+.References
The original issue #2716.
Description
The original issue came through our normal issue tracker instead of our security flow: #2716. Because this came through our normal issue flow, we handled this as a normal issue. In the future, we will ensure such issues, even if prematurely made public through the normal issue flow, are redirected through our security process.
The regular expression pattern in question is as follows:
The POC was provided by @ShangzhiXu
The issue with the above pattern is that we used
.which accepts any character when we meant to use\.. The fix was to update the pattern to:Relevant PR with fix: #2717
Version(s) & System Info