Skip to content

Security: Insecure YAML Deserialization via yaml.FullLoader#628

Open
bachdev wants to merge 2 commits intomicrosoft:mainfrom
bachdev:contribai/fix/security/insecure-yaml-deserialization-via-yaml-f
Open

Security: Insecure YAML Deserialization via yaml.FullLoader#628
bachdev wants to merge 2 commits intomicrosoft:mainfrom
bachdev:contribai/fix/security/insecure-yaml-deserialization-via-yaml-f

Conversation

@bachdev
Copy link
Copy Markdown

@bachdev bachdev commented Mar 31, 2026

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. 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.

Severity: critical
File: PW_FT_detection/main.py

Solution

Replace yaml.FullLoader with yaml.safe_load to 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

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

bachdev added 2 commits April 1, 2026 02:04
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>
Copilot AI review requested due to automatic review settings March 31, 2026 19:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) with yaml.safe_load in detection config loading.
  • Replace yaml.load(..., Loader=yaml.FullLoader) with yaml.safe_load in 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.

@bachdev
Copy link
Copy Markdown
Author

bachdev commented Apr 1, 2026

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants