SQL injection - Code In pyload-ng
Description
PyLoad vulnerable to SQL Injection via API /json/add_package in add_links parameter
Summary
The parameter add_links in the API /json/add_package is vulnerable to SQL Injection. SQL injection vulnerabilities can lead to sensitive data leakage.
Details
Affected file:https://github.com/pyload/pyload/blob/develop/src/pyload/core/database/file_database.py#L271
Affected code:
@style.queue def update_link_info(self, data): """ data is list of tuples (name, size, status, url) """ self.c.executemany( "UPDATE links SET name=?, size=?, status=? WHERE url=? AND status IN (1,2,3,14)", data,...
statuses is constructed from data, and data is the value of the add_links parameter entered by the user through /json/add_packge. Because {statuses} is directly spliced into the SQL statement, it leads to the SQL injection vulnerability.
Vulnerability Chain
josn_blueprint.py#add_package src/pyload/core/api/__init__.py#add_package src/pyload/core/managers/file_manager.py#add_links src/pyload/core/threads/info_thread.py#run src/pyload/core/threads/info_thread.py#update_info src/pyload/core/managers/file_manager.py#update_file_info src/pyload/core/database/file_database.py#update_link_info
PoC
import requests if __name__ == "__main__": url = "http://localhost:8000/json/add_package" data = { "add_name": "My Downloads1", "add_dest": "0",...
Remediation
def update_link_info(self, data): """ data is list of tuples (name, size, status, url) """ self.c.executemany( "UPDATE links SET name=?, size=?, status=? WHERE url=? AND status IN (1,2,3,14)", data, )...
Impact
Attackers can modify or delete data in the database, causing data errors or loss.
Mitigation
Update Impact
Minimal update. May introduce new vulnerabilities or breaking changes.
Ecosystem | Package | Affected version | Patched versions |
|---|---|---|---|
pypi | 0.5.0b3.dev91 |
Aliases
References