Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves security by switching from unsafe YAML loading to yaml.SafeLoader and adding or reordering check_trust_remote_code checks before loading configurations. The review feedback recommends using the more idiomatic and concise yaml.safe_load function instead of explicitly passing Loader=yaml.SafeLoader. Additionally, it is advised to call check_trust_remote_code at the very beginning of initialization methods to ensure no untrusted files are parsed beforehand.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Calling self.check_trust_remote_code(model_dir=model_dir) at the very beginning of __init__ (right after super().__init__) is safer and more robust. This ensures that any configuration loading (such as Config.from_file on line 42) or parameter parsing from the untrusted model directory is gated by the trust check, preventing potential exploitation of parser vulnerabilities or unnecessary processing of untrusted input.
| config = OmegaConf.load(os.path.join(model_dir, 'v1.yaml')) | ||
| self.check_trust_remote_code(model_dir=model_dir) |
There was a problem hiding this comment.
Calling self.check_trust_remote_code(model_dir=model_dir) before loading the configuration file (v1.yaml) via OmegaConf.load is safer. This ensures that no files from the untrusted model directory are parsed or loaded before verifying that the remote code/repository is trusted.
| config = OmegaConf.load(os.path.join(model_dir, 'v1.yaml')) | |
| self.check_trust_remote_code(model_dir=model_dir) | |
| self.check_trust_remote_code(model_dir=model_dir) | |
| config = OmegaConf.load(os.path.join(model_dir, 'v1.yaml')) |
| self.am_config = yaml.load(f, Loader=yaml.SafeLoader) | ||
| with open(self.voc_config_path, 'r') as f: | ||
| self.voc_config = yaml.load(f, Loader=yaml.Loader) | ||
| self.voc_config = yaml.load(f, Loader=yaml.SafeLoader) |
There was a problem hiding this comment.
Using yaml.safe_load(f) is more idiomatic, cleaner, and less verbose than yaml.load(f, Loader=yaml.SafeLoader) while providing the same security guarantees.
| self.am_config = yaml.load(f, Loader=yaml.SafeLoader) | |
| with open(self.voc_config_path, 'r') as f: | |
| self.voc_config = yaml.load(f, Loader=yaml.Loader) | |
| self.voc_config = yaml.load(f, Loader=yaml.SafeLoader) | |
| self.am_config = yaml.safe_load(f) | |
| with open(self.voc_config_path, 'r') as f: | |
| self.voc_config = yaml.safe_load(f) |
| config = yaml.load(f, Loader=yaml.SafeLoader) | ||
| with open(config_path, 'r') as f: | ||
| config.update(yaml.load(f, Loader=yaml.Loader)) | ||
| config.update(yaml.load(f, Loader=yaml.SafeLoader)) |
There was a problem hiding this comment.
Using yaml.safe_load(f) is more idiomatic, cleaner, and less verbose than yaml.load(f, Loader=yaml.SafeLoader) while providing the same security guarantees.
| config = yaml.load(f, Loader=yaml.SafeLoader) | |
| with open(config_path, 'r') as f: | |
| config.update(yaml.load(f, Loader=yaml.Loader)) | |
| config.update(yaml.load(f, Loader=yaml.SafeLoader)) | |
| config = yaml.safe_load(f) | |
| with open(config_path, 'r') as f: | |
| config.update(yaml.safe_load(f)) |
| config = yaml.load(f, Loader=yaml.SafeLoader) | ||
|
|
||
| with open(config_path, 'r') as f: | ||
| config.update(yaml.load(f, Loader=yaml.Loader)) | ||
| config.update(yaml.load(f, Loader=yaml.SafeLoader)) |
There was a problem hiding this comment.
Using yaml.safe_load(f) is more idiomatic, cleaner, and less verbose than yaml.load(f, Loader=yaml.SafeLoader) while providing the same security guarantees.
| config = yaml.load(f, Loader=yaml.SafeLoader) | |
| with open(config_path, 'r') as f: | |
| config.update(yaml.load(f, Loader=yaml.Loader)) | |
| config.update(yaml.load(f, Loader=yaml.SafeLoader)) | |
| config = yaml.safe_load(f) | |
| with open(config_path, 'r') as f: | |
| config.update(yaml.safe_load(f)) |
| os.PathLike]) -> Dict[str, Any]: | ||
| with open(yaml_file, 'r', encoding='utf-8') as reader: | ||
| config_dict = yaml.load(reader, Loader=yaml.Loader) | ||
| config_dict = yaml.load(reader, Loader=yaml.SafeLoader) |
There was a problem hiding this comment.
| os.PathLike]) -> Dict[str, Any]: | ||
| with open(yaml_file, 'r', encoding='utf-8') as reader: | ||
| config_dict = yaml.load(reader, Loader=yaml.Loader) | ||
| config_dict = yaml.load(reader, Loader=yaml.SafeLoader) |
There was a problem hiding this comment.
|
Thanks for tackling these — switching the For the record and to help with tracking: I independently reported these same sinks (the sambert TTS Could a maintainer link this PR to GHSA-7629-4rmx-r5c4 and publish the advisory (with a CVE) when it merges? I'm glad to help with the advisory metadata — the affected range should read |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |

Security: fix multiple RCE vectors in ModelScope
This PR fixes a cluster of remote-code-execution bugs where attacker-controlled
artifacts (model repo files) were fed unchecked to create_model, load_model_from_config,
or unsafe YAML loaders.
yaml.SafeLoaderrather than unsafeyaml.Loadercheck_trust_remote_code()beforeload_model_from_config.check_trust_remote_code()beforeload_model_from_config.check_trust_remote_code()beforecreate_model.