Security: Insecure YAML Deserialization via yaml.FullLoader#628
Open
bachdev wants to merge 2 commits intomicrosoft:mainfrom
Open
Security: Insecure YAML Deserialization via yaml.FullLoader#628bachdev wants to merge 2 commits intomicrosoft:mainfrom
yaml.FullLoader#628bachdev wants to merge 2 commits intomicrosoft:mainfrom
Conversation
The application uses `yaml.load(f, Loader=yaml.FullLoader)` to parse a configuration file (`config`) whose path can be controlled by a command-line argument. While `FullLoader` is safer than the default `yaml.load` without a specified loader, it still allows the construction of arbitrary Python objects. If an attacker can provide a specially crafted malicious YAML file, this can lead to arbitrary code execution on the system where the application is run. This is a severe vulnerability as it allows an attacker to execute arbitrary code with the privileges of the running application. Affected files: main.py, main.py Signed-off-by: BachDEV <1437214+bachdev@users.noreply.github.com>
The application uses `yaml.load(f, Loader=yaml.FullLoader)` to parse a configuration file (`config`) whose path can be controlled by a command-line argument. While `FullLoader` is safer than the default `yaml.load` without a specified loader, it still allows the construction of arbitrary Python objects. If an attacker can provide a specially crafted malicious YAML file, this can lead to arbitrary code execution on the system where the application is run. This is a severe vulnerability as it allows an attacker to execute arbitrary code with the privileges of the running application. Affected files: main.py, main.py Signed-off-by: BachDEV <1437214+bachdev@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates a critical RCE risk by switching YAML configuration parsing in the fine-tuning entrypoints from yaml.load(..., Loader=yaml.FullLoader) to yaml.safe_load, ensuring only basic YAML types are deserialized.
Changes:
- Replace
yaml.load(..., Loader=yaml.FullLoader)withyaml.safe_loadin detection config loading. - Replace
yaml.load(..., Loader=yaml.FullLoader)withyaml.safe_loadin classification config loading.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
PW_FT_detection/main.py |
Loads the user-provided config via yaml.safe_load to prevent unsafe object construction. |
PW_FT_classification/main.py |
Loads the CLI-provided config via yaml.safe_load to prevent unsafe object construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The application uses
yaml.load(f, Loader=yaml.FullLoader)to parse a configuration file (config) whose path can be controlled by a command-line argument. WhileFullLoaderis safer than the defaultyaml.loadwithout a specified loader, it still allows the construction of arbitrary Python objects. If an attacker can provide a specially crafted malicious YAML file, this can lead to arbitrary code execution on the system where the application is run. This is a severe vulnerability as it allows an attacker to execute arbitrary code with the privileges of the running application.Severity:
criticalFile:
PW_FT_detection/main.pySolution
Replace
yaml.FullLoaderwithyaml.safe_loadto restrict YAML parsing to basic Python types, preventing the deserialization of potentially malicious objects.Changes
PW_FT_detection/main.py(modified)PW_FT_classification/main.py(modified)Testing