Use yaml.safe_* instaed of yaml.load / yaml.dump / … #39531
Labels
Bug
broken, incorrect, or confusing behavior
Core
relates to code central or existential to Salt
fixed-pls-verify
fix is linked, bug author to confirm fix
P1
Priority 1
severity-high
2nd top severity, seen by most users, causes major problems
Milestone
Description of Issue/Question
yaml.load
andyaml.dump
allow arbitrary code execution when processing YAML files. I don’t think this is intended. I would propose to change those occurrences to the safe variants. Is the feature provided by the unsafe variants even used?The first fix iteration should be quite easy. Just run
git ls-files -z "$(git rev-parse --show-toplevel)" | xargs --null -I '{}' find '{}' -type f -print0 | xargs --null sed --in-place --regexp-extended 's/(yaml\.)(dump|load)\b/\1safe_\2/g;'
in each git repo which might use the pyyaml package.Note that this might not catch all occurrences. Maybe add a Python linting check for those functions?
Related to: ansible/ansible#21724
Setup
https://www.qubes-os.org/doc/salt/
Steps to Reproduce Issue
Run
ag
'(yaml\.)(dump|load)\b'
in the git repo.Expected Results
No output and exit code 1 confirming no matches where found.
Actual Results
Versions Report
develop
The text was updated successfully, but these errors were encountered: