Skip to content

SQL Injection on v <=1.16.7

Critical
FelixMalfait published GHSA-jgx4-6mr9-9573 May 17, 2026

Package

TwentyCRM

Affected versions

<=1.16.7

Patched versions

1.16.7

Description

Description

Summary

A critical Remote Code Execution (RCE) vulnerability exists in Twenty CRM v1.7.7 through v1.16.7 via a chained SQL Injection and PostgreSQL COPY TO PROGRAM attack. If Postgres user is a super user then any authenticated user can execute arbitrary OS commands on the database server by injecting SQL through the unsanitized timeZone parameter in the REST API groupBy endpoint.

Details

The vulnerability consists of two chained weaknesses:

1. SQL Injection (CWE-89)

File: packages/twenty-server/src/engine/api/graphql/graphql-query-runner/group-by/resolvers/utils/get-group-by-expression.util.ts

const timeZoneAsDateTruncParameter = shouldUseTimeZone
  ? `, '${groupByField.timeZone}'`  // Direct interpolation — no sanitization
  : '';

const timeZoneAsToCharParameter = shouldUseTimeZone
  ? ` AT TIME ZONE '${groupByField.timeZone}'`  // Direct interpolation — no sanitization
  : '';

The timeZone field within the group_by query parameter is directly interpolated into a raw SQL expression using JavaScript template literals without any parameterization, validation, or escaping. This produces:

TO_CHAR(DATE_TRUNC('DAY', "company"."createdAt", '<TIMEZONE>') AT TIME ZONE '<TIMEZONE>', 'YYYY-MM-DD')

An attacker can break out of the SQL string context and execute arbitrary SQL including stacked queries.

2. Remote Code Execution via COPY TO PROGRAM (CWE-78)

Twenty CRM's default Docker deployment runs PostgreSQL as a superuser (not the cloud version). This allows an attacker to:

  1. Create a PostgreSQL large object containing a shell script via lo_from_bytea()
  2. Export it to the filesystem via lo_export()
  3. Execute it via a stacked COPY (SELECT 1) TO PROGRAM query

Impact

Who is Impacted

  • All Twenty CRM installations from v1.7.7 through v1.16.7
  • Organization running Twenty CRM with its default Docker deployment (superuser PostgreSQL)
  • No administrator role required

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

CVE ID

CVE-2026-46624

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

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. Learn more on MITRE.

Credits