Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces unsafe yaml loaders with yaml.safe_load #3753

Merged
merged 4 commits into from Jun 17, 2022
Merged

Conversation

zythosec
Copy link
Contributor

@zythosec zythosec commented Jun 7, 2022

Fixes WB-9909

Description

What does the PR do?

FullLoader and Loader should not be used on untrusted data. While it can be argued that the config file can be "trusted" data, this PR replaces unsafe yaml.full_load and yaml.load with yaml.safe_load to eliminate the possibility of a malicious config file being run causing arbitrary code execution.

Testing

How was this PR tested?

make test

Checklist

  • Include reference to internal ticket "Fixes WB-NNNN" (and github issue "Fixes #NNNN" if applicable)

@zythosec zythosec requested review from raubitsj and vanpelt June 7, 2022 23:13
@@ -1014,11 +1014,7 @@ def image_from_docker_args(args: List[str]) -> Optional[str]:


def load_yaml(file: Any) -> Any:
"""If pyyaml > 5.1 use full_load to avoid warning"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Open question: what warning was this? And do we actually use the functionality of full_load?

Copy link
Member

Choose a reason for hiding this comment

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

It must have been a deprecation warning like shown here yaml/pyyaml#265

@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #3753 (9ab415e) into master (c682bb6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3753      +/-   ##
==========================================
+ Coverage   81.83%   81.84%   +0.01%     
==========================================
  Files         241      241              
  Lines       29771    29769       -2     
==========================================
+ Hits        24362    24364       +2     
+ Misses       5409     5405       -4     
Flag Coverage Δ
functest 57.41% <100.00%> (+0.01%) ⬆️
unittest 72.09% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
wandb/util.py 85.74% <100.00%> (+0.08%) ⬆️
wandb/sdk/service/server_sock.py 91.87% <0.00%> (-2.04%) ⬇️
wandb/sdk/lib/sock_client.py 92.50% <0.00%> (-1.67%) ⬇️
wandb/sdk/internal/stats.py 65.92% <0.00%> (-0.56%) ⬇️
wandb/sdk/lib/git.py 76.19% <0.00%> (ø)
wandb/sdk/wandb_run.py 89.50% <0.00%> (+0.25%) ⬆️
wandb/filesync/step_prepare.py 94.80% <0.00%> (+1.29%) ⬆️
wandb/sdk/internal/meta.py 90.06% <0.00%> (+3.10%) ⬆️

@zythosec zythosec requested review from dmitryduev and a team June 8, 2022 12:59
@@ -1014,11 +1014,7 @@ def image_from_docker_args(args: List[str]) -> Optional[str]:


def load_yaml(file: Any) -> Any:
"""If pyyaml > 5.1 use full_load to avoid warning"""
Copy link
Member

Choose a reason for hiding this comment

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

It must have been a deprecation warning like shown here yaml/pyyaml#265

@dmitryduev dmitryduev merged commit 3ad618a into master Jun 17, 2022
@dmitryduev dmitryduev deleted the fix/yaml-load branch June 17, 2022 19:58
@kptkin kptkin changed the title [WB-9909] Replaces unsafe yaml loaders with yaml.safe_load Replace unsafe yaml loaders with yaml.safe_load Jun 30, 2022
@kptkin kptkin added this to the sdk-2022-07.1 milestone Jun 30, 2022
@kptkin kptkin changed the title Replace unsafe yaml loaders with yaml.safe_load Replaces unsafe yaml loaders with yaml.safe_load Jul 2, 2022
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.

None yet

3 participants