Skip to content

Security: Unsafe YAML Loading in postprocess_toc_yml.py#2058

Open
tomaioo wants to merge 1 commit into
MicrosoftDocs:mainfrom
tomaioo:fix/security/unsafe-yaml-loading-in-postprocess-toc-y
Open

Security: Unsafe YAML Loading in postprocess_toc_yml.py#2058
tomaioo wants to merge 1 commit into
MicrosoftDocs:mainfrom
tomaioo:fix/security/unsafe-yaml-loading-in-postprocess-toc-y

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Security: Unsafe YAML Loading in postprocess_toc_yml.py

Problem

Severity: Critical | File: ci_scripts/postprocess_toc_yml.py:L28

The code uses yaml.load() without specifying a Loader parameter, which defaults to the unsafe Loader. This can lead to arbitrary code execution if an attacker can control the contents of toc.yml. The yaml.load() function is known to be vulnerable to deserialization attacks when used without a safe loader.

Solution

Use yaml.safe_load() instead of yaml.load(), or explicitly pass Loader=yaml.SafeLoader to yaml.load(). For example: data_loaded = yaml.safe_load(stream) or data_loaded = yaml.load(stream, Loader=yaml.SafeLoader)

Changes

  • ci_scripts/postprocess_toc_yml.py (modified)

The code uses yaml.load() without specifying a Loader parameter, which defaults to the unsafe Loader. This can lead to arbitrary code execution if an attacker can control the contents of toc.yml. The yaml.load() function is known to be vulnerable to deserialization attacks when used without a safe loader.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 7e2f788:

✅ Validation status: passed

File Status Preview URL Details
ci_scripts/postprocess_toc_yml.py ✅Succeeded

For more details, please refer to the build report.

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.

1 participant