#1288·pig

SQL Injection via ascs/descs pagination parameters (v4.1.0)

Author: vinch3sCreated Sep 19, 2026Updated Sep 21, 2026

Summary

Pig4Cloud (up to and including v4.1.0) is vulnerable to SQL injection through the ascs / descs pagination sort parameters. Any authenticated user — including the lowest-privileged ordinary user — can inject arbitrary SQL expressions into the ORDER BY clause and read data from any table referenced by the query, including columns that are not returned by the API.

Affected Component

pig-common-data/src/main/java/com/pig4cloud/pig/common/data/resolver/SqlFilterArgumentResolver.java:73-101

The same logic exists in v3.9.2 under pig-common-mybatis/.../resolver/SqlFilterArgumentResolver.java:71-92; only the package name and the parameter-parsing method differ between the two versions.

Root Cause

The resolver is registered globally and applies to every paginated endpoint (any controller method taking a MyBatis-Plus Page parameter):

java
Optional.ofNullable(descs)
    .ifPresent(s -> orderItemList.addAll(Arrays.stream(s.split(StrUtil.COMMA))
        .filter(desc -> !SqlInjectionUtils.check(desc))  // only protection: regex blacklist
        .map(OrderItem::desc)                            // raw value into column
        .toList()));

Since ORDER BY cannot use prepared-statement placeholders, OrderItem.column is concatenated verbatim into the SQL statement by MyBatis-Plus's PaginationInnerInterceptor:

java
sql.append(" ORDER BY ").append(orderItem.getColumn()).append(" DESC");

The sole protection, SqlInjectionUtils.check(), is a regex blacklist with three structural weaknesses:

  1. SQL_COMMENT_PATTERN ("'.*(or|union|--|#|/\*|;)") requires a leading single quote — omitting quotes disables comment-based filtering entirely.
  2. SQL_SYNTAX_PATTERN enumerates only a limited set of function names (if / select / substr / substring / char / concat / benchmark / sleep). It does not cover case / when / then / hex / lower / like.
  3. The (and|or)\s+.* alternative requires trailing whitespace, so a bare or passes through.

Proof of Concept

http
GET /admin/user/page?current=1&size=3&descs=<payload>
Authorization: Bearer <any valid token>

Boolean-based blind extraction using a CASE expression whose branch selects the sort column:

sql
case((lower(hex(password)))LIKE(0x<hex-prefix>%))when(1)then(user_id)else(phone)end

This was used to fully extract sys_user.password (a bcrypt hash, 120 hex characters) — a field that is not present in the API response and exists only inside the SQL query. The extracted value matched the ground truth at all 120 positions.

Verified against v4.1.0 with MySQL 8.4.5 / JDK 17 in an isolated lab environment.

Suggested Fix

Replace the blacklist with a column-name whitelist at the entity or mapper layer so that only known sortable columns are accepted:

java
private static final Set<String> ALLOWED_COLUMNS = Set.of(
    "user_id", "username", "create_time", "update_time"
);
// ...
.filter(ALLOWED_COLUMNS::contains)

As a minimum fallback, restrict the character set to alphanumerics and underscore:

java
private static final Pattern SAFE = Pattern.compile("^[A-Za-z0-9_]+$");
.filter(desc -> SAFE.matcher(desc).matches())

This is the same remediation adopted for the equivalent issue in Apache InLong (CVE-2026-63039) and yu-picture (CVE-2026-7060).

Additional Observation

The error response echoes the full SQL statement and stack trace back to the client, including sensitive column names such as u.password and u.salt. This is an independent information-disclosure issue worth fixing alongside the injection itself.

Disclosure

Reported in the spirit of coordinated disclosure. Full technical analysis:

https://github.com/vinch3s/pig4cloud-cve/blob/main/Pig4Cloud-SQL-Injection.md

Also submitted to VulDB for CVE assignment.

This is the same class of issue as CVE-2020-16165 (SpringBlade ascs/desc ORDER BY injection). The distinction is that Pig4Cloud does implement a protection, but it is a bypassable regex blacklist rather than a whitelist.

Environment

  • Pig4Cloud v4.1.0 (latest release, 2026-07-08)
  • pig-boot monolithic mode, MySQL 8.4.5, Redis 7, JDK 17
  • Tested on an isolated lab instance; no production system was involved