/

CVE-2026-40163

Severity:

HIGH RISK

(8.2)

Path Traversal / Insecure File System Access in Saltcorn

CVE-2026-40163

Analyzed

Vulnerability type

Category:

Path Traversal / Insecure File System Access

CWE:

CWE-22

Impact:

Arbitrary File Write and Information Disclosure

Severity:

HIGH RISK

(8.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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_changes for uploading offline changes
  • GET /sync/upload_finished for 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_changes with attacker-controlled path elements and JSON payload.
  • GET /sync/upload_finished with 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.json files 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.

Sources

SourceLink
github.comgithub.com/saltcorn/saltcorn/security/advisories/GHSA-32pv-mpqg-h292

Frequently asked

questions

The vulnerability is broadly exploitable anywhere the affected Saltcorn endpoints are exposed over the network without additional access controls. An attacker does not need valid credentials; they only need to reach the sync endpoints and craft specific requests.

No. The described behavior is triggered by unauthenticated requests to /sync/offline_changes and /sync/upload_finished. Any party capable of sending HTTP requests to these endpoints can attempt exploitation, subject to any external network protections in place.

The most robust fix pattern is to strictly decouple client input from filesystem paths. Use canonicalization and enforce that all file operations resolve inside a dedicated storage root directory, reject any traversal or disallowed characters, and map client identifiers to server-controlled names instead of trusting client-supplied paths directly.

Prevention relies on consistently treating path-related inputs as untrusted and applying a layered approach:

  • Establish reusable utilities for secure path handling and require their use in code review.
  • Document and enforce guidelines that no raw client input may be concatenated into filesystem paths.
  • Combine static analysis, secure code review checklists, and runtime logging to catch path traversal patterns early in development and testing.
Find out what's already
exploitable in your codebase.