Summary
A critical SQL injection vulnerability in Tencent APIJSON through version 8.1.8 affects processing of the Map-form @having operator. An unauthenticated remote attacker may bypass per-table access controls and read arbitrary database tables when a vulnerable endpoint accepts attacker-controlled query parameters.
Affected context
The issue may arise in APIJSON deployments that expose query functionality through remotely reachable API endpoints and process the Map-form @having operator without sufficiently separating user-supplied values from SQL expressions. Risk is higher when endpoints are unauthenticated or when database authorization relies primarily on application-level per-table access controls.
Exploit preconditions
- Attack surface: Remotely accessible APIJSON query endpoints
- Required access: No authentication may be required when an affected endpoint is publicly reachable
- Trigger point: Processing of attacker-controlled input associated with the Map-form
@havingoperator - Why exploitation is possible: Insufficient separation between query input and generated SQL may allow user-controlled expressions to alter database query behavior and bypass application-level table restrictions
Why this happens
The underlying bug is an SQL injection condition, mapped to CWE-89, in which externally controlled query data is incorporated into SQL processing without reliable parameterization or equivalent structural controls. When the Map-form @having operator is interpreted as part of a database query, inadequate validation or query construction boundaries may allow input to influence SQL semantics rather than remain a constrained data value.
Potential impact
- An attacker may bypass per-table access controls
- An attacker could read arbitrary database tables
- Sensitive business, personal, or authentication data may be disclosed
- Database confidentiality and application trust boundaries may be weakened
- Excessive database permissions could increase the scope of resulting data exposure
General mitigation guidance
Mitigation generally focuses on ensuring that query construction treats external input as data rather than executable SQL structure.
Common defensive patterns include:
- Using parameterized queries or safe query-builder abstractions for values
- Allowing only explicitly supported operators, fields, and query shapes
- Applying strict type, format, and allowlist validation to Map-form query inputs
- Enforcing authorization after query interpretation and independently of client-supplied table or field selectors
- Using database identities with least-privilege read permissions and narrowly scoped table access
- Limiting unauthenticated access to query endpoints and applying appropriate request controls
- Avoiding dynamic SQL fragments unless they are generated exclusively from trusted, validated identifiers
How teams detect issues like this
Detection approaches may include:
- Static analysis for string concatenation or interpolation involving request parameters and SQL statements
- Code review of custom handling for
@having, table selectors, field selectors, and other query operators - Testing that unauthorized table references and unsupported query structures are rejected consistently
- Monitoring database audit logs for unusual table access from API service identities
- Enforcing policies that require parameterized queries, approved query builders, and explicit operator allowlists
- Using automated security review tools as a supplementary way to identify SQL construction patterns

