/

CVE-2026-34612

Severity:

CRITICAL RISK

(9.9)

SQL Injection in Kestra Flow Search API

CVE-2026-34612

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Remote Code Execution via Database SQL Injection

Severity:

CRITICAL RISK

(9.9)

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 Kestra's authenticated flow search endpoint allows crafted queries to be injected into PostgreSQL.

When exploited, PostgreSQL can be coerced into executing arbitrary OS commands via COPY ... TO PROGRAM ..., resulting in remote code execution on the host running the database.

Affected context

This vulnerability affects Kestra deployments, particularly those using the default docker-compose setup where Kestra is backed by PostgreSQL and the /api/v1/main/flows/search endpoint is exposed to authenticated users.

The issue arises when user-controlled search parameters are passed into dynamically constructed SQL queries without robust parameterization or sanitization.

Any environment where the database user has permission to invoke COPY ... TO PROGRAM ... is at elevated risk, as this capability allows escalation from data-layer compromise to code execution on the underlying host.

Exploit preconditions

  • Attack surface: HTTP API endpoint GET /api/v1/main/flows/search.
  • Required access: Valid authenticated Kestra user account with permission to access the flow search functionality.
  • User interaction: Visiting a specially crafted link or triggering a request containing malicious search input.
  • Database configuration: PostgreSQL in use, with a database role that has privileges to execute COPY ... TO PROGRAM ....
  • Why exploitation is possible: Untrusted input from request parameters is incorporated into SQL statements in a way that alters the structure of the query, allowing attackers to append COPY ... TO PROGRAM ... directives and execute arbitrary OS commands.

Why this happens

The underlying bug is classic SQL Injection (CWE-89).

Application logic responsible for searching flows accepts user-supplied criteria and embeds them into SQL queries in a dynamically concatenated form rather than using strictly parameterized statements or safe query builders.

As a result, an attacker-controlled value can break out of the intended data context and inject additional SQL syntax, including dangerous PostgreSQL constructs like COPY ... TO PROGRAM ....

This pattern reflects insufficient separation between data and control in database interactions, as well as overprivileged database roles that can invoke operating system commands.

Potential impact

  • Execution of arbitrary OS commands on the host running PostgreSQL.
  • Full compromise of the Kestra application data stored in the database (read, modify, and delete).
  • Lateral movement to other services or hosts accessible from the compromised database server.
  • Installation of backdoors or malware on the host system.
  • Exfiltration or tampering with workflow definitions, execution histories, and secrets stored or referenced by Kestra.

General mitigation guidance

Effective mitigation focuses on eliminating injection opportunities and limiting what the database can do even if an injection occurs:

  • Use parameterized queries or an ORM/query builder that does not allow raw string concatenation of SQL fragments with user input.
  • Apply strict input validation and canonicalization on search and filter fields, restricting them to well-defined patterns (e.g., whitelisted columns, operators, and formats).
  • Avoid exposing powerful database features like COPY ... TO PROGRAM ... to application-level roles; apply least privilege to database accounts.
  • Separate data filtering logic (search parameters) from query construction logic so that user input can never influence SQL structure, only bound values.
  • Introduce defense-in-depth measures such as database-level security policies, restricted OS-level permissions for the database user, and hardened container/host configurations to limit the blast radius of a compromise.

How teams detect issues like this

Organizations can detect and monitor this class of vulnerability and its exploitation using a combination of code-centric and operational approaches:

  • Static application security testing (SAST): Scan source code for dynamic SQL string construction that interpolates HTTP parameters or request fields directly, especially around search and filtering logic.
  • Code review practices: Flag any use of string concatenation to build SQL, and require developers to justify or refactor those patterns into parameterized forms.
  • Database monitoring: Enable logging of all SQL statements and watch for suspicious patterns such as COPY ... TO PROGRAM ..., unexpected shell commands, or unusual bulk operations.
  • Web and API monitoring: Use web application firewalls or API gateways with rules that detect common SQL Injection signatures in query parameters and URLs.
  • Policy enforcement in CI/CD: Integrate automated tools that block builds or deployments when insecure SQL construction patterns are detected, or when database permissions exceed predefined least-privilege baselines.

Sources

SourceLink
github.comgithub.com/kestra-io/kestra/commit/3926762795df8ad3e03924b370c51832ed3a21d3
github.comgithub.com/kestra-io/kestra/releases/tag/v1.3.7
github.comgithub.com/kestra-io/kestra/security/advisories/GHSA-365w-2m69-mp9x

Frequently asked

questions

Yes, if the Kestra API is exposed over the network and an attacker can obtain or abuse valid credentials, they can send crafted requests to the vulnerable endpoint. The injection is triggered over HTTP, but requires authentication.

The attacker must be an authenticated user with the ability to access the /api/v1/main/flows/search endpoint. No elevated application role is strictly required if normal users can trigger flow searches, but the exact risk depends on how roles and permissions are configured.

Refactor all database access code to use parameterized queries or safe query-building abstractions so that user input cannot influence SQL structure. In parallel, ensure the database user used by the application does not have permissions to execute OS-level commands, including disabling or restricting features like COPY ... TO PROGRAM ... for that role.

Establish secure coding standards that forbid dynamic SQL construction with user input, enforce these standards via code review and automated scanning, and apply least-privilege principles at the database level. Additionally, regularly test APIs for injection flaws using security testing tools and incorporate these checks into continuous integration pipelines.

Find out what's already
exploitable in your codebase.