Skip to contentSkip to conversation

python-grpcio(-tools): add grpc:grpc to cve product

PATCH New Gyorgy Sarvari 1 participant 5 messages Jan 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 python-grpcio(-tools): add grpc:grpc to cve product

From: Peter Marko <[email protected]>

These grpc python modules contain parts of grpc core.
Each CVE needs to be assessed if the patch applies also to core parts included in each module.

Note that so far there was never a CVE specific for python module, only for grpc:grpc and many of those needed to be fixed at leasts in grpcio:

sqlite> select vendor, product, count(*) from products where product like '%grpc%' group by vendor, product; grpc|grpc|21
grpck|grpck|1
linuxfoundation|grpc_swift|9
microsoft|grpconv|1
opentelemetry|configgrpc|1

(cherry picked from commit f993cb2ecb62193bcce8d3d0e06e180a7fef44b8)
---
 .../recipes-devtools/python/python3-grpcio-tools_1.45.0.bb      | 2 ++
 meta-python/recipes-devtools/python/python3-grpcio_1.45.0.bb    | 2 ++
 2 files changed, 4 insertions(+)
meta-python/recipes-devtools/python/python3-grpcio-tools_1.45.0.bb +2 -0
index be851ba990..1f74d25aee 100644
@@ -19,3 +19,5 @@ do_compile:prepend() {
 }
 
 BBCLASSEXTEND = "native nativesdk"
+
+CVE_PRODUCT += "grpc:grpc"
meta-python/recipes-devtools/python/python3-grpcio_1.45.0.bb +2 -0
index 56b84dab72..2671e5c738 100644
@@ -47,4 +47,6 @@ CLEANBROKEN = "1"
 
 BBCLASSEXTEND = "native nativesdk"
 
+CVE_PRODUCT += "grpc:grpc"
+
 CCACHE_DISABLE = "1"
#1 lore raw

PATCH 2/5 python3-protobuf: set CVE_PRODUCT

From: Peter Marko <[email protected]>

Similarly to c++ protobuf, add products matching historical entries.

(cherry picked from commit ae7556a737f7d21b0e345226fdab4a286d2f85db)
---
 meta-python/recipes-devtools/python/python3-protobuf_3.20.3.bb | 2 ++
 1 file changed, 2 insertions(+)
meta-python/recipes-devtools/python/python3-protobuf_3.20.3.bb +2 -0
index 3c25373796..b3846ddeb3 100644
@@ -11,6 +11,8 @@ SRC_URI += "file://CVE-2025-4565.patch"
 
 SRC_URI[sha256sum] = "2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2"
 
+CVE_PRODUCT += "google:protobuf protobuf:protobuf google-protobuf protobuf-python"
+
 # http://errors.yoctoproject.org/Errors/Details/184715/
 # Can't find required file: ../src/google/protobuf/descriptor.proto
 CLEANBROKEN = "1"
#2 lore raw

PATCH 3/5 python3-cbor2: ignore CVE-2025-64076

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2025-64076

The vunerability was introduced in v5.6.0[1], the recipe version doesn't contain the vulnerable piece of code.

[1]: https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542

---
 meta-python/recipes-devtools/python/python3-cbor2_5.4.2.bb | 3 +++
 1 file changed, 3 insertions(+)
meta-python/recipes-devtools/python/python3-cbor2_5.4.2.bb +3 -0
index 0d0ab6af37..bbdeca7adb 100644
@@ -12,6 +12,9 @@ SRC_URI += " \
         file://run-ptest \
 "
 
+# not vulnerable yet, vulnerability was introduced in v5.6.0
+CVE_CHECK_IGNORE = "CVE-2025-64076"
+
 RDEPENDS:${PN}-ptest += " \
        ${PYTHON_PN}-pytest \
        ${PYTHON_PN}-unixadmin \
#3 lore raw

PATCH 4/5 python3-configobj: patch CVE-2023-26112

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2023-26112

Pick the patch that resolves the issue referenced in the NVD report.

---
 .../python3-configobj/CVE-2023-26112.patch    | 25 +++++++++++++++++++
 .../python/python3-configobj_5.0.6.bb         |  3 ++-
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 meta-python/recipes-devtools/python/python3-configobj/CVE-2023-26112.patch
meta-python/recipes-devtools/python/python3-configobj/CVE-2023-26112.patch new file +25 -0
new file mode 100644
index 0000000000..35d8ea77cf
@@ -0,0 +1,25 @@
+From 76dd27ec0dbde6c852f412390ac4e2cfefa8af76 Mon Sep 17 00:00:00 2001
+From: cdcadman <[email protected]>
+Date: Wed, 17 May 2023 03:57:08 -0700
+Subject: [PATCH] Address CVE-2023-26112 ReDoS
+
+CVE: CVE-2023-26112
+Upstream-Status: Backport [https://github.com/DiffSK/configobj/commit/7c618b0bbaff6ecaca51a6f05b29795d1377a4a5]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ validate.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/validate.py b/validate.py
+index b7a964c..af76898 100644
+--- a/validate.py
++++ b/validate.py
+@@ -542,7 +542,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)
meta-python/recipes-devtools/python/python3-configobj_5.0.6.bb +2 -1
index 1125a6389d..589ad6f1d9 100644
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://configobj.py;md5=a7c3968dd866dfd23e91e125b669ab21"
 PYPI_PACKAGE = "configobj"
 SRC_URI[sha256sum] = "a2f5650770e1c87fb335af19a9b7eb73fc05ccf22144eb68db7d00cd2bcb0902"
 
-SRC_URI += "file://0001-Switch-from-using-distutils-to-setuptools.patch"
+SRC_URI += "file://0001-Switch-from-using-distutils-to-setuptools.patch \
+            file://CVE-2023-26112.patch"
 
 inherit pypi setuptools3
#4 lore raw

PATCH 5/5 python3-flask: patch CVE-2023-30861

In reply to Gyorgy Sarvari

Details: https://nvd.nist.gov/vuln/detail/CVE-2023-30861

Pick the patch referenced by the NVD report.

---
 .../python/python3-flask/CVE-2023-30861.patch | 94 +++++++++++++++++++
 .../python/python3-flask_2.1.1.bb             |  1 +
 2 files changed, 95 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-flask/CVE-2023-30861.patch
meta-python/recipes-devtools/python/python3-flask/CVE-2023-30861.patch new file +94 -0
new file mode 100644
index 0000000000..370f17bb7f
@@ -0,0 +1,94 @@
+From 32cc429640d7307caa2075d15b0634fd886c6381 Mon Sep 17 00:00:00 2001
+From: David Lord <[email protected]>
+Date: Mon, 1 May 2023 08:01:32 -0700
+Subject: [PATCH] set `Vary: Cookie` header consistently for session
+
+CVE: CVE-2023-30861
+Upstream-Status: Backport [https://github.com/pallets/flask/commit/afd63b16170b7c047f5758eb910c416511e9c965]
+Signed-off-by: Gyorgy Sarvari <[email protected]>
+---
+ src/flask/sessions.py | 10 ++++++----
+ tests/test_basic.py   | 23 +++++++++++++++++++++++
+ 2 files changed, 29 insertions(+), 4 deletions(-)
+
+diff --git a/src/flask/sessions.py b/src/flask/sessions.py
+index 4e19270..039e30c 100644
+--- a/src/flask/sessions.py
++++ b/src/flask/sessions.py
+@@ -385,6 +385,10 @@ class SecureCookieSessionInterface(SessionInterface):
+         samesite = self.get_cookie_samesite(app)
+         httponly = self.get_cookie_httponly(app)
+ 
++        # Add a "Vary: Cookie" header if the session was accessed at all.
++        if session.accessed:
++            response.vary.add("Cookie")
++
+         # If the session is modified to be empty, remove the cookie.
+         # If the session is empty, return without setting the cookie.
+         if not session:
+@@ -397,13 +401,10 @@ class SecureCookieSessionInterface(SessionInterface):
+                     samesite=samesite,
+                     httponly=httponly,
+                 )
++                response.vary.add("Cookie")
+ 
+             return
+ 
+-        # Add a "Vary: Cookie" header if the session was accessed at all.
+-        if session.accessed:
+-            response.vary.add("Cookie")
+-
+         if not self.should_set_cookie(app, session):
+             return
+ 
+@@ -419,3 +420,4 @@ class SecureCookieSessionInterface(SessionInterface):
+             secure=secure,
+             samesite=samesite,
+         )
++        response.vary.add("Cookie")
+diff --git a/tests/test_basic.py b/tests/test_basic.py
+index 2a177e9..2da7699 100644
+--- a/tests/test_basic.py
++++ b/tests/test_basic.py
+@@ -558,6 +558,11 @@ def test_session_vary_cookie(app, client):
+     def setdefault():
+         return flask.session.setdefault("test", "default")
+ 
++    @app.route("/clear")
++    def clear():
++        flask.session.clear()
++        return ""
++
+     @app.route("/vary-cookie-header-set")
+     def vary_cookie_header_set():
+         response = flask.Response()
+@@ -590,11 +595,29 @@ def test_session_vary_cookie(app, client):
+     expect("/get")
+     expect("/getitem")
+     expect("/setdefault")
++    expect("/clear")
+     expect("/vary-cookie-header-set")
+     expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")
+     expect("/no-vary-header", None)
+ 
+ 
++def test_session_refresh_vary(app, client):
++    @app.get("/login")
++    def login():
++        flask.session["user_id"] = 1
++        flask.session.permanent = True
++        return ""
++
++    @app.get("/ignored")
++    def ignored():
++        return ""
++
++    rv = client.get("/login")
++    assert rv.headers["Vary"] == "Cookie"
++    rv = client.get("/ignored")
++    assert rv.headers["Vary"] == "Cookie"
++
++
+ def test_flashes(app, req_ctx):
+     assert not flask.session.modified
+     flask.flash("Zap")
meta-python/recipes-devtools/python/python3-flask_2.1.1.bb +1 -0
index 24a7047703..edf9f628d2 100644
@@ -6,6 +6,7 @@ HOMEPAGE = "https://github.com/mitsuhiko/flask/"
 LICENSE = "BSD-3-Clause"
 LIC_FILES_CHKSUM = "file://LICENSE.rst;md5=ffeffa59c90c9c4a033c7574f8f3fb75"
 
+SRC_URI += "file://CVE-2023-30861.patch"
 SRC_URI[sha256sum] = "a8c9bd3e558ec99646d177a9739c41df1ded0629480b4c8d2975412f3c9519c8"
 
 PYPI_PACKAGE = "Flask"