Summary
A path traversal flaw in Saltcorn's offline synchronization endpoints allows unauthenticated attackers to create directories and write changes.json files to arbitrary filesystem locations on the server.
Combined with an information disclosure issue that exposes directory listings and JSON file contents, this can be abused to plant attacker-controlled data and probe the server's filesystem layout without valid credentials.
Affected context
The vulnerability occurs in Saltcorn deployments that expose the offline synchronization API endpoints:
POST /sync/offline_changesfor uploading offline changesGET /sync/upload_finishedfor acknowledging uploads
When path components derived from client input are used to construct filesystem locations without strict normalization and validation, the application may write files and enumerate directories outside the intended storage root.
This issue is relevant wherever the Saltcorn server is reachable over the network and these endpoints are accessible without authentication.
Exploit preconditions
- Attack surface: Publicly exposed HTTP(S) interface of the Saltcorn server.
- Required access: No authentication required; an attacker only needs network connectivity to the affected endpoints.
- Trigger point: Crafted requests to:
POST /sync/offline_changeswith attacker-controlled path elements and JSON payload.GET /sync/upload_finishedwith attacker-controlled path parameters.- Why exploitation is possible: User-supplied values are incorporated into filesystem paths without sufficient canonicalization, normalization, and restriction to a designated base directory. As a result, directory traversal constructs (e.g.,
../) or unexpected path segments can redirect file operations to arbitrary locations that the server process can access.
Why this happens
This issue stems from improper restriction of filesystem paths derived from client input, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
The application appears to trust client-provided identifiers or paths when creating directories and writing changes.json, as well as when listing directories and reading JSON files. Without robust checks to:
- Canonicalize paths,
- Enforce that resolved paths remain under a designated storage root,
- Reject traversal sequences and unsafe characters,
file operations can escape the intended sandbox. This abstract pattern—combining user-controlled path segments with filesystem APIs—creates both write and read primitives outside the expected directory tree.
Potential impact
- Attackers may create arbitrary directories on the server within any location writable by the Saltcorn process.
- Attackers can write attacker-controlled
changes.jsonfiles in arbitrary writable directories, potentially influencing application behavior that later parses these files. - Attackers can list directory contents via the upload completion endpoint, revealing filenames and structure of arbitrary directories.
- Attackers can read the contents of specific JSON files, which may expose configuration details, metadata, or other sensitive structured data.
- The arbitrary file write primitive may be chainable with other weaknesses (e.g., insecure file parsing or misconfigurations) to escalate impact, depending on the surrounding environment.
General mitigation guidance
Effective mitigation centers on tightening how filesystem paths are constructed and restricting the reachable filesystem surface:
- Normalize and canonicalize any path derived from client data before use, and verify that the resolved path remains inside a predefined, application-controlled base directory.
- Avoid using raw client-provided path segments; instead, map client identifiers (such as user IDs or sync session tokens) to internal directory names using server-side lookup tables or opaque IDs.
- Implement strict allowlists for acceptable characters and patterns in path-related parameters; reject input containing
.., path separators, or other traversal-related constructs. - Separate storage for user-supplied content from application code, configuration, and other sensitive areas to limit the blast radius of any file-write capability.
- Run the Saltcorn server under a dedicated, least-privileged account with minimal filesystem permissions to reduce the number of directories that can be written or read.
- Design offline sync mechanisms to treat incoming data as untrusted content, not as directives to manipulate arbitrary filesystem locations.
How teams detect issues like this
Detection often involves combining static analysis of the codebase with runtime monitoring:
- Static analysis and code review:
- Search for filesystem operations (e.g.,
fs.mkdir,fs.writeFile, directory listing, and file read APIs) that incorporate HTTP request parameters or body fields into paths. - Flag code where user input is concatenated with directory paths without a canonicalization and base-path check.
- Review sync-related controllers or middleware handling offline synchronization for assumptions about trusted path formats.
- Runtime monitoring and logging:
- Log all sync-related requests with normalized paths and flag usage of suspicious patterns such as
../, URL-encoded traversal sequences, or unexpected absolute paths. - Monitor for abnormal directory creation patterns outside known storage roots.
- Use host-based intrusion detection or file integrity monitoring to detect unauthorized directory creation and changes to sensitive directories.
- Policy enforcement:
- Enforce secure coding guidelines that disallow direct use of user-controllable data in filesystem paths without explicit validation utilities.
- Integrate automated security scanning tools in CI to catch common path traversal patterns.

