mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 00:25:08 +00:00
[core] Prevent RCE when using --exec
with %q
(CVE-2023-40581)
The shell escape function is now using `""` instead of `\"`. `utils.Popen` has been patched to properly quote commands. Prior to this fix using `--exec` together with `%q` when on Windows could cause remote code to execute. See https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg for reference. Authored by: Grub4K
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
import subprocess
|
||||
|
||||
from .common import PostProcessor
|
||||
from ..compat import compat_shlex_quote
|
||||
from ..utils import PostProcessingError, encodeArgument, variadic
|
||||
from ..utils import Popen, PostProcessingError, variadic
|
||||
|
||||
|
||||
class ExecPP(PostProcessor):
|
||||
@ -27,10 +25,10 @@ class ExecPP(PostProcessor):
|
||||
def run(self, info):
|
||||
for tmpl in self.exec_cmd:
|
||||
cmd = self.parse_cmd(tmpl, info)
|
||||
self.to_screen('Executing command: %s' % cmd)
|
||||
retCode = subprocess.call(encodeArgument(cmd), shell=True)
|
||||
if retCode != 0:
|
||||
raise PostProcessingError('Command returned error code %d' % retCode)
|
||||
self.to_screen(f'Executing command: {cmd}')
|
||||
_, _, return_code = Popen.run(cmd, shell=True)
|
||||
if return_code != 0:
|
||||
raise PostProcessingError(f'Command returned error code {return_code}')
|
||||
return [], info
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user