Apache Flink: Remote code execution via SQL injection in code generation

Description

Code injection in SQL code generation in Apache Flink 1.15.0 through 1.20.x and 2.0.0 through 2.x allows authenticated users with query submission privileges to execute arbitrary code on TaskManagers via maliciously crafted SQL queries. The vulnerability affects JSON functions (1.15.0+) and LIKE expressions with ESCAPE clauses (1.17.0+). User-controlled strings are interpolated into generated Java code without proper escaping, allowing attackers to break out of string literals and inject arbitrary expressions.

Users are recommended to upgrade to either version 1.20.4, 2.0.2, 2.1.2 or 2.2.1, which fixes this issue.

Basic information

Type
reviewed
Severity
high
Advisory on GitHub
Open advisory ↗
Repository advisory
Source code
Browse source ↗
Published (advisory)
2026-05-15 18:30:34 UTC
Updated
2026-05-22 15:49:49 UTC
GitHub reviewed
2026-05-22 15:49:47 UTC
NVD published
2026-05-15 16:16:14 UTC

EPSS Score

Score Percentile
0.05% 16.18%

CVSS Scores

Base score Version Severity Vector
8.1 3.1
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network—not just someone sitting at the machine.
Attack complexity (AC:L)
Once they can reach the bug, pulling it off is straightforward—no weird race conditions or rare setup.
Privileges required (PR:L)
A normal user session is enough; they don’t have to be admin.
User interaction (UI:N)
Nobody has to click “OK” or open a trap file; it can work without a victim helping.
Scope (S:U)
Damage stays in the same “trust bubble” as the broken component—no big spill into unrelated systems.
Confidentiality (C:H)
Serious risk that confidential data gets exposed in a big way.
Integrity (I:H)
They could widely tamper with or forge data—trust in the data is badly hurt.
Availability (A:N)
Service keeps running; no real outage angle.

Identifiers

CWEs

CWE id Name
CWE-94 Improper Control of Generation of Code ('Code Injection')

Affected packages (12)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
maven org.apache.flink:flink-table-planner_2.12 >= 1.15.0, < 1.20.4 1.20.4
maven org.apache.flink:flink-table-planner_2.12 >= 2.0.0, < 2.0.2 2.0.2
maven org.apache.flink:flink-table-planner_2.12 >= 2.1.0, < 2.1.2 2.1.2
maven org.apache.flink:flink-table-planner_2.12 >= 2.2.0, < 2.2.1 2.2.1
maven org.apache.flink:flink-table-api-java >= 1.15.0, < 1.20.4 1.20.4
maven org.apache.flink:flink-table-api-java >= 2.0.0, < 2.0.2 2.0.2
maven org.apache.flink:flink-table-api-java >= 2.1.0, < 2.1.2 2.1.2
maven org.apache.flink:flink-table-api-java >= 2.2.0, < 2.2.1 2.2.1
maven org.apache.flink:flink-table-runtime >= 1.15.0, < 1.20.4 1.20.4
maven org.apache.flink:flink-table-runtime >= 2.0.0, < 2.0.2 2.0.2
maven org.apache.flink:flink-table-runtime >= 2.1.0, < 2.1.2 2.1.2
maven org.apache.flink:flink-table-runtime >= 2.2.0, < 2.2.1 2.2.1

References

cvelogic Threat Intelligence