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.
The
dynparam
script processes unsanitized parameter input using a known unsafe function of the PyYaml library,yaml.load
.As explained in the library's documentation: "It is not safe to call yaml.load with any data received from an untrusted source! yaml.load is as powerful as pickle.load and so may call any Python function." This category of issue is also recognized as CWE-502: Deserialization of Untrusted Data.
This PR switches to using the
yaml.safe_load
alternative in thedo_set()
anddo_load()
functions. It includes a new test for thedynparam
script, which also serves as a proof-of-concept for the issue.The test in
test/test_dynparam.py
attempts to load a .yaml file with an insecure input that calls theos.system
module. You can verify that the same input will be executed successfully with the current code, in this case returning the contents of the local/etc/passwd
file. Theyaml.safe_load
function correctly blocks the insecure input.Signed-off by Florencia Cabral [email protected]