GHSA-59xv-588h-2vmm: @saltcorn/data SQL Injection Vulnerability

LOW
CVSS 0.0
CWE-89
Published
Advisory Summary

GHSA-59xv-588h-2vmm is a LOW (CVSS 0.0) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting @saltcorn/data libraries in the npm ecosystem. The issue involves @saltcorn/data vulnerable to sql injection via jsexprtosql literal handler. Remediation is available by upgrading affected packages to version 1.4.5, 1.5.5, 1.6.0-beta.4.

GHSA-59xv-588h-2vmm at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-59xv-588h-2vmm
Severity LOW
CVSS v3.1 Base Score 0.0
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product @saltcorn/data
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 0.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-59xv-588h-2vmm

To remediate this vulnerability, upgrade all affected @saltcorn/data dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@saltcorn/data fixed: 1.4.5
npm install @saltcorn/data@1.4.5
@saltcorn/data fixed: 1.5.5
npm install @saltcorn/data@1.5.5
@saltcorn/data fixed: 1.6.0-beta.4
npm install @saltcorn/data@1.6.0-beta.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @saltcorn/data

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-59xv-588h-2vmm, inspect your project dependencies using npm:

npm ls @saltcorn/data

Analyze the terminal output to locate any version of @saltcorn/data in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.5), your application is affected.

Note: The npm ls @saltcorn/data command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In @saltcorn/data, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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="1194" height="559" alt="SCR-20260307-edqn" src="https://github.com/user-attachments/assets/a2d11102-f49b-4b2b-88ff-fced37476b6f" /> 2. Go to the table and then to `Constraits` <img width="1180" height="600" alt="SCR-20260307-edsg" src="https://github.com/user-attachments/assets/b55ddace-01be-4a53-8f62-cbec98172cd7" /> 3. Go to `Formula` <img width="1130" height="518" alt="SCR-20260307-edud" src="https://github.com/user-attachments/assets/8a5addc6-e681-401b-91ea-bce3b0eece54" /> 4. Create a test table for verification <img width="857" height="294" alt="SCR-20260307-eetw" src="https://github.com/user-attachments/assets/debc8581-8145-44cb-a684-2bc3eb7adbcf" /> 5. Input the payload and save <img width="763" height="383" alt="SCR-20260307-ehcz" src="https://github.com/user-attachments/assets/f7a3aa34-7b0b-48ea-b1df-f852f137c37f" /> 6. Check the table for testing <img width="549" height="256" alt="SCR-20260307-ehuh" src="https://github.com/user-attachments/assets/8f6da842-0275-4729-93bf-96575f3fe963" /> ## 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: ```typescript 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.

GHSA-59xv-588h-2vmm Affected @saltcorn/data Versions

3 component(s)
Fixed Versions:
1.4.51.5.51.6.0-beta.4
Product / Package Ecosystem Affected Versions Fixed Version
@saltcorn/data
npm
< 1.4.5
1.4.5
@saltcorn/data
npm
≥ 1.5.0
< 1.5.5
1.5.5
@saltcorn/data
npm
≥ 1.6.0-alpha.0
< 1.6.0-beta.4
1.6.0-beta.4

References

Frequently Asked Questions

What is GHSA-59xv-588h-2vmm?
GHSA-59xv-588h-2vmm is a security vulnerability in @saltcorn/data involving @saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which @saltcorn/data versions are affected?
Affected versions include releases prior to 1.4.5, 1.5.5, 1.6.0-beta.4 across affected packages: @saltcorn/data.
What version fixes GHSA-59xv-588h-2vmm?
Upgrading to 1.4.5, 1.5.5, 1.6.0-beta.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @saltcorn/data affected?
Yes, @saltcorn/data is affected in releases prior to 1.4.5, 1.5.5, 1.6.0-beta.4. Upgrade your dependency to 1.4.5, 1.5.5, 1.6.0-beta.4 or later.
What is the CVSS score of GHSA-59xv-588h-2vmm?
GHSA-59xv-588h-2vmm has a CVSS v3.1 base score of 0.0 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N.
What CWE is associated with GHSA-59xv-588h-2vmm?
GHSA-59xv-588h-2vmm is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check npm dependencies for GHSA-59xv-588h-2vmm?
Run the dependency tree command: 'npm ls @saltcorn/data'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-59xv-588h-2vmm",
  "modified" : "2026-04-10T19:30:32Z",
  "published" : "2026-04-10T19:30:32Z",
  "aliases" : [ ],
  "summary" : "@saltcorn/data vulnerable to SQL Injection via jsexprToSQL Literal Handler",
  "details" : "## Summary\n\nThe `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.\n\n\n## Vulnerable Component\n\n**File:** `packages/saltcorn-data/models/expression.ts`, lines 117-118\n\n```typescript\nLiteral({ value }: { value: ExtendedNode }) {\n  if (typeof value == \"string\") return `'${value}'`;  // NO ESCAPING!\n  return `${value}`;\n},\n```\n\n**Call chain:** Formula constraint creation → `table_constraints.ts:127` → `jsexprToSQL()` → `Literal()` → `db.query()` executes unsanitized SQL.\n\n## Proof of Concept\n\n### Injection via Formula Constraint\n\nWhen an admin creates a Formula-type table constraint with the expression:\n\n```javascript\nname === \"test' OR '1'='1\"\n```\n\nThe `jsexprToSQL()` function generates:\n\n```sql\n(name)=('test' OR '1'='1')\n```\n\nThis is then executed as:\n\n```sql\nALTER TABLE \"tablename\" ADD CONSTRAINT \"tablename_fml_1\" CHECK ((name)=('test' OR '1'='1'));\n```\n\nThe single quote in the string literal is not escaped, breaking out of the SQL string context.\n\n### More Dangerous Payload\n\n```javascript\nname === \"'; DROP TABLE users; --\"\n```\n\nGenerates:\n\n```sql\n(name)=(''; DROP TABLE users; --')\n```\n\n### Verified on Saltcorn v1.5.0 (Docker)\n\nDirect invocation of `jsexprToSQL()` inside the running container confirms the vulnerability:\n\n```\nInput:  name === \"hello\"\nOutput: (name)=('hello')                          ← Normal\n\nInput:  name === \"test' OR '1'='1\"\nOutput: (name)=('test' OR '1'='1')                ← Single quote NOT escaped, OR injected\n\nInput:  name === \"'; DROP TABLE users; --\"\nOutput: (name)=(''; DROP TABLE users; --')         ← DROP TABLE injected\n```\n\nThe test was performed on a completely fresh Saltcorn installation (zero user-created tables, default Docker setup).\n\n### PoC Screenshot\n\n1. Create a table after moving to the table menu\n\n<img width=\"1194\" height=\"559\" alt=\"SCR-20260307-edqn\" src=\"https://github.com/user-attachments/assets/a2d11102-f49b-4b2b-88ff-fced37476b6f\" />\n\n\n2. Go to the table and then to `Constraits`\n\n<img width=\"1180\" height=\"600\" alt=\"SCR-20260307-edsg\" src=\"https://github.com/user-attachments/assets/b55ddace-01be-4a53-8f62-cbec98172cd7\" />\n\n3. Go to `Formula`\n\n<img width=\"1130\" height=\"518\" alt=\"SCR-20260307-edud\" src=\"https://github.com/user-attachments/assets/8a5addc6-e681-401b-91ea-bce3b0eece54\" />\n\n4. Create a test table for verification\n\n<img width=\"857\" height=\"294\" alt=\"SCR-20260307-eetw\" src=\"https://github.com/user-attachments/assets/debc8581-8145-44cb-a684-2bc3eb7adbcf\" />\n\n5. Input the payload and save\n\n<img width=\"763\" height=\"383\" alt=\"SCR-20260307-ehcz\" src=\"https://github.com/user-attachments/assets/f7a3aa34-7b0b-48ea-b1df-f852f137c37f\" />\n\n6. Check the table for testing\n\n<img width=\"549\" height=\"256\" alt=\"SCR-20260307-ehuh\" src=\"https://github.com/user-attachments/assets/8f6da842-0275-4729-93bf-96575f3fe963\" />\n\n\n\n## Impact\n\n- Arbitrary SQL execution via crafted CHECK constraints\n- Data exfiltration through error-based or time-based SQL injection\n- Database schema manipulation (DROP TABLE, ALTER TABLE)\n- Potential privilege escalation via direct `users` table modification\n\n## Suggested Remediation\n\nEscape single quotes in the `Literal` handler:\n\n```typescript\nLiteral({ value }: { value: ExtendedNode }) {\n  if (typeof value == \"string\") return `'${value.replace(/'/g, \"''\")}'`;\n  return `${value}`;\n},\n```\n\nAlternatively, use parameterized queries for constraint creation instead of string interpolation.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@saltcorn/data"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@saltcorn/data"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.5.0"
      }, {
        "fixed" : "1.5.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@saltcorn/data"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.6.0-alpha.0"
      }, {
        "fixed" : "1.6.0-beta.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/saltcorn/saltcorn/security/advisories/GHSA-59xv-588h-2vmm"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/saltcorn/saltcorn"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-10T19:30:32Z",
    "nvd_published_at" : null
  }
}