/

CVE-2026-22599

Severity:

HIGH RISK

(7.2)

SQL / Database Query Injection in Strapi Content-Type

CVE-2026-22599

Analyzed

Vulnerability type

Category:

SQL / Database Query Injection

CWE:

CWE-89

Impact:

Arbitrary Database Statement Execution (up to DB-level Remote Code Execution)

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A database query injection flaw in Strapi's Content-Type Builder write API allowed authenticated administrators to inject arbitrary database statements through the column.defaultTo attribute during content-type creation or modification.

By marking values as raw and bypassing sanitization, attackers could execute arbitrary SQL at the database layer, which, depending on the database engine, could lead to file access, denial of service, or even remote code execution on the database server.

Affected context

This vulnerability affects Strapi installations using:

  • Version 4.x prior to 4.26.1
  • Version 5.x prior to 5.33.2

where:

  • The Content-Type Builder write APIs are exposed and usable (typically in development or misconfigured production environments).
  • Administrators can create or modify content types through the admin panel or programmatic calls.
  • Schema migrations are handled by Knex, and the defaultTo configuration in content-type definitions is propagated into migration logic.

The issue manifests when defaultTo values are allowed to be expressed as raw tuples, leading to unvalidated data being passed into low-level database APIs during schema migration operations.

Exploit preconditions

  • Attack surface: Strapi Content-Type Builder write endpoints (e.g., /content-type-builder/content-types and related APIs).
  • Required access: Authenticated administrator account or any role with permission to create or edit content types via the Content-Type Builder.
  • Trigger point: Creation or modification of a content type field whose column.defaultTo is set to a tuple of the form [value, { isRaw: true }], thereby flagging the value as raw SQL.
  • Why exploitation is possible: The migration logic forwards the raw defaultTo value directly into Knex's db.connection.raw() without sanitization or parameterization. This allows attacker-supplied SQL fragments to be executed as-is by the database engine during schema migration, effectively bypassing query construction safeguards.

Why this happens

The root cause lies in treating configuration metadata for schema definition as fully trusted and allowing it to opt into raw query execution.

Specifically, the column.defaultTo attribute accepts a tuple form that includes { isRaw: true }, which signals that the associated value should be treated as raw SQL. In the vulnerable design, this value is passed straight into Knex's db.connection.raw() during schema migration. Because the Content-Type Builder write API is exposed to authenticated administrators, any administrator with sufficient permissions can inject arbitrary SQL statements into this field.

This aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), as user-controlled input is concatenated or embedded directly into SQL commands without proper neutralization, binding, or validation. The bug is fundamentally an injection-prone API design combined with over-trusting configuration data, rather than enforcing strict schema or parameterized patterns for all database interactions.

Potential impact

  • Arbitrary SQL statement execution against the application database.
  • Unauthorized reading of sensitive data stored in the database.
  • Arbitrary file read on database servers that provide file-access utilities (e.g., loading files through SQL functions).
  • Denial of service by causing schema migration errors that crash or destabilize the Strapi process.
  • Escalation to remote code execution on database servers where SQL functions permit external program execution or shell access.
  • Data corruption or destructive operations such as dropping tables, truncating data, or altering schemas in unexpected ways.

General mitigation guidance

Effective mitigation centers on ensuring that schema and configuration inputs cannot carry executable SQL and that risky endpoints are not exposed in production environments.

Common defensive patterns include:

  • Eliminate raw SQL configuration paths: Avoid supporting features that allow configuration fields (like defaultTo) to pass raw SQL directly into low-level database APIs. If raw access is unavoidable, confine it to strongly trusted, offline, or code-only contexts rather than network-exposed administrative interfaces.
  • Enforce strict validation and schema constraints: Treat content-type definitions as untrusted input even from administrators. Apply strong server-side validation, only allowing safe data types and disallowing markers such as { isRaw: true } or any indication of raw query execution.
  • Use parameterized and templated query builders: Structure database interactions so that all dynamic values are added via parameter binding or safe query builder methods, never concatenated into raw strings.
  • Restrict powerful admin capabilities in production: Limit access to content-type creation or modification APIs in production deployments, or constrain them to development environments. Employ role-based access control and separate "schema designer" privileges from day-to-day admin roles where possible.
  • Harden database environments: Configure the database to restrict dangerous utilities (file-system access, external program execution) and ensure it operates under least-privilege OS accounts to reduce the blast radius of any successful injection.

How teams detect issues like this

Detection focuses on identifying unsafe usage of raw SQL paths in schema and migration code, and monitoring for anomalous schema changes:

  • Static analysis and code review:
  • Flag calls to raw database APIs (e.g., db.connection.raw(), raw(), or equivalent) where any part of the input derives from user/admin-controlled configuration such as content-type definitions, migration metadata, or JSON config.
  • Look for patterns where defaultTo, column definitions, or field attributes accept tuples or objects that can signal "raw" behavior or bypass sanitization layers.
  • Enforce architectural guidelines that restrict raw SQL APIs to whitelisted modules or internal-only utilities, and require code review sign-off for any new raw query usage.
  • Configuration and policy enforcement:
  • Implement CI/CD checks that prohibit or warn on the presence of { isRaw: true } or comparable flags in configuration or migration code that can be updated through HTTP APIs.
  • Enforce environment-based policies so that content-type builder write APIs are inaccessible in production or restricted to internal networks.
  • Runtime monitoring:
  • Enable database auditing or logging to detect unexpected schema modifications, unusual use of file-access functions, or execution of rarely used administrative SQL functions.
  • Correlate admin actions (content-type changes) with downstream database operations to spot suspicious patterns, such as complex statements appearing in default values or migrations.
  • Automated security tooling:
  • Integrate security-focused linters or SAST tools that recognize SQL injection risk patterns in Node.js and Strapi applications, particularly around migration and schema-builder code.

Sources

SourceLink
github.comgithub.com/strapi/strapi/releases/tag/v4.26.1
github.comgithub.com/strapi/strapi/releases/tag/v5.33.2
github.comgithub.com/strapi/strapi/security/advisories/GHSA-3xcq-8mjw-h6mx

Frequently asked

questions

Exploitation is limited to authenticated users who have sufficient privileges to create or modify content types through Strapi's Content-Type Builder. It is not a fully unauthenticated vulnerability, but in many deployments administrators have broad access, and compromised admin accounts or misconfigured roles could make exploitation practical.

The attacker must be an authenticated administrator or hold a role with the ability to modify content types via the Content-Type Builder write APIs. Without such access, they cannot inject malicious column.defaultTo values into the schema definitions that drive migrations.

The safest pattern is to prevent network-exposed APIs from ever accepting configuration that can translate directly into raw SQL. This typically means restricting powerful builder APIs to controlled environments (e.g., development only), enforcing strict validation on schema fields, and redesigning APIs so that raw database operations are performed only by trusted backend code, not through user-managed metadata.

Preventing similar issues involves adopting a few consistent practices:

  • Design administrative and builder APIs under the assumption that even privileged users can introduce risky input, and never let that input reach raw execution paths.
  • Standardize on parameterized access patterns across all database operations, and treat any escape hatches (like raw SQL calls) as exceptional and tightly constrained.
  • Separate configuration and schema management responsibilities from day-to-day administration, limiting who can change structural aspects of the application.
  • Integrate security reviews for features that touch migrations, schema builders, and other meta-programming capabilities, as these are often high-risk for injection and escalation bugs.
Find out what's already
exploitable in your codebase.