Summary
A path traversal flaw in the Jupyter Server REST API allows authenticated users to escape the configured root_dir and access sibling directories whose names share the same prefix as the root directory.
By crafting encoded paths to the /api/contents endpoint, an attacker can read, write, and delete files in other users' directories in multi-tenant or shared deployments.
Affected context
This vulnerability affects Jupyter Server deployments that:
- Use the /api/contents REST API for file operations
- Rely on root_dir to isolate user or tenant workspaces
- Have sibling directories that share a common prefix with the configured root_dir
It is particularly relevant in multi-tenant environments where per-user directories follow predictable naming schemes (e.g., user1, user10, user11) and where authenticated users are expected to be confined to their own directory subtree.
Exploit preconditions
- Attack surface: Jupyter Server REST API endpoint
/api/contents - Required access: Valid authenticated access to Jupyter Server with permission to use the contents API
- Deployment assumptions: The server is configured with a
root_dirintended to restrict each user to a specific directory subtree, and sibling directories exist that share a prefix with that root directory name - Trigger point: Submission of a crafted request to
/api/contentsusing encoded path components that exploit traversal logic and prefix-matching behavior - Why exploitation is possible: The input path normalization and validation logic insufficiently constrains resolved paths to the configured
root_dir, allowing traversal into sibling directories whose names begin with the same prefix, despite directory isolation expectations.
Why this happens
The underlying issue stems from incorrect canonicalization and validation of file system paths that are derived from user-controlled input.
Instead of strictly enforcing that all resolved paths remain within the configured root_dir, the implementation relies on logic that can be bypassed when sibling directories share a common prefix with root_dir.
This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where path traversal is possible because the application does not robustly verify that normalized paths do not escape the intended directory boundary.
Encoded path components and prefix-based checks combine to create a situation where users confined to one directory can interact with files located in other, similarly named sibling directories.
Potential impact
- Unauthorized reading of files in sibling directories that share a prefix with the configured root_dir
- Unauthorized modification or overwriting of files belonging to other users or tenants
- Deletion of critical or user-owned data in neighboring directories
- Breach of data isolation guarantees in multi-tenant Jupyter environments
- Potential exposure of configuration files or secrets stored in affected sibling directories, depending on deployment layout
General mitigation guidance
Mitigation typically focuses on enforcing strict directory boundaries and hardening path handling:
- Implement robust canonicalization of all user-supplied paths and verify that the final, normalized path resides strictly within the configured root_dir (e.g., by comparing absolute paths rather than relying on string prefixes).
- Avoid prefix-based directory isolation; instead, treat root_dir as an absolute boundary and reject any requests that resolve outside of it.
- Use per-tenant or per-user directory layouts that do not rely solely on predictable, prefix-based naming schemes; consider hierarchical structures that naturally segregate tenants.
- Reduce filesystem privileges for the Jupyter Server process so it only has access to directories that are legitimately needed for each instance.
- Apply defense-in-depth by separating tenants at the operating-system or container level, limiting the impact of any path validation flaw in a single server instance.
How teams detect issues like this
Detection can leverage both code-centric and operational approaches:
- Static analysis: Look for file operations in the Jupyter Server codebase (or similar systems) where user-controlled paths are joined with a base directory using string operations or incomplete normalization checks; flag locations that do not verify that the resolved path remains within the intended root.
- Code review signals: Pay attention to any logic that relies on prefix matching, partial string comparison, or manual path concatenation for directory isolation; ensure reviewers verify correct use of canonicalized absolute paths.
- Runtime monitoring: Instrument logging around the
/api/contentsendpoint to record requested paths and the final resolved filesystem paths; alert on accesses that target directories outside expected user roots or that follow unusual encoded patterns. - Policy enforcement: Integrate security linting and configuration checks into CI/CD pipelines to ensure new code paths respect directory boundaries and that deployments do not co-locate unrelated tenants in sibling directories with overlapping name prefixes.
- Automated review tools can complement manual review by flagging dangerous path-handling patterns and missing path boundary checks.

