Skip to content

Commit 7c618b0

Browse files
authored
Merge pull request #236 from cdcadman/cve_2023_26112
Address CVE-2023-26112 ReDoS
2 parents 97325b9 + a82ea8f commit 7c618b0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/configobj/validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class Validator(object):
541541
"""
542542

543543
# this regex does the initial parsing of the checks
544-
_func_re = re.compile(r'(.+?)\((.*)\)', re.DOTALL)
544+
_func_re = re.compile(r'([^\(\)]+?)\((.*)\)', re.DOTALL)
545545

546546
# this regex takes apart keyword arguments
547547
_key_arg = re.compile(r'^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$', re.DOTALL)

src/tests/test_validate_errors.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from configobj import ConfigObj, get_extra_values, ParseError, NestingError
6-
from configobj.validate import Validator
6+
from configobj.validate import Validator, VdtUnknownCheckError
77

88
@pytest.fixture()
99
def thisdir():
@@ -77,3 +77,11 @@ def test_no_parent(tmpdir, specpath):
7777
ini.write('[[haha]]')
7878
with pytest.raises(NestingError):
7979
conf = ConfigObj(str(ini), configspec=specpath, file_error=True)
80+
81+
82+
def test_re_dos(val):
83+
value = "aaa"
84+
i = 165100
85+
attack = '\x00'*i + ')' + '('*i
86+
with pytest.raises(VdtUnknownCheckError):
87+
val.check(attack, value)

0 commit comments

Comments
 (0)