b10-msgpack-numpy 0.4.8__tar.gz → 0.4.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/CHANGES.md +10 -0
- {b10_msgpack_numpy-0.4.8/b10_msgpack_numpy.egg-info → b10_msgpack_numpy-0.4.8.1}/PKG-INFO +1 -1
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1/b10_msgpack_numpy.egg-info}/PKG-INFO +1 -1
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/msgpack_numpy.py +9 -1
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/setup.py +1 -1
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/tests.py +30 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/AUTHORS.md +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/LICENSE.md +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/README.md +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/SOURCES.txt +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/dependency_links.txt +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/requires.txt +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/top_level.txt +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/pyproject.toml +0 -0
- {b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/setup.cfg +0 -0
|
@@ -5,6 +5,16 @@ vi:ft=markdown
|
|
|
5
5
|
Change Log
|
|
6
6
|
==========
|
|
7
7
|
|
|
8
|
+
Release 0.4.8.1 (Baseten fork, November 2026)
|
|
9
|
+
---------------------------------------------
|
|
10
|
+
* SECURITY: ``decode`` now raises ``ValueError`` for an ndarray payload whose
|
|
11
|
+
dtype holds Python objects under any kind other than ``O`` (for example
|
|
12
|
+
``type: "|O"`` with ``kind: "f"``, or a structured dtype with an object
|
|
13
|
+
field). These built the array directly over the payload bytes and read
|
|
14
|
+
them as object pointers, which crashes the process. Structured arrays with
|
|
15
|
+
object fields can no longer be round-tripped; their encoded bytes were
|
|
16
|
+
only valid within the encoding process.
|
|
17
|
+
|
|
8
18
|
Release 0.4.8 (Baseten fork, November 2026)
|
|
9
19
|
-------------------------------------------
|
|
10
20
|
* SECURITY (CWE-502): object-dtype ndarrays are no longer unpickled by
|
|
@@ -125,8 +125,16 @@ def decode(obj, chain=None, allow_pickle=False):
|
|
|
125
125
|
return pickle.loads(obj[b'data'])
|
|
126
126
|
else:
|
|
127
127
|
descr = obj[b'type']
|
|
128
|
+
|
|
129
|
+
# Object fields in a raw buffer would be read as object
|
|
130
|
+
# pointers. np.frombuffer refuses this; np.ndarray does not.
|
|
131
|
+
dtype = _unpack_dtype(descr)
|
|
132
|
+
if dtype.hasobject:
|
|
133
|
+
raise ValueError(
|
|
134
|
+
'cannot create an OBJECT array from memory buffer')
|
|
135
|
+
|
|
128
136
|
return np.ndarray(buffer=obj[b'data'],
|
|
129
|
-
dtype=
|
|
137
|
+
dtype=dtype,
|
|
130
138
|
shape=obj[b'shape'])
|
|
131
139
|
else:
|
|
132
140
|
descr = obj[b'type']
|
|
@@ -238,6 +238,36 @@ class test_numpy_msgpack(TestCase):
|
|
|
238
238
|
msgpack.unpackb(payload, allow_pickle=True)
|
|
239
239
|
self.assertEqual(EXECUTED, [True])
|
|
240
240
|
|
|
241
|
+
def test_object_dtype_raw_buffer_rejected(self):
|
|
242
|
+
# Hostile payloads naming an object dtype under a kind other than
|
|
243
|
+
# "O", which would read the raw data bytes as object pointers.
|
|
244
|
+
types_by_kind = [
|
|
245
|
+
(b'f', b'|O'),
|
|
246
|
+
(None, b'|O'),
|
|
247
|
+
(b'', 'object'),
|
|
248
|
+
(b'', 'O8'),
|
|
249
|
+
(b'', '(2,)O'),
|
|
250
|
+
(b'V', [(b'a', b'|O')]),
|
|
251
|
+
(b'V', [(b'a', [('b', '|O')])]),
|
|
252
|
+
(b'', 'i4,O'),
|
|
253
|
+
]
|
|
254
|
+
for kind, dtype_type in types_by_kind:
|
|
255
|
+
obj = {b'nd': True, b'type': dtype_type, b'shape': (2,),
|
|
256
|
+
b'data': b'\x41' * 64}
|
|
257
|
+
if kind is not None:
|
|
258
|
+
obj[b'kind'] = kind
|
|
259
|
+
payload = msgpack.packb(obj)
|
|
260
|
+
for allow_pickle in (False, True):
|
|
261
|
+
with self.assertRaisesRegex(ValueError, 'OBJECT array'):
|
|
262
|
+
msgpack.unpackb(payload, allow_pickle=allow_pickle)
|
|
263
|
+
|
|
264
|
+
def test_structured_array_with_object_field_rejected(self):
|
|
265
|
+
# The encoder writes these as raw object pointers, so they can't be
|
|
266
|
+
# decoded safely.
|
|
267
|
+
x = np.array([(1, 'a')], dtype=[('n', '<i4'), ('o', 'O')])
|
|
268
|
+
with self.assertRaisesRegex(ValueError, 'OBJECT array'):
|
|
269
|
+
msgpack.unpackb(msgpack.packb(x))
|
|
270
|
+
|
|
241
271
|
def test_numpy_array_complex(self):
|
|
242
272
|
x = (np.random.rand(5)+1j*np.random.rand(5)).astype(np.complex128)
|
|
243
273
|
x_rec = self.encode_decode(x)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/requires.txt
RENAMED
|
File without changes
|
{b10_msgpack_numpy-0.4.8 → b10_msgpack_numpy-0.4.8.1}/b10_msgpack_numpy.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|