security code fix -RCE#1
Open
R-Sudharshan wants to merge 1 commit intotaxmeifyoucan:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: Security Vulnerability: Unrestricted File Extension leading to Potential Remote Code Execution (RCE) via Malicious Source Data
Description: While reviewing the download implementation in mkbsd.js and mkbsd.py, I discovered that the scripts determine the file extension by directly extracting it from the remote image URL provided by the JSON data API.
If an attacker were able to manipulate the source JSON data—via a Man-in-the-Middle (MitM) attack, DNS hijacking, or a backend compromise—they could replace the image URLs with links to malicious executable files (e.g., .exe, .bat, .sh). The script will happily download these and save them with the executable extension intact (e.g., 1.bat). Since the user specifically runs this script to download media files they intend to open and view, inadvertently clicking on a downloaded executable leads to high-risk Remote Code Execution.
Steps to Reproduce (Local PoC):
Set up a local HTTP server hosting a JSON payload with a .bat file link: "dhd": "http://127.0.0.1:8000/malware.bat"
Point the url variable in mkbsd.py to this local JSON file.
Run the script. The folder is populated with 1.bat instead of standard image formats.
Impact: High. If the data source API is compromised, attackers can distribute malware disguised as numeric wallpapers to all users running this script.
Suggested Fix: Enforce strict validation on the downloaded extensions. Validate the inferred extension against a whitelist of expected media extensions (e.g., ['.jpg', '.jpeg', '.png', '.webp']). If an unexpected extension is found, the script should skip the file or abort.
Example for Python:
python
ALLOWED_EXTS = {'.jpg', '.png', '.jpeg', '.webp'}
ext = os.path.splitext(parsed_url.path)[-1].lower()
if ext not in ALLOWED_EXTS:
print(f"Skipping potentially unsafe file extension: {ext}")
continue
filename = f"{file_index}{ext}"
Note: Also the api url has expired it seems..check on it too !!