Skip to content

Commit

Permalink
Merge pull request #236 from cdcadman/cve_2023_26112
Browse files Browse the repository at this point in the history
Address CVE-2023-26112 ReDoS
  • Loading branch information
jelmer authored Sep 17, 2024
2 parents 97325b9 + a82ea8f commit 7c618b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/configobj/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class Validator(object):
"""

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

# this regex takes apart keyword arguments
_key_arg = re.compile(r'^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$', re.DOTALL)
Expand Down
10 changes: 9 additions & 1 deletion src/tests/test_validate_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from configobj import ConfigObj, get_extra_values, ParseError, NestingError
from configobj.validate import Validator
from configobj.validate import Validator, VdtUnknownCheckError

@pytest.fixture()
def thisdir():
Expand Down Expand Up @@ -77,3 +77,11 @@ def test_no_parent(tmpdir, specpath):
ini.write('[[haha]]')
with pytest.raises(NestingError):
conf = ConfigObj(str(ini), configspec=specpath, file_error=True)


def test_re_dos(val):
value = "aaa"
i = 165100
attack = '\x00'*i + ')' + '('*i
with pytest.raises(VdtUnknownCheckError):
val.check(attack, value)

0 comments on commit 7c618b0

Please sign in to comment.