Summary
Mesop versions 1.2.2 and below contain a path traversal vulnerability in the file-based runtime backend that allows untrusted state_token values from UI stream payloads to target arbitrary files on disk.
Under the FileStateSessionBackend, an attacker can abuse crafted tokens to cause denial of service through crash loops or manipulate and delete backend files outside normal application bounds.
Affected context
This vulnerability occurs in deployments of Mesop that use the standard file-based runtime backend, specifically the FileStateSessionBackend for storing UI state and session data.
The issue manifests when state_token values supplied via UI stream payloads are used to construct filesystem paths without sufficiently constraining or normalizing the resulting path.
Systems that expose Mesop applications to untrusted or semi-trusted users, such as public-facing web apps or multi-tenant dashboards, are particularly at risk because any such user can supply arbitrary tokens.
Exploit preconditions
- Attack surface: HTTP/UI stream interface where clients can submit or influence
state_tokenvalues as part of the payload. - Required access: Ability to interact with the Mesop web application (no direct filesystem or shell access required); in many deployments this means any remote user with network access to the app.
- Trigger point: Backend logic that maps the
state_tokento a file path on disk and then reads, writes, or deletes the correlated file for session or configuration handling. - Why exploitation is possible: The backend treats
state_tokenas a trusted filesystem identifier without restricting it to a safe directory, validating allowed patterns, or preventing directory traversal sequences (e.g.,../) and other crafted path components.
Why this happens
The underlying bug is a classic path traversal problem where untrusted input is used to build filesystem paths that the application then operates on.
Instead of constraining file operations to a fixed directory and a controlled filename schema, the FileStateSessionBackend uses user-influenced state_token values directly or with insufficient normalization, enabling the computed path to escape the intended storage directory.
This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where the absence of robust canonicalization and validation allows attackers to reach or manipulate files outside the authorized scope.
Potential impact
- Application denial of service by forcing repeated attempts to parse non-msgpack files as configuration or state, leading to crash loops or persistent failures.
- Overwriting of critical state or configuration files used by the backend, potentially altering application behavior or corrupting session data.
- Deletion of files relied upon by the service, causing data loss or unexpected runtime errors.
- Manipulation of files that, while outside the intended application storage directory, are reachable by the process and can be targeted by the constructed paths.
- Escalation of impact in multi-tenant environments, where one tenant can interfere with another tenant's state or resources stored on disk.
General mitigation guidance
Effective mitigation focuses on strictly confining file operations derived from user input and treating all external identifiers as untrusted.
Recommended defensive patterns include:
- Directory confinement: Ensure all paths derived from
state_tokenare resolved against a fixed, application-controlled root directory, rejecting any path that escapes this root after canonicalization. - Input validation and normalization: Enforce a strict, documented format for
state_token(e.g., UUIDs or opaque tokens) and disallow path separators, traversal sequences, or any characters not explicitly required. - Use of indirect identifiers: Store state using generated, opaque IDs that map to files via a server-side lookup table rather than deriving filenames directly from client-provided values.
- Least-privilege filesystem access: Run the Mesop process under an account with access only to the directories it genuinely needs, reducing the blast radius if traversal is attempted.
- Robust error handling: Handle file parsing and read errors gracefully to prevent crash loops, converting unexpected file formats into controlled failures instead of repeated restart cycles.
How teams detect issues like this
Organizations can detect and monitor for this class of issue using a combination of static and dynamic approaches:
- Static analysis: Configure rules or linters to flag string concatenation or interpolation operations that combine user-sourced values (like
state_token) with filesystem paths, especially when used in open/read/write/delete calls. - Code review heuristics: During reviews, scrutinize any code that:
- Builds paths from request parameters or UI payloads,
- Accesses session/state files,
- Performs file operations without explicit whitelisting or canonicalization.
- Runtime logging and monitoring: Log resolved file paths and unexpected file access errors in the backend, and alert on patterns such as
../in tokens or repeated attempts to access non-existent or invalid files. - Policy enforcement: Integrate security checks into CI/CD pipelines to enforce safe file-access patterns, including mandatory use of helper APIs that encapsulate path canonicalization and directory confinement.

