Impact
Type of vulnerability : Remote Code Execution (RCE)
Who is impacted : Any user interacting with archive extraction, password prompts, or video uploads in the affected versions.
Users could exploit unsanitized inputs to inject malicious commands that are executed through subprocess.Popen
with shell=True
. This vulnerability allows arbitrary command execution, potentially compromising the system.
Examples
How could this vulnerability be exploited ?
-
Exploitation via malformed archive name :
An user could craft an archive with a maliciously formatted name. For instance :
File"; rm -fr / --no-preserve-root; ".zip
When extracted (or even tested before extraction), this triggers command execution :
7z t -p"test" "/app/Downloaded/123/File"; rm -fr / --no-preserve-root; ".zip" -y
-
Exploitation via malformed password input :
An user could provide a malicious password string during the bot's password prompt. For example :
password"; rm -fr / --no-preserve-root;"
This would execute the injected command :
7z x -o"/app/Downloaded/123/extracted" -p"password"; rm -fr / --no-preserve-root;"" "/app/Downloaded/123/file.7z" -y
-
Exploitation via malformed video name :
A malicious archive could contain a video file with a specially crafted name. For example :
video"; rm -fr / --no-preserve-root;".mp4
This would result in command execution during thumbnail generation or before, when retrieving the video duration :
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "/app/Downloaded/123/extracted/video"; rm -fr / --no-preserve-root;".mp4"
Patches
Is the issue resolved ? What versions contain the fix ?
The vulnerability was addressed in multiple updates. The final and complete fix was implemented on 1st December 2024.
Patch timeline :
- 14th February 2022 (14268d0) : The bug is present since the first version of the bot.
- 16th August 2022 (ca8382a) : Partial fix addressing spaces in passwords; RCE persisted.
- 15th May 2024 (0aebff1) : Addressed issues with spaces in paths; RCE persisted.
- 1st December 2024 (2c5aba2) : Comprehensive fix using
shlex.quote()
to sanitize inputs.
- 1st December 2024 (5213b69) : Final working version of the fix.
Workarounds
Users of the main bot have no issues since this fix was deployed.
Temporary mitigation steps for fork owners :
They need to upgrade either by :
- Deploying the
v7
branch (on Heroku for instance)
- Pulling the code on their bot (by running the commands
/exec git pull && git switch v7
and /restart
)
- By pulling the
7.0.3a
tag (if they use a local Docker instance)
References
For more details, refer to :
Impact
Type of vulnerability : Remote Code Execution (RCE)
Who is impacted : Any user interacting with archive extraction, password prompts, or video uploads in the affected versions.
Users could exploit unsanitized inputs to inject malicious commands that are executed through
subprocess.Popen
withshell=True
. This vulnerability allows arbitrary command execution, potentially compromising the system.Examples
How could this vulnerability be exploited ?
Exploitation via malformed archive name :
An user could craft an archive with a maliciously formatted name. For instance :
When extracted (or even tested before extraction), this triggers command execution :
Exploitation via malformed password input :
An user could provide a malicious password string during the bot's password prompt. For example :
This would execute the injected command :
Exploitation via malformed video name :
A malicious archive could contain a video file with a specially crafted name. For example :
This would result in command execution during thumbnail generation or before, when retrieving the video duration :
Patches
Is the issue resolved ? What versions contain the fix ?
The vulnerability was addressed in multiple updates. The final and complete fix was implemented on 1st December 2024.
Patch timeline :
shlex.quote()
to sanitize inputs.Workarounds
Users of the main bot have no issues since this fix was deployed.
Temporary mitigation steps for fork owners :
They need to upgrade either by :
v7
branch (on Heroku for instance)/exec git pull && git switch v7
and/restart
)7.0.3a
tag (if they use a local Docker instance)References
For more details, refer to :