new file mode 100644
@@ -0,0 +1,119 @@
+From a51df6d9e2d31b44be9adb6bc8732517db6bf96b Mon Sep 17 00:00:00 2001
+From: Andi Albrecht <albrecht.andi@gmail.com>
+Date: Sat, 25 Jul 2026 08:52:26 +0200
+Subject: [PATCH] Measure reindent offsets backwards to avoid quadratic CPU use
+
+ReindentFilter._get_offset() reports the column a token starts on and is
+called once per group. It rebuilt the statement prefix from the start of
+the statement on every call, so reindenting a list of N parenthesized
+tuples cost O(N^2). A ~12 KB payload sized just below MAX_GROUPING_TOKENS
+occupied a worker for seconds (CWE-1333, GHSA-cfqr-cjx5-5jcm).
+
+Measure the current line by walking backwards from the token and counting
+characters instead, which stops at the preceding line break rather than
+touching the whole statement. Formatting output is unchanged, verified
+byte for byte over the test corpus and 147 option combinations.
+
+Both vectors reaching the offset calculation are covered by the new
+benchmark: IN (...) tuple lists via _process_parenthesis() and
+_process_identifierlist(), VALUES lists via _process_values().
+
+CVE: CVE-2026-84305
+Upstream-Status: Backport [https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b]
+
+Backport Changes:
+- Omitted CHANGELOG because its upstream master hunk conflicts with the
+ wrynose 0.5.5 changelog history; the entry is documentation-only and
+ is not needed for the security fix.
+- Omitted the upstream benchmark script; it is development tooling and is
+ not required for the production fix.
+
+Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
+Signed-off-by: Yogita Urade <yurade@cisco.com>
+---
+ sqlparse/filters/reindent.py | 66 +++++++++++++++----
+ 1 file changed, 53 insertions(+), 13 deletions(-)
+
+diff --git a/sqlparse/filters/reindent.py b/sqlparse/filters/reindent.py
+index 9fb232f..96b603a 100644
+--- a/sqlparse/filters/reindent.py
++++ b/sqlparse/filters/reindent.py
+@@ -25,25 +25,65 @@ class ReindentFilter:
+ self._last_stmt = None
+ self._last_func = None
+
+- def _flatten_up_to_token(self, token):
+- """Yields all tokens up to token but excluding current."""
+- if token.is_group:
+- token = next(token.flatten())
+-
+- for t in self._curr_stmt.flatten():
+- if t == token:
+- break
+- yield t
+-
+ @property
+ def leading_ws(self):
+ return self.offset + self.indent * self.width
+
++ def _current_line_len(self, token):
++ """Returns the width of what's already emitted on *token*'s line.
++
++ The tokens preceding *token* are visited last one first, so the walk
++ stops at the line break that starts the current line. Rebuilding the
++ statement prefix from its start instead made every caller
++ O(statement), and the callers running once per group (tuple lists,
++ identifier lists) quadratic in the number of groups -- a CPU
++ exhaustion vector (GHSA-cfqr-cjx5-5jcm). The walk is inlined and
++ counts characters rather than collecting them: both matter, since a
++ line without any break still has to be measured token by token.
++ """
++ length = 0
++ node = token
++ while node is not self._curr_stmt and node.parent is not None:
++ parent = node.parent
++ # ``Token`` doesn't implement ``__eq__``, so ``index()`` is an
++ # identity lookup and safe against tokens sharing a value.
++ stack = parent.tokens[:parent.tokens.index(node)]
++ while stack:
++ prev_ = stack.pop()
++ if prev_.is_group:
++ stack.extend(prev_.tokens)
++ continue
++
++ value = prev_.value
++ size = len(value)
++ if not size:
++ continue
++ lines = value.splitlines()
++ if len(lines) == 1 and len(lines[0]) == size:
++ # No break in here. ``splitlines()`` hands back the value
++ # itself in that case, so this costs a scan but no copy --
++ # which is what keeps a long break-free line affordable.
++ length += size
++ continue
++
++ # ``value`` holds the break that starts the current line. The
++ # sentinel keeps a trailing break from collapsing, so ``lines``
++ # always has one entry more than the number of breaks.
++ lines = (value + '.').splitlines()
++ tail = len(lines[-1]) - 1 + length
++ if tail:
++ return tail
++ # Nothing but a break to our right, and ``splitlines()`` drops
++ # that empty line -- so the line to measure is the one before.
++ if len(lines) > 2:
++ return len(lines[-2])
++ length = len(lines[0])
++ node = parent
++ return length
++
+ def _get_offset(self, token):
+- raw = ''.join(map(str, self._flatten_up_to_token(token)))
+- line = (raw or '\n').splitlines()[-1]
+ # Now take current offset into account and return relative offset.
+- return len(line) - len(self.char * self.leading_ws)
++ return self._current_line_len(token) - len(self.char * self.leading_ws)
+
+ def nl(self, offset=0):
+ return sql.Token(
@@ -11,6 +11,7 @@ SRC_URI += "file://CVE-2026-54284-1.patch \
file://CVE-2026-59893.patch \
file://CVE-2026-59894.patch \
file://CVE-2026-71491.patch \
+ file://CVE-2026-84305.patch \
"
CVE_PRODUCT = "sqlparse"
Backport upstream's reindent fix, which measures offsets by walking backward through tokens [1] for CVE-2026-84305 [2]. [1] https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b [2] https://nvd.nist.gov/vuln/detail/cve-2026-84305 Signed-off-by: Yogita Urade <yurade@cisco.com> --- .../python3-sqlparse/CVE-2026-84305.patch | 119 ++++++++++++++++++ .../python/python3-sqlparse_0.5.5.bb | 1 + 2 files changed, 120 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-84305.patch