Summary
pyLoad allows certain non-admin users to change the storage_folder configuration in a way that can redirect downloads into Flask's filesystem session store.
By planting a malicious pickle payload as a crafted session file and then triggering a request with the matching session cookie, an attacker can cause arbitrary code execution on the server.
Affected context
The vulnerability affects pyLoad deployments where:
- Flask's filesystem-based session store is in use and accessible on the server filesystem
- Non-admin users can obtain SETTINGS and ADD permissions
- The
storage_folderconfiguration is not treated as a strictly admin-only option
In these conditions, download paths can be redirected so that attacker-controlled files land inside the directory used for Flask session storage, where they may later be deserialized.
Exploit preconditions
- Attack surface: HTTP interface of pyLoad, including authenticated configuration endpoints and typical web requests that create or load sessions.
- Required access: An authenticated user account with SETTINGS and ADD permissions (but not necessarily full admin privileges).
- Trigger point: Flask's session loading mechanism, which deserializes session data (e.g., via pickle) from files mapped to session cookies.
- Why exploitation is possible: The
storage_folderoption is not enforced as admin-only and is insufficiently constrained, allowing a non-admin user to:
- Redirect downloads into the Flask session directory.
- Create a file with attacker-controlled pickle content that matches a predictable session filename.
- Induce Flask to load and deserialize that file when a request presents the corresponding session cookie.
Why this happens
The core issue combines unsafe deserialization (CWE-502) with missing or incorrect authorization (CWE-863).
On one side, the web framework's session subsystem relies on deserialization of session files (e.g., pickled Python objects), which is inherently dangerous when the backing storage can be influenced by an attacker. On the other side, the application's configuration model allows a non-admin user, granted certain capabilities (SETTINGS and ADD), to change a sensitive path (storage_folder) that determines where downloaded content is written.
This design creates a path-traversal-like control over a security-critical directory: the session store. Because session files are named and loaded in a predictable manner, an attacker can cause arbitrary, attacker-crafted serialized objects to be deserialized in a privileged context, leading directly to code execution. Conceptually, this reflects a pattern where user-controllable configuration influences the trust boundary of a deserialization sink that assumes only trusted data resides in its storage location.
Potential impact
- Execution of arbitrary Python code on the server hosting pyLoad
- Full compromise of the pyLoad process and its data, including download lists and stored credentials
- Use of the compromised server as a pivot point for further attacks within the hosting environment
- Modification or deletion of downloaded files and tampering with future downloads
- Unauthorized access to secrets, tokens, or configuration files accessible to the pyLoad process
General mitigation guidance
Effective mitigation focuses on tightening authorization around configuration and removing unsafe deserialization from the trust boundary:
- Treat any configuration option that influences security-sensitive paths (session directories, config directories, executable or script locations) as admin-only, regardless of historical defaults.
- Enforce strict validation on path-like settings:
- Restrict them to known-safe base directories within the application's data root.
- Disallow paths that resolve to framework internals or system directories (such as session stores or temporary execution paths).
- Avoid using general-purpose serialization mechanisms (e.g., Python pickle) for session or configuration data, especially where file-backed storage may be influenced indirectly by user actions.
- Apply least-privilege principles to the application runtime:
- Run pyLoad under a dedicated, minimal-privilege account.
- Limit writable directories for that account to only those needed for normal operation.
- Establish secure defaults: ensure that out-of-the-box configuration isolates user-controlled data from framework internals, especially session and cache directories.
How teams detect issues like this
Detection typically combines configuration review with code-level analysis:
- Static analysis / code review:
- Look for configuration options that control filesystem paths and are exposed to non-admin or partially privileged users.
- Identify usage of unsafe serialization/deserialization APIs (e.g., pickle) in session or configuration handling code.
- Verify that session storage locations cannot be influenced by user-controlled settings.
- Configuration audits:
- Periodically scan deployed instances to ensure that
storage_folderand similar options do not point to framework internals or shared system directories. - Check permission models to confirm that only admins can modify security-critical configuration keys.
- Runtime monitoring:
- Monitor for unusual file creation patterns within session directories (e.g., non-session-like file contents or rapid creation of large or binary files).
- Aggregate and alert on unexpected deserialization-related exceptions or errors that may indicate probing attempts.
- Automated security scanning tools can be configured with rules targeting unsafe deserialization sinks and privilege gaps in configuration endpoints to catch similar patterns across the codebase.

