Skip to content

Commit b8f9a0a

Browse files
authored
This uses shlex for safe command parsing to fix arbitrary code injection
1 parent da60eae commit b8f9a0a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/paddle/utils/download.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import hashlib
1616
import os
1717
import os.path as osp
18+
import shlex
1819
import shutil
1920
import subprocess
2021
import sys
@@ -204,7 +205,8 @@ def _wget_download(url: str, fullname: str):
204205
'https',
205206
), 'Only support https and http url'
206207
# using wget to download url
207-
tmp_fullname = fullname + "_tmp"
208+
tmp_fullname = shlex.quote(fullname + "_tmp")
209+
url = shlex.quote(url)
208210
# –user-agent
209211
command = f'wget -O {tmp_fullname} -t {DOWNLOAD_RETRY_LIMIT} {url}'
210212
subprc = subprocess.Popen(

0 commit comments

Comments
 (0)