Security: Unsafe YAML deserialization in RuleSet.load()#9416
Open
tuanaiseo wants to merge 1 commit into
Open
Conversation
…et.load() The `RuleSet.load()` method uses `yaml.safe_load()` which is safe, but the `JobSubmissionMetadata.load()` method also uses `yaml.safe_load()`. However, more critically, the `JobSubmissionMetadata.save()` method uses `yaml.dump()` with `model_dump(mode='json')` which could potentially serialize arbitrary objects if the model were compromised. The main concern is that `yaml.safe_load()` is properly used, but there's no validation of file integrity (hash/checksum) before loading, which could allow tampered YAML files to be loaded if an attacker can modify files on disk. Affected files: ruleset.py Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Contributor
PR title does not follow the required formatYour title must follow this pattern: Example titles:
Allowed types: Just edit your PR title above to fix this. The check will re-run automatically. See the PR guidelines for full details. |
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
RuleSet.load()method usesyaml.safe_load()which is safe, but theJobSubmissionMetadata.load()method also usesyaml.safe_load(). However, more critically, theJobSubmissionMetadata.save()method usesyaml.dump()withmodel_dump(mode='json')which could potentially serialize arbitrary objects if the model were compromised. The main concern is thatyaml.safe_load()is properly used, but there's no validation of file integrity (hash/checksum) before loading, which could allow tampered YAML files to be loaded if an attacker can modify files on disk.Severity:
mediumFile:
packages/syft-permissions/src/syft_permissions/spec/ruleset.pySolution
Add file integrity verification (hash/checksum) before loading YAML files, and consider adding a digital signature verification for permission files loaded from external sources.
Changes
packages/syft-permissions/src/syft_permissions/spec/ruleset.py(modified)Testing