Skip to content

Commit 8b7a12c

Browse files
Replace eval() with ast.literal_eval() for security (#12212)
Co-authored-by: Carlos Mocholi <[email protected]>
1 parent 91052dc commit 8b7a12c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
663663

664664
- Fixed an issue where `HorovodStrategy.teardown()` did not complete gracefully if an exception was thrown during callback setup [#11752](https://github.com/PyTorchLightning/pytorch-lightning/pull/11752)
665665

666+
666667
- Fixed security vulnerabilities CVE-2020-1747 and CVE-2020-14343 caused by the `PyYAML` dependency ([#11099](https://github.com/PyTorchLightning/pytorch-lightning/pull/11099))
667668

668669

670+
- Fixed security vulnerability "CWE-94: Improper Control of Generation of Code (Code Injection)" ([#12212](https://github.com/PyTorchLightning/pytorch-lightning/pull/12212))
671+
672+
669673
- Fixed logging on `{test,validation}_epoch_end` with multiple dataloaders ([#11132](https://github.com/PyTorchLightning/pytorch-lightning/pull/11132))
670674

671675

pytorch_lightning/utilities/argparse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
from abc import ABC
1919
from argparse import _ArgumentGroup, ArgumentParser, Namespace
20+
from ast import literal_eval
2021
from contextlib import suppress
2122
from functools import wraps
2223
from typing import Any, Callable, cast, Dict, List, Tuple, Type, TypeVar, Union
@@ -121,7 +122,7 @@ def parse_env_variables(cls: Type["pl.Trainer"], template: str = "PL_%(cls_name)
121122
# todo: specify the possible exception
122123
with suppress(Exception):
123124
# converting to native types like int/float/bool
124-
val = eval(val)
125+
val = literal_eval(val)
125126
env_args[arg_name] = val
126127
return Namespace(**env_args)
127128

0 commit comments

Comments
 (0)