summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python
diff options
context:
space:
mode:
authorJon Mason <jon.mason@arm.com>2026-04-13 10:23:41 -0400
committerGyorgy Sarvari <skandigraun@gmail.com>2026-04-13 16:30:11 +0200
commit66bb701b2e3fcc261a21c00051721fd99380c1ed (patch)
treee6819690c215db15b6c10173b60e9c975a3bee45 /meta-python/recipes-devtools/python
parentb11accc51ba6ac16c91eddd346cfec067e7a2663 (diff)
downloadmeta-openembedded-66bb701b2e3fcc261a21c00051721fd99380c1ed.tar.gz
python3-cbor2: Fix CVE-2025-68131 CVE patch error
The patch for CVE-2025-68131 does not actually match https://github.com/agronholm/cbor2/commit/f1d701cd2c411ee40bb1fe383afe7f365f35abf0 Specifically, the indenting in decode_from_bytes This is causing an error in trusted-firmware-m of | Traceback (most recent call last): | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/git/tfm/bl2/ext/mcuboot/scripts/wrapper/wrapper.py", line 21, in <module> | import imgtool.main | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/git/mcuboot/scripts/imgtool/main.py", line 25, in <module> | from imgtool import image, imgtool_version | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/git/mcuboot/scripts/imgtool/image.py", line 24, in <module> | from .boot_record import create_sw_component_data | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/git/mcuboot/scripts/imgtool/boot_record.py", line 21, in <module> | from cbor2 import dumps | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/recipe-sysroot-native/usr/lib/python3.10/site-packages/cbor2/__init__.py", line 1, in <module> | from .decoder import load, loads, CBORDecoder # noqa | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/recipe-sysroot-native/usr/lib/python3.10/site-packages/cbor2/decoder.py", line 215 | with BytesIO(buf) as fp: | ^ | IndentationError: expected an indented block after 'with' statement on line 214 Indenting to match the original patch fixes this. Also, because this version of cbor2 is older, it doesn't include commit 53e21063ed1d72ac8f911044dd598a7f9ef72406, which adds 'Any' to encode.py Because that is missing, we see the following error: | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/recipe-sysroot-native/usr/lib/python3.10/site-packages/cbor2/__init__.py", line 2, in <module> | from .encoder import dump, dumps, CBOREncoder, shareable_encoder # noqa | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/recipe-sysroot-native/usr/lib/python3.10/site-packages/cbor2/encoder.py", line 68, in <module> | class CBOREncoder: | File "/builder/meta-arm/build/tmp/work/corstone1000_fvp-poky-linux-musl/trusted-firmware-m/1.5.0+gitAUTOINC+f8c7e5361b-r0/recipe-sysroot-native/usr/lib/python3.10/site-packages/cbor2/encoder.py", line 266, in CBOREncoder | def _encode_value(self, obj: Any) -> None: To get around this issue, remove the "Any" from the encoder.py. The logic behind this (instead of importing typing) is that this is the only instance, and since this is not something that will be updated frequently with patches from upstream. Signed-off-by: Jon Mason <jon.mason@arm.com> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python')
-rw-r--r--meta-python/recipes-devtools/python/python3-cbor2/CVE-2025-68131.patch43
1 files changed, 28 insertions, 15 deletions
diff --git a/meta-python/recipes-devtools/python/python3-cbor2/CVE-2025-68131.patch b/meta-python/recipes-devtools/python/python3-cbor2/CVE-2025-68131.patch
index 4c5310edfa..8556c5bdbc 100644
--- a/meta-python/recipes-devtools/python/python3-cbor2/CVE-2025-68131.patch
+++ b/meta-python/recipes-devtools/python/python3-cbor2/CVE-2025-68131.patch
@@ -21,18 +21,18 @@ CVE: CVE-2025-68131
21Upstream-Status: Backport [https://github.com/agronholm/cbor2/commit/f1d701cd2c411ee40bb1fe383afe7f365f35abf0] 21Upstream-Status: Backport [https://github.com/agronholm/cbor2/commit/f1d701cd2c411ee40bb1fe383afe7f365f35abf0]
22Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com> 22Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
23--- 23---
24 cbor2/decoder.py | 26 ++++++++++++++-- 24 cbor2/decoder.py | 38 +++++++++++++++++++-----
25 cbor2/encoder.py | 42 +++++++++++++++++++++----- 25 cbor2/encoder.py | 43 ++++++++++++++++++++++-----
26 source/decoder.c | 28 +++++++++++++++++- 26 source/decoder.c | 28 +++++++++++++++++-
27 source/decoder.h | 1 + 27 source/decoder.h | 1 +
28 source/encoder.c | 23 +++++++++++++-- 28 source/encoder.c | 23 +++++++++++++--
29 source/encoder.h | 1 + 29 source/encoder.h | 1 +
30 tests/test_decoder.py | 62 ++++++++++++++++++++++++++++++++++++++ 30 tests/test_decoder.py | 62 ++++++++++++++++++++++++++++++++++++++
31 tests/test_encoder.py | 69 +++++++++++++++++++++++++++++++++++++++++++ 31 tests/test_encoder.py | 69 +++++++++++++++++++++++++++++++++++++++++++
32 8 files changed, 239 insertions(+), 13 deletions(-) 32 8 files changed, 246 insertions(+), 19 deletions(-)
33 33
34diff --git a/cbor2/decoder.py b/cbor2/decoder.py 34diff --git a/cbor2/decoder.py b/cbor2/decoder.py
35index be7198b..f2d818c 100644 35index be7198b..6cdd752 100644
36--- a/cbor2/decoder.py 36--- a/cbor2/decoder.py
37+++ b/cbor2/decoder.py 37+++ b/cbor2/decoder.py
38@@ -2,6 +2,7 @@ import re 38@@ -2,6 +2,7 @@ import re
@@ -94,16 +94,28 @@ index be7198b..f2d818c 100644
94 94
95 def decode_from_bytes(self, buf): 95 def decode_from_bytes(self, buf):
96 """ 96 """
97@@ -190,6 +211,7 @@ class CBORDecoder: 97@@ -190,12 +211,13 @@ class CBORDecoder:
98 object needs to be decoded separately from the rest but while still 98 object needs to be decoded separately from the rest but while still
99 taking advantage of the shared value registry. 99 taking advantage of the shared value registry.
100 """ 100 """
101- with BytesIO(buf) as fp:
102- old_fp = self.fp
103- self.fp = fp
104- retval = self._decode()
105- self.fp = old_fp
106- return retval
101+ with self._decoding_context(): 107+ with self._decoding_context():
102 with BytesIO(buf) as fp: 108+ with BytesIO(buf) as fp:
103 old_fp = self.fp 109+ old_fp = self.fp
104 self.fp = fp 110+ self.fp = fp
111+ retval = self._decode()
112+ self.fp = old_fp
113+ return retval
114
115 def _decode_length(self, subtype, allow_indefinite=False):
116 if subtype < 24:
105diff --git a/cbor2/encoder.py b/cbor2/encoder.py 117diff --git a/cbor2/encoder.py b/cbor2/encoder.py
106index 42526c0..0a5722d 100644 118index 42526c0..fc22458 100644
107--- a/cbor2/encoder.py 119--- a/cbor2/encoder.py
108+++ b/cbor2/encoder.py 120+++ b/cbor2/encoder.py
109@@ -109,7 +109,7 @@ class CBOREncoder: 121@@ -109,7 +109,7 @@ class CBOREncoder:
@@ -147,13 +159,14 @@ index 42526c0..0a5722d 100644
147 def encode(self, obj): 159 def encode(self, obj):
148 """ 160 """
149 Encode the given object using CBOR. 161 Encode the given object using CBOR.
150@@ -243,6 +261,14 @@ class CBOREncoder: 162@@ -243,6 +261,15 @@ class CBOREncoder:
151 :param obj: 163 :param obj:
152 the object to encode 164 the object to encode
153 """ 165 """
154+ with self._encoding_context(): 166+ with self._encoding_context():
155+ self._encode_value(obj) 167+ self._encode_value(obj)
156+ def _encode_value(self, obj: Any) -> None: 168+
169+ def _encode_value(self, obj) -> None:
157+ """ 170+ """
158+ Internal fast path for encoding - used by built-in encoders. 171+ Internal fast path for encoding - used by built-in encoders.
159+ External code should use encode() instead, which properly manages 172+ External code should use encode() instead, which properly manages
@@ -162,7 +175,7 @@ index 42526c0..0a5722d 100644
162 obj_type = obj.__class__ 175 obj_type = obj.__class__
163 encoder = ( 176 encoder = (
164 self._encoders.get(obj_type) or 177 self._encoders.get(obj_type) or
165@@ -390,14 +416,14 @@ class CBOREncoder: 178@@ -390,14 +417,14 @@ class CBOREncoder:
166 def encode_array(self, value): 179 def encode_array(self, value):
167 self.encode_length(4, len(value)) 180 self.encode_length(4, len(value))
168 for item in value: 181 for item in value:
@@ -180,7 +193,7 @@ index 42526c0..0a5722d 100644
180 193
181 def encode_sortable_key(self, value): 194 def encode_sortable_key(self, value):
182 """ 195 """
183@@ -422,10 +448,10 @@ class CBOREncoder: 196@@ -422,10 +449,10 @@ class CBOREncoder:
184 # String referencing requires that the order encoded is 197 # String referencing requires that the order encoded is
185 # the same as the order emitted so string references are 198 # the same as the order emitted so string references are
186 # generated after an order is determined 199 # generated after an order is determined
@@ -193,7 +206,7 @@ index 42526c0..0a5722d 100644
193 206
194 def encode_semantic(self, value): 207 def encode_semantic(self, value):
195 # Nested string reference domains are distinct 208 # Nested string reference domains are distinct
196@@ -436,7 +462,7 @@ class CBOREncoder: 209@@ -436,7 +463,7 @@ class CBOREncoder:
197 self._string_references = {} 210 self._string_references = {}
198 211
199 self.encode_length(6, value.tag) 212 self.encode_length(6, value.tag)
@@ -202,7 +215,7 @@ index 42526c0..0a5722d 100644
202 215
203 self.string_referencing = old_string_referencing 216 self.string_referencing = old_string_referencing
204 self._string_references = old_string_references 217 self._string_references = old_string_references
205@@ -489,7 +515,7 @@ class CBOREncoder: 218@@ -489,7 +516,7 @@ class CBOREncoder:
206 def encode_stringref(self, value): 219 def encode_stringref(self, value):
207 # Semantic tag 25 220 # Semantic tag 25
208 if not self._stringref(value): 221 if not self._stringref(value):