Summary
pyLoad's set_package_data() API failed to sanitize the _folder field, allowing users with modification permissions to specify arbitrary filesystem paths as download targets.
Under these conditions, a malicious or compromised user account can direct downloads into sensitive or unintended directories, potentially overwriting or planting files in security-critical locations.
Affected context
This vulnerability appears in pyLoad deployments that:
- Expose or integrate the set_package_data() API, and
- Allow users with Perms.MODIFY to control or update package metadata, including
_folder.
The issue is relevant when the download server runs with access to directories beyond a confined, application-specific data area. It is most impactful when the pyLoad process has permissions to write into system directories, shared storage, or other applications' data locations.
Exploit preconditions
- Attack surface: Application API layer (programmatic access to set_package_data()).
- Required access: An authenticated account or API token with at least
Perms.MODIFY. - Trigger point: Passing a crafted value in the
_folderkey within the data object to set_package_data(), causing pyLoad to use that path as the download destination. - Why exploitation is possible: The
_folderparameter is used directly as a filesystem path without normalization, restriction to an allowed base directory, or checks against path traversal and absolute paths, enabling writes outside intended download areas.
Why this happens
The underlying bug stems from unvalidated, user-controlled filesystem paths being used to construct download destinations.
In the set_package_data() API, the _folder key is treated as a trusted directory path and passed to the filesystem layer without:
- Normalizing or canonicalizing the path,
- Enforcing a fixed base directory,
- Rejecting absolute paths or
..segments.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') and is closely related to CWE-36: Absolute Path Traversal, because an attacker can specify arbitrary absolute or traversal-based locations.
Potential impact
- File downloads may be written into arbitrary directories accessible by the pyLoad process.
- Attackers can plant or overwrite files in configuration directories, logs, or shared application data.
- System integrity may be degraded if critical files (e.g., scripts, service configs) are overwritten where permissions allow.
- Other applications or services may be influenced by tampered files (e.g., altered configuration leading to unsafe behavior).
- Privacy and data segregation guarantees can be undermined by writing into other users' or tenants' directories.
General mitigation guidance
Effective mitigation focuses on constraining and validating download paths:
- Treat all user-controlled path components (including
_folder) as untrusted data and never use them directly as absolute paths. - Enforce a strict, application-controlled base directory for all downloads, and resolve paths relative to this sandbox only.
- Normalize and canonicalize paths before use, and reject any that escape the allowed root via
..or symlink-based traversal. - Block absolute paths and paths containing prohibited characters or patterns, according to the deployment platform.
- Apply least-privilege principles to the pyLoad process so it can write only to designated data directories, not to system or application code locations.
- Design APIs such that clients select from predefined storage locations or IDs rather than supplying raw filesystem paths.
How teams detect issues like this
To detect this class of issue and its potential abuse:
- Use static analysis or code scanning tools to flag direct use of user-controlled values in filesystem APIs (e.g., open, mkdir, os.path.join) without path canonicalization and boundary checks.
- During code review, look for:
- API parameters that represent directories or filenames,
- Lack of validation or normalization on those parameters,
- Absence of enforced base-directory constraints.
- Implement server-side logging of requested download directories and periodically review for suspicious paths (absolute references,
/etc,/var,../, or other atypical locations). - Introduce defensive runtime checks or assertions around path resolution to prevent future regressions, and monitor test suites for coverage of path edge cases.

