diff options
author | Soumya Sambu <soumya.sambu@windriver.com> | 2024-07-26 12:04:24 +0000 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2024-08-03 11:56:05 -0400 |
commit | cffdfd0d699829f5ee7a0a59a6573cc6ed2601c4 (patch) | |
tree | 96d9d0a5cbe53ff058e73bec5bf1512639a83448 | |
parent | 9edbfe9826a58370a834a2a3bc2025698e52b184 (diff) | |
download | meta-openembedded-cffdfd0d699829f5ee7a0a59a6573cc6ed2601c4.tar.gz |
python3-sqlparse: Fix CVE-2024-4340
Passing a heavily nested list to sqlparse.parse() leads to a Denial
of Service due to RecursionError.
References:
https://nvd.nist.gov/vuln/detail/CVE-2024-4340
Upstream-patch:
https://github.com/andialbrecht/sqlparse/commit/b4a39d9850969b4e1d6940d32094ee0b42a2cf03
Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | meta-python/recipes-devtools/python/python3-sqlparse/CVE-2024-4340.patch | 48 | ||||
-rw-r--r-- | meta-python/recipes-devtools/python/python3-sqlparse_0.4.4.bb | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2024-4340.patch b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2024-4340.patch new file mode 100644 index 0000000000..670904071a --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2024-4340.patch | |||
@@ -0,0 +1,48 @@ | |||
1 | From b4a39d9850969b4e1d6940d32094ee0b42a2cf03 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andi Albrecht <albrecht.andi@gmail.com> | ||
3 | Date: Sat, 13 Apr 2024 13:59:00 +0200 | ||
4 | Subject: [PATCH] Raise SQLParseError instead of RecursionError. | ||
5 | |||
6 | CVE: CVE-2024-4340 | ||
7 | |||
8 | Upstream-Status: Backport [https://github.com/andialbrecht/sqlparse/commit/b4a39d9850969b4e1d6940d32094ee0b42a2cf03] | ||
9 | |||
10 | Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> | ||
11 | --- | ||
12 | sqlparse/sql.py | 14 +++++++++----- | ||
13 | 1 file changed, 9 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/sqlparse/sql.py b/sqlparse/sql.py | ||
16 | index 1ccfbdb..2090621 100644 | ||
17 | --- a/sqlparse/sql.py | ||
18 | +++ b/sqlparse/sql.py | ||
19 | @@ -10,6 +10,7 @@ | ||
20 | import re | ||
21 | |||
22 | from sqlparse import tokens as T | ||
23 | +from sqlparse.exceptions import SQLParseError | ||
24 | from sqlparse.utils import imt, remove_quotes | ||
25 | |||
26 | |||
27 | @@ -209,11 +210,14 @@ class TokenList(Token): | ||
28 | |||
29 | This method is recursively called for all child tokens. | ||
30 | """ | ||
31 | - for token in self.tokens: | ||
32 | - if token.is_group: | ||
33 | - yield from token.flatten() | ||
34 | - else: | ||
35 | - yield token | ||
36 | + try: | ||
37 | + for token in self.tokens: | ||
38 | + if token.is_group: | ||
39 | + yield from token.flatten() | ||
40 | + else: | ||
41 | + yield token | ||
42 | + except RecursionError as err: | ||
43 | + raise SQLParseError('Maximum recursion depth exceeded') from err | ||
44 | |||
45 | def get_sublists(self): | ||
46 | for token in self.tokens: | ||
47 | -- | ||
48 | 2.25.1 | ||
diff --git a/meta-python/recipes-devtools/python/python3-sqlparse_0.4.4.bb b/meta-python/recipes-devtools/python/python3-sqlparse_0.4.4.bb index c04971ee8f..fa633026c8 100644 --- a/meta-python/recipes-devtools/python/python3-sqlparse_0.4.4.bb +++ b/meta-python/recipes-devtools/python/python3-sqlparse_0.4.4.bb | |||
@@ -5,6 +5,7 @@ LICENSE = "BSD-3-Clause" | |||
5 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2b136f573f5386001ea3b7b9016222fc" | 5 | LIC_FILES_CHKSUM = "file://LICENSE;md5=2b136f573f5386001ea3b7b9016222fc" |
6 | 6 | ||
7 | SRC_URI += "file://0001-sqlparse-change-shebang-to-python3.patch \ | 7 | SRC_URI += "file://0001-sqlparse-change-shebang-to-python3.patch \ |
8 | file://CVE-2024-4340.patch \ | ||
8 | file://run-ptest \ | 9 | file://run-ptest \ |
9 | " | 10 | " |
10 | 11 | ||