@saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler
Summary
The jsexprToSQL() function in Saltcorn converts JavaScript expressions to SQL for use in database constraints. The Literal handler wraps string values in single quotes without escaping embedded single quotes, allowing SQL injection when creating Formula-type table constraints.
Vulnerable Component
File: packages/saltcorn-data/models/expression.ts, lines 117-118
Literal({ value }: { value: ExtendedNode }) {
if (typeof value == "string") return `'${value}'`; // NO ESCAPING!
return `${value}`;
},
Call chain: Formula constraint creation → table_constraints.ts:127 → jsexprToSQL() → Literal() → db.query() executes unsanitized SQL.
Proof of Concept
Injection via Formula Constraint
When an admin creates a Formula-type table constraint with the expression:
name === "test' OR '1'='1"
The jsexprToSQL() function generates:
(name)=('test' OR '1'='1')
This is then executed as:
ALTER TABLE "tablename" ADD CONSTRAINT "tablename_fml_1" CHECK ((name)=('test' OR '1'='1'));
The single quote in the string literal is not escaped, breaking out of the SQL string context.
More Dangerous Payload
name === "'; DROP TABLE users; --"
Generates:
(name)=(''; DROP TABLE users; --')
Verified on Saltcorn v1.5.0 (Docker)
Direct invocation of jsexprToSQL() inside the running container confirms the vulnerability:
Input: name === "hello"
Output: (name)=('hello') ← Normal
Input: name === "test' OR '1'='1"
Output: (name)=('test' OR '1'='1') ← Single quote NOT escaped, OR injected
Input: name === "'; DROP TABLE users; --"
Output: (name)=(''; DROP TABLE users; --') ← DROP TABLE injected
The test was performed on a completely fresh Saltcorn installation (zero user-created tables, default Docker setup).
PoC Screenshot
- Create a table after moving to the table menu
- Go to the table and then to
Constraits
- Go to
Formula
- Create a test table for verification
- Input the payload and save
- Check the table for testing
Impact
- Arbitrary SQL execution via crafted CHECK constraints
- Data exfiltration through error-based or time-based SQL injection
- Database schema manipulation (DROP TABLE, ALTER TABLE)
- Potential privilege escalation via direct
userstable modification
Suggested Remediation
Escape single quotes in the Literal handler:
Literal({ value }: { value: ExtendedNode }) {
if (typeof value == "string") return `'${value.replace(/'/g, "''")}'`;
return `${value}`;
},
Alternatively, use parameterized queries for constraint creation instead of string interpolation.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | @saltcorn/data | < 1.4.5, >= 1.5.0, < 1.5.5, >= 1.6.0-alpha.0, < 1.6.0-beta.4 | 1.4.5, 1.5.5, 1.6.0-beta.4 |
References
- CVSS vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N- Weakness (CWE)
CWE-89- Platform
- npm
- Package
@saltcorn/data- Disclosed
- 10.04.2026
- Updated
- 11.10.2026 10:22
Sources and licenses
OSV / GitHub Advisory Database - GHSA-59xv-588h-2vmm - CC BY 4.0
Vulnerability history: @saltcorn/data
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 2
- First → latest
- 04.2026 04.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 1
- Low 1
Disclosures per year
- 2026: 2
-
@saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.