Skip to content

Commit

Permalink
CVE-2023-30608 Hand-Cherry-Pick a fix c457abd
Browse files Browse the repository at this point in the history
  • Loading branch information
rickprice committed May 9, 2024
1 parent 0d6684b commit 41d5b92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
Release 0.3.1.1 (May 9, 2024)
----------------------------

Notable Changes

* IMPORTANT: This release fixes a security vulnerability in the
parser where a regular expression vulnerable to ReDOS (Regular
Expression Denial of Service) was used. See the security advisory
for details: https://github.com/andialbrecht/sqlparse/security/advisories/GHSA-rrm6-wvj7-cwh2
The vulnerability was discovered by @erik-krogh from GitHub
Security Lab (GHSL). Thanks for reporting!


Bug Fixes

* Fix regular expressions for string parsing.

Release 0.3.1 (Feb 29, 2020)
----------------------------

Expand Down
4 changes: 2 additions & 2 deletions sqlparse/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def is_keyword(value):
(r'(?![_A-ZÀ-Ü])-?(\d+(\.\d*)|\.\d+)(?![_A-ZÀ-Ü])',
tokens.Number.Float),
(r'(?![_A-ZÀ-Ü])-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer),
(r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single),
(r"'(''|\\'|[^'])*'", tokens.String.Single),
# not a real string literal in ANSI SQL:
(r'"(""|\\\\|\\"|[^"])*"', tokens.String.Symbol),
(r'"(""|\\"|[^"])*"', tokens.String.Symbol),
(r'(""|".*?[^\\]")', tokens.String.Symbol),
# sqlite names can be escaped with [square brackets]. left bracket
# cannot be preceded by word character or a right bracket --
Expand Down
5 changes: 2 additions & 3 deletions tests/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ def test_split_semicolon():


def test_split_backslash():
stmts = sqlparse.parse(r"select '\\'; select '\''; select '\\\'';")
assert len(stmts) == 3

stmts = sqlparse.parse("select '\'; select '\'';")
assert len(stmts) == 2

@pytest.mark.parametrize('fn', ['function.sql',
'function_psql.sql',
Expand Down

0 comments on commit 41d5b92

Please sign in to comment.