/

CVE-2026-38812

Severity:

CRITICAL RISK

(9.8)

SQL Injection (CWE-89) in RuoYi Code Generation Module

CVE-2026-38812

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exfiltration and Database Compromise

Severity:

CRITICAL RISK

(9.8)

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

RuoYi v4.8.2 contains a SQL injection vulnerability in the /tool/gen/createTable endpoint of the code generation module.

An authenticated attacker with administrative privileges can craft malicious input that manipulates backend SQL queries, potentially exposing sensitive database information and other data.

Affected context

The vulnerability occurs in RuoYi deployments using the code generation feature exposed via the /tool/gen/createTable endpoint.

It manifests when user-supplied parameters from the admin interface are directly embedded into SQL statements without robust validation or parameterization.

This risk is present in environments where administrative accounts are used to define or generate database-backed entities and the application trusts these inputs as safe.

Exploit preconditions

  • Attack surface: HTTP interface of the RuoYi admin backend, specifically the /tool/gen/createTable endpoint.
  • Required access: Valid, authenticated account with administrative-level permissions to access the code generation module.
  • Trigger point: Submission of crafted parameters (e.g., table names or related metadata) that are used to construct SQL queries.
  • Why exploitation is possible: The server-side logic constructs SQL dynamically using attacker-influenced values without consistent parameter binding, escaping, or whitelist-based validation, allowing injected SQL fragments to be executed by the database.

Why this happens

This issue stems from constructing SQL statements using concatenated strings that incorporate user-controllable input from the code generation interface.

Rather than using prepared statements or strict, validated mappings to known-safe identifiers, the implementation allows arbitrary values from the request to flow into SQL.

This pattern aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the database interprets attacker-controlled input as part of the SQL syntax rather than as data.

Potential impact

  • Access to sensitive database records that the attacker's account would not normally be able to query.
  • Enumeration of database schema, including table names, columns, and relationships.
  • Modification or deletion of data in arbitrary tables, potentially causing integrity loss.
  • Bypass of application-level authorization by issuing direct SQL queries.
  • Potential pivot to other systems via stored credentials or secrets in the database.

General mitigation guidance

Mitigation typically focuses on eliminating dynamic SQL that incorporates untrusted input and constraining what the code generation module can do.

Common defensive patterns include:

  • Using parameterized queries or prepared statements for all database access, including metadata and code generation routines.
  • Restricting inputs to well-defined, whitelist-validated identifiers (e.g., limiting table names to known schema entries or strict patterns).
  • Separating code generation metadata from raw SQL construction, with a dedicated, vetted mapping layer between user input and database objects.
  • Applying least-privilege to the database account used by the code generation module so that it cannot read or modify unrelated tables.
  • Implementing centralized input validation for administrative forms, ensuring consistent filtering and canonicalization of all database-related parameters.

How teams detect issues like this

Effective detection often combines code-level and runtime observations:

  • Static analysis rules that flag string-based SQL construction where request parameters or admin form fields are concatenated into queries.
  • Code review checklists that treat dynamic SQL and code generation utilities as high-risk, requiring explicit justification for any non-parameterized queries.
  • Application security testing (SAST/DAST) focused on admin-only endpoints, including the /tool/gen/createTable path, to identify injection sinks that may be missed in user-facing interfaces.
  • Database monitoring and alerting for anomalous queries originating from the application, such as unexpected schema enumeration or access to non-core tables.

Automated security testing tools can be integrated into CI/CD to enforce these checks for every change affecting data-access layers and code generation modules.

Sources

SourceLink
github.comgithub.com/jjcjgo/CVE-2026-38812-RuoYi-SQL-Injection

Frequently asked

questions

Yes, it is exploitable via the web-based admin interface, but only by authenticated users who can reach the /tool/gen/createTable endpoint and have sufficient privileges.

Under typical configurations, access to the affected endpoint requires an administrative or similarly privileged account.

The attack relies on the ability to submit crafted values through the code generation interface.

The safest pattern is to remove dynamic SQL that embeds user input and instead use parameterized queries or constrained mappings to predefined database entities.

Additionally, tighten database privileges and validate all admin-provided inputs against strict whitelists.

Adopt a secure-by-default data access layer that only exposes parameterized operations, enforce input validation at service boundaries, and treat all admin-facing tools as untrusted input sources.

Incorporating static analysis, security code review, and regular penetration tests into the development lifecycle helps catch regressions early.

Find out what's already
exploitable in your codebase.