Summary
Two unauthenticated path traversal vulnerabilities exist in Saltcorn's mobile sync endpoints. The POST /sync/offline_changes endpoint allows an unauthenticated attacker to create arbitrary directories and write a changes.json file with attacker-controlled JSON content anywhere on the server filesystem. The GET /sync/upload_finished endpoint allows an unauthenticated attacker to list arbitrary directory contents and read specific JSON files.
The safe path validation function File.normalise_in_base() exists in the codebase and is correctly used by the clean_sync_dir endpoint in the same file (fix for GHSA-43f3-h63w-p6f6), but was not applied to these two endpoints.
Details
Finding 1: Arbitrary file write, POST /sync/offline_changes (sync.js line 226)
The newSyncTimestamp parameter from the request body is used directly in path.join() without sanitization:
const syncDirName = `${newSyncTimestamp}_${req.user?.email || "public"}`;
const syncDir = path.join(
rootFolder.location, "mobile_app", "sync", syncDirName
);
await fs.mkdir(syncDir, { recursive: true }); // creates arbitrary dir
await fs.writeFile(
path.join(syncDir, "changes.json"),
JSON.stringify(changes) // writes attacker content
);
No authentication middleware is applied to this route. Since path.join() normalizes ../ sequences, setting newSyncTimestamp to ../../../../tmp/evil causes the path to resolve outside the sync directory.
Finding 2: Arbitrary directory read, GET /sync/upload_finished (sync.js line 288)
The dir_name query parameter is used directly in path.join() without sanitization:
const syncDir = path.join(
rootFolder.location, "mobile_app", "sync", dir_name
);
let entries = await fs.readdir(syncDir);
Also unauthenticated. An attacker can list directory contents and read files named translated-ids.json, unique-conflicts.json, data-conflicts.json, or error.json from any directory.
Contrast, fixed endpoint in the same file (line 342):
The clean_sync_dir endpoint correctly uses File.normalise_in_base():
const syncDir = File.normalise_in_base(
path.join(rootFolder.location, "mobile_app", "sync"),
dir_name
);
if (syncDir) await fs.rm(syncDir, { recursive: true, force: true });
PoC
# Write arbitrary file to /tmp/
curl -X POST http://TARGET:3000/sync/offline_changes \
-H "Content-Type: application/json" \
-d '{
"newSyncTimestamp": "../../../../tmp/saltcorn_poc",
"oldSyncTimestamp": "0",
"changes": {"proof": "path_traversal_write"}
}'
# Result: /tmp/saltcorn_poc_public/changes.json created with attacker content
# List /etc/ directory
curl "http://TARGET:3000/sync/upload_finished?dir_name=../../../../etc"
Impact
- Unauthenticated arbitrary directory creation anywhere on the filesystem
- Unauthenticated arbitrary JSON file write (
changes.json) to any writable directory - Unauthenticated directory listing of arbitrary directories
- Unauthenticated read of specific JSON files from arbitrary directories
- Potential for remote code execution via writing to sensitive paths (cron, systemd, Node.js module paths)
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
CVE-2026-40163 has a CVSS score of 8.2 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.4.5, 1.5.5, 1.6.0-beta.4); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Apply File.normalise_in_base() to both endpoints, matching the existing pattern in clean_sync_dir:
// offline_changes fix
const syncDirName = `${newSyncTimestamp}_${req.user?.email || "public"}`;
const syncDir = File.normalise_in_base(
path.join(rootFolder.location, "mobile_app", "sync"),
syncDirName
);
if (!syncDir) {
return res.status(400).json({ error: "Invalid sync directory name" });
}
// upload_finished fix
const syncDir = File.normalise_in_base(
path.join(rootFolder.location, "mobile_app", "sync"),
dir_name
);
if (!syncDir) {
return res.json({ finished: false });
}
Additionally, add loggedIn middleware to endpoints that modify server state.
Frequently Asked Questions
- What is CVE-2026-40163? CVE-2026-40163 is a high-severity path traversal vulnerability in @saltcorn/server (npm), affecting versions < 1.4.5. It is fixed in 1.4.5, 1.5.5, 1.6.0-beta.4. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- How severe is CVE-2026-40163? CVE-2026-40163 has a CVSS score of 8.2 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of @saltcorn/server are affected by CVE-2026-40163? @saltcorn/server (npm) versions < 1.4.5 is affected.
- Is there a fix for CVE-2026-40163? Yes. CVE-2026-40163 is fixed in 1.4.5, 1.5.5, 1.6.0-beta.4. Upgrade to this version or later.
- Is CVE-2026-40163 exploitable, and should I be worried? Whether CVE-2026-40163 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-40163 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-40163?
- Upgrade
@saltcorn/serverto 1.4.5 or later - Upgrade
@saltcorn/serverto 1.5.5 or later - Upgrade
@saltcorn/serverto 1.6.0-beta.4 or later
- Upgrade