Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address CVE-2023-26112 ReDoS #236

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)