From patchwork Fri Dec 4 12:29:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogita Urade X-Patchwork-Id: 107304 Received: from aer-iport-4.cisco.com (aer-iport-4.cisco.com [173.38.203.54]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.6871.1796387386351056206 for ; Fri, 04 Dec 2026 04:29:46 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=jRV0AZxg; spf=pass (domain: cisco.com, ip: 173.38.203.54, mailfrom: yurade@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=5890; q=dns/txt; s=iport01; t=1796387386; x=1797596986; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=CwvxC4Q2L4MLTo3ZQMReSI4imUG4h4jI3YNSTGM005I=; b=jRV0AZxgmU6XsXSPt5Z893zkXeZbECYgeiS02Ec+LIUgJcj/9EXrOd7H pAibRCox/D+7hPQw0bGkfgxnFqj/RGrV/UICHAyQ7kTXX6v/u8J8z9Ol0 oyLttxKKVLr25dpxS18x9ysbg20p2TcGTQkZBSI2V1jcXtW2u9aYs3YXK pbDR/G+hnStQF91FPSX78m28fJ1mB7hFl7pgNa5OYaJmihLzf/drankpM lH7mqPkF1ADnNGy5WOPRl2Y/xC9BO71XkcYIplbAODHXJPe+yWmHQT4hb QSrtjQV8GH2AANQr/O9H9wM8azdeR5l6LjY4LoajDREfXKTgKEuyC788s A==; X-CSE-ConnectionGUID: 2ISAIJy+RZu2WubPOwyn2Q== X-CSE-MsgGUID: YHd0y0zYT9GDIDc+QiXRlg== X-IPAS-Result: A0BJAgDYsRJr/8pK/pBaglmCV3VgQ0mULIIhA4ETnReBfg8BAQEPRA0EAQGEP0YCjiQCJjQJDgECBAMCAwEBAQEBAQEBAQEBAQoBAQUBAQECAQcFgQ4Thk8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BEbWR63rOe0jma6WslDM AoT4icooK04+UCnQ9W7WAe3yENopTYVVsAVF6gx7xuAj/KNpQ2YHWMDCDVGbbTKqfMLeNDj7 XfR9/uBONClmOT9pa61nltMkQ6PBA== IronPort-HdrOrdr: A9a23:YKzbxqgpM7IZCjl+yUmcQUi/n3BQXvYji2hC6mlwRA09TyX+rb HLoB1173HJYVoqNU3I3OrwW5VoIkmskKKdn7NxAV7KZmCP0wGVxcNZnOnfKlbbdBEWmNQw6U 4ZSchDIey1K0RmhsDn5wT9OdMhzN6btJ2Mv47lvhBQpcUAUdAY0++/YTzrdHFLeA== X-Talos-CUID: 9a23:gJQCxmtaW4rlypLy9Tbw6o/w6It/U0b07VXBYHWKFDxWVbetbkCB/vldxp8= X-Talos-MUID: 9a23:FJm6jAQ24VWrRJVARXTdpD06JZ960pj/J2wsvZ5Fgsi0Dyh/bmI= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="64543026" Received: from aer-l-core-01.cisco.com ([144.254.74.202]) by aer-iport-4.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 12:29:37 +0000 Received: from sjc-ads-7871.cisco.com (sjc-ads-7871.cisco.com [10.30.222.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-01.cisco.com (Postfix) with ESMTPS id 81115D6545 for ; Fri, 4 Dec 2026 12:29:37 +0000 (GMT) Received: by sjc-ads-7871.cisco.com (Postfix, from userid 1889728) id 2354FCBF201; Fri, 4 Dec 2026 04:29:36 -0800 (PST) From: Yogita Urade To: openembedded-devel@lists.openembedded.org Subject: [oe][meta-python][wrynose][PATCH 2/2] python3-sqlparse: Fix CVE-2026-112307 Date: Fri, 4 Dec 2026 04:29:35 -0800 Message-Id: <20261204122935.2451864-2-yurade@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261204122935.2451864-1-yurade@cisco.com> References: <20261204122935.2451864-1-yurade@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-7871.cisco.com [10.30.222.158];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.30.222.158, sjc-ads-7871.cisco.com X-Outbound-Node: aer-l-core-01.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 04 Dec 2026 12:29:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134032 This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. [1] https://github.com/andialbrecht/sqlparse/commit/bb3c50a52dc2f267c786f0d99c27b25519f9331f [2] https://github.com/andialbrecht/sqlparse/pull/937 [3] https://nvd.nist.gov/vuln/detail/cve-2026-112307 Signed-off-by: Yogita Urade --- .../python3-sqlparse/CVE-2026-112307.patch | 98 +++++++++++++++++++ .../python/python3-sqlparse_0.5.5.bb | 1 + 2 files changed, 99 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch diff --git a/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch new file mode 100644 index 0000000000..4793952ead --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch @@ -0,0 +1,98 @@ +From bb3c50a52dc2f267c786f0d99c27b25519f9331f Mon Sep 17 00:00:00 2001 +From: cve-zh00 +Date: Tue, 20 Oct 2026 10:56:23 -0300 +Subject: [PATCH] fix: escape dollar signs in PHP output format (CVE-2026-112307) + +PHP interpolates $var, ${expr} and {$expr} inside double-quoted strings, +so SQL text containing them could inject PHP code into the snippet +generated by output_format='php'. Escape "$" as "\$" after the existing +backslash and double-quote escaping. + +Adds regression tests for SQL literals, ${expr}/{${expr}} payloads, +PostgreSQL dollar quoting, quoted identifiers, comments and a preceding +backslash. + +CVE: CVE-2026-112307 +Upstream-Status: Backport [https://github.com/andialbrecht/sqlparse/commit/bb3c50a52dc2f267c786f0d99c27b25519f9331f] + +Backport Changes: +- Omitted CHANGELOG because its upstream master hunk conflicts with the + target 0.5.5 changelog context; the entry is documentation-only. + +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> +Signed-off-by: Yogita Urade +--- + sqlparse/filters/output.py | 8 ++++++-- + tests/test_format.py | 39 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+), 2 deletions(-) + +diff --git a/sqlparse/filters/output.py b/sqlparse/filters/output.py +index 697ebc3..06015ec 100644 +--- a/sqlparse/filters/output.py ++++ b/sqlparse/filters/output.py +@@ -114,9 +114,13 @@ class OutputPHPFilter(OutputFilter): + + # Escape backslashes before quotes so a backslash preceding a + # quote cannot break out of the generated string literal +- # (GHSA-3496-9g83-7v6x). ++ # (GHSA-3496-9g83-7v6x). Dollar signs are escaped last because ++ # PHP interpolates $var, ${expr} and {$expr} inside double-quoted ++ # strings (CVE-2026-112307). + else: +- token.value = token.value.replace('\\', '\\\\').replace('"', '\\"') ++ token.value = (token.value.replace('\\', '\\\\') ++ .replace('"', '\\"') ++ .replace('$', '\\$')) + + # Put the token + yield sql.Token(T.Text, token.value) +diff --git a/tests/test_format.py b/tests/test_format.py +index 9349506..06c9342 100644 +--- a/tests/test_format.py ++++ b/tests/test_format.py +@@ -705,6 +705,45 @@ class TestOutputFormat: + f = lambda sql: sqlparse.format(sql, output_format='php') + assert f(sql) == '$sql = "select \'\\\\foo\\\\\'";' + ++ @pytest.mark.parametrize('sql, expected', [ ++ # plain variable interpolation ++ ("SELECT '$name'", r'''$sql = "SELECT '\$name'";'''), ++ # expression interpolation payloads (CVE-2026-112307) ++ ("SELECT '${expr}'", r'''$sql = "SELECT '\${expr}'";'''), ++ ("SELECT '{${expr}}'", r'''$sql = "SELECT '{\${expr}}'";'''), ++ ("SELECT '{$obj->prop}'", r'''$sql = "SELECT '{\$obj->prop}'";'''), ++ # PostgreSQL dollar-quoted strings ++ ('SELECT $body$text$body$', ++ r'''$sql = "SELECT \$body\$text\$body\$";'''), ++ # quoted identifiers and comments ++ ('SELECT "$table"', r'''$sql = "SELECT \"\$table\"";'''), ++ ('SELECT 1 /* $name */', r'''$sql = "SELECT 1 /* \$name */";'''), ++ # an existing backslash must not neutralize the dollar escape ++ ("SELECT '\\$name'", r'''$sql = "SELECT '\\\$name'";'''), ++ ]) ++ def test_php_escapes_dollar_signs(self, sql, expected): ++ # CVE-2026-112307: "$" starts variable/expression interpolation in ++ # PHP double-quoted strings and must be escaped. ++ assert sqlparse.format(sql, output_format='php') == expected ++ ++ def test_php_dollar_escape_multiline(self): ++ sql = 'select $a$x$a$\nfrom foo where b = \'$c\'' ++ formatted = sqlparse.format(sql, output_format='php') ++ assert formatted == '\n'.join([ ++ '$sql = "select \\$a\\$x\\$a\\$ ";', ++ '$sql .= "from foo where b = \'\\$c\'";']) ++ ++ def test_php_variable_name_keeps_dollar(self): ++ # only SQL content is escaped, not the generated assignment target ++ formatted = sqlparse.format('select 1; select 2', output_format='php') ++ assert formatted == '$sql = "select 1; ";\n$sql2 = "select 2";' ++ ++ def test_python_dollar_signs_unchanged(self): ++ # "$" has no special meaning in single-quoted Python strings ++ sql = "select '$name' from $t$x$t$" ++ formatted = sqlparse.format(sql, output_format='python') ++ assert formatted == "sql = 'select \\'$name\\' from $t$x$t$'" ++ + def test_sql(self): + # "sql" is an allowed option but has no effect + sql = 'select * from foo;' diff --git a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb index 62d0318f84..0da78b8a03 100644 --- a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb +++ b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb @@ -12,6 +12,7 @@ SRC_URI += "file://CVE-2026-54284-1.patch \ file://CVE-2026-59894.patch \ file://CVE-2026-71491.patch \ file://CVE-2026-84305.patch \ + file://CVE-2026-112307.patch \ " CVE_PRODUCT = "sqlparse"