/

CVE-2026-29953

Severity:

HIGH RISK

(7.4)

SQL Injection in SchemaHero Postgres Column Handling

CVE-2026-29953

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Arbitrary SQL Execution / Data Compromise

Severity:

HIGH RISK

(7.4)

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 SQL injection vulnerability in SchemaHero 0.23.0 allows crafted input in the column parameter to flow into dynamically constructed SQL within the columnAsInsert function for Postgres.

If an attacker can influence column names or related metadata passed into this function, they may be able to inject arbitrary SQL statements during migration or data manipulation workflows.

Affected context

This vulnerability affects environments using SchemaHero 0.23.0 with the Postgres plugin where:

  • Application or operator-controlled input can affect the column parameter used in migrations or insert generation, and
  • Column identifiers or metadata are not fully controlled at build time or by trusted operators, and
  • The columnAsInsert helper is invoked to construct SQL statements against a PostgreSQL database.

The risk is higher in multi-tenant or self-service database provisioning scenarios where less-trusted parties can influence schema definitions or migration specifications.

Exploit preconditions

  • Attack surface: Database migration or schema management pathways that use SchemaHero with the Postgres plugin.
  • Required access: Ability to influence or submit values that become the column parameter (e.g., schema/migration definitions, column configuration, or other metadata consumed by SchemaHero).
  • Trigger point: Execution of code paths that call columnAsInsert to build and execute SQL statements against the database.
  • Why exploitation is possible: The column parameter is incorporated into SQL without proper sanitization, escaping, or use of safe identifier-quoting APIs, enabling crafted values to alter the intended SQL structure.

Why this happens

The underlying issue is improper handling of untrusted data when constructing SQL statements for PostgreSQL.

Within plugins/postgres/lib/column.go, the columnAsInsert function appears to interpolate the column parameter directly into SQL text.

This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where attacker-controlled input is treated as part of the SQL syntax rather than as a data or identifier value.

Instead of strictly validating and quoting the column identifier or using safe construction primitives, the code path allows SQL metacharacters to modify the query structure.

Potential impact

  • Injection and execution of arbitrary SQL statements under the privileges of the SchemaHero-managed database connection.
  • Unauthorized reading of sensitive tables and rows that should not be exposed.
  • Modification or deletion of application data, including corruption of schema or migration metadata.
  • Creation, alteration, or dropping of tables and other database objects.
  • Escalation of impact to other tenants or applications sharing the same database instance.

General mitigation guidance

Effective mitigation generally focuses on ensuring untrusted values cannot influence SQL structure:

  • Treat the column value strictly as an identifier and apply robust identifier validation (e.g., allowlist of expected patterns, rejecting unexpected characters and SQL metacharacters).
  • Use database driver or library APIs specifically designed for safely quoting identifiers, not just string concatenation or parameter substitution intended for data values.
  • Clearly separate schema-definition responsibilities from untrusted users; only trusted operators or CI/CD pipelines should be able to define or modify column metadata used by SchemaHero.
  • Apply least-privilege principles to the database account used by SchemaHero so that even if an injection occurs, the account cannot perform high-impact actions outside its intended scope.
  • Incorporate secure-by-default abstractions for query construction in migration tooling, avoiding raw SQL assembly where feasible.

How teams detect issues like this

Organizations can detect this pattern and similar SQL injection risks through several approaches:

  • Static analysis: Configure linters or static analysis tools to flag dynamic SQL construction where identifiers or keywords are directly concatenated from variable input, especially in migration or schema management modules.
  • Code review: During review of database-related code, look for functions that join fragments into SQL strings and verify that all identifiers come from trusted sources or pass through strict validation and quoting utilities.
  • Policy enforcement: Establish internal guidelines that prohibit raw string concatenation for SQL query and schema generation in infrastructure-as-code and migration tools; enforce these rules via pre-commit hooks or CI checks.
  • Runtime monitoring: Monitor database logs for anomalous or malformed SQL statements, including unexpected comments, stacked queries, or control keywords appearing in places where only identifiers should appear.

Sources

SourceLink
gist.github.comgist.github.com/b0b0haha/fb59199fb1fdf9414e76442e0599bfed
github.comgithub.com/b0b0haha/SchemaHero--Sqlinjection/blob/main/README.md

Frequently asked

questions

It can be, depending on how SchemaHero is integrated. If remote users or external systems can influence schema definitions or any configuration that maps into the column parameter, then remote exploitation is possible through those interfaces. In tightly controlled environments where only trusted operators define schemas, the practical exposure is lower.

An attacker needs the ability to supply or modify values that become the column parameter used by columnAsInsert. This might be through misconfigured self-service schema features, user-submitted metadata that feeds into migrations, or compromised CI/CD or configuration channels.

The safest pattern is to ensure that the column value is treated strictly as an identifier: apply strict allowlist-based validation, reject unsafe characters, and use dedicated identifier-quoting utilities rather than raw string concatenation. Additionally, keep the set of allowed columns controlled by trusted configuration rather than user input.

To prevent similar issues, adopt a development policy that forbids dynamic SQL assembly with unsanitized input, especially in tooling that manages schemas or migrations. Use parameterized queries for data values, safe identifier APIs for names, integrate static analysis rules into CI, and keep schema-management inputs restricted to trusted, code-reviewed sources.

Find out what's already
exploitable in your codebase.