Skip to content

Commit

Permalink
Use safe_load() instead of insecure load()
Browse files Browse the repository at this point in the history
Replace yaml.load() by yaml.safe_load(). In PyYAML before 5.1,
the yaml.load() API could execute arbitrary code
if used with untrusted data (CVE-2017-18342).

Signed-off-by: Juergen Leopold <leopoldj@de.ibm.com>
  • Loading branch information
leopoldjuergen committed Aug 20, 2019
1 parent 8e78cc6 commit 6ff498a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Released: xxxx-xx-xx

**Bug fixes:**
- Avoid exception in case of a connection drop error handling.
- Replace yaml.load() by yaml.safe_load(). In PyYAML before 5.1,
the yaml.load() API could execute arbitrary code if used with untrusted data
(CVE-2017-18342).

**Known issues:** See the `list of open issues`_.

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PyYAML>=3.13 # MIT
PyYAML>=5.1 # MIT
zhmcclient>=0.19.0 # Apache-2.0
prometheus-client>=0.3.1 # Apache-2.0
2 changes: 1 addition & 1 deletion zhmc_prometheus_exporter/zhmc_prometheus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parse_yaml_file(yamlfile):
"""
try:
with open(yamlfile, "r") as yamlcontent:
return yaml.load(yamlcontent)
return yaml.safe_load(yamlcontent)
except PermissionError:
raise PermissionError("Permission error. Make sure you have "
"appropriate permissions to read from %s."
Expand Down

0 comments on commit 6ff498a

Please sign in to comment.