Summary
EGroupware's core Nextmatch filter processing contains a SQL injection flaw where attacker-controlled values can be injected into the WHERE clause of database queries.
Due to a PHP type juggling issue after JSON decoding, numeric strings are converted into integers, bypassing an is_int() security check and allowing authenticated attackers to craft malicious filters that alter or exfiltrate data through arbitrary SQL commands.
Affected context
The vulnerability appears in EGroupware's core query-building logic for the Nextmatch component, which processes filter parameters received from authenticated users.
It affects scenarios where:
- Filter parameters are sent as JSON and decoded in PHP
- The decoded values are trusted as safe integers based on
is_int()checks - These values are then interpolated into SQL
WHEREclauses without proper parameterization
Deployments where authenticated users can influence complex filters or search criteria are particularly exposed.
Exploit preconditions
- Attack surface: Application web interface (HTTP/HTTPS endpoints that use Nextmatch-based filtering).
- Required access: Valid authenticated account with permissions to use views or modules that rely on Nextmatch filters.
- Trigger point: Submission of crafted filter data (often JSON-encoded) that is decoded and fed into the SQL query builder.
- Why exploitation is possible:
- JSON decoding in PHP converts numeric strings into integers.
- The application uses
is_int()as a safety gate, assuming that integers are safe. - Attacker-controlled data that passes this check is incorporated into the SQL
WHEREclause without proper parameter binding or escaping. - This allows injection of conditions or fragments that modify the intended query logic.
Why this happens
The core issue is the combination of:
- Trusting data solely based on PHP type checks after JSON decoding, and
- Building SQL statements in a way that allows those values to influence the
WHEREclause structure.
When JSON input is decoded, numeric strings become integers, so is_int() returns true even for attacker-controlled content. The code then treats such values as inherently safe and embeds them into SQL fragments instead of using parameterized queries.
This pattern aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where external input is allowed to shape SQL commands rather than being treated strictly as data. The implicit trust in type-based validation, without strict whitelisting and parameterization, creates a path for malicious filters to alter query semantics.
Potential impact
- Extraction of sensitive data from tables reachable by the affected queries
- Unauthorized access to other users' information or application metadata
- Manipulation or deletion of records (e.g., updates, soft deletes, or hard deletes) depending on query context
- Bypassing of application-level access controls enforced via SQL conditions
- Lateral movement toward other vulnerabilities through knowledge gained from database contents
General mitigation guidance
Effective mitigation typically focuses on enforcing strict separation between data and SQL logic, and on avoiding reliance on PHP type juggling for security.
Common defensive patterns include:
- Using parameterized queries or prepared statements for all variable parts of SQL, including dynamically constructed
WHEREfilters. - Replacing generic
is_int()checks with explicit whitelisting of allowed values and ranges, or mapping user input to known-safe constants. - Normalizing and validating decoded JSON data using strict schemas, ensuring only expected types and formats are accepted.
- Avoiding concatenation of user-derived values into SQL fragments that can alter query structure (operators, column names, function calls).
- Designing filter APIs that expose a constrained set of allowed operations, rather than allowing arbitrary filter expressions.
How teams detect issues like this
High-level detection approaches may include:
- Static analysis:
- Rules that flag SQL query construction using string concatenation or interpolation with variables derived from request or JSON-decoded data.
- Checks for reliance on
is_int(),is_numeric(), or similar type-based gates immediately before SQL construction. - Code review:
- Reviewing all Nextmatch-related query builders and filter processors for non-parameterized SQL and dynamic
WHEREclause construction. - Looking for places where JSON-decoded arrays are passed directly into query-building helpers without schema validation.
- Runtime and policy enforcement:
- Application firewalls or query firewalls that detect anomalous query patterns or unexpected predicates.
- CI/CD policies that require use of database abstraction layers or prepared-statement APIs and reject direct concatenation of SQL.
Automated code review and SAST tools can be configured to highlight dynamic SQL construction patterns and insecure type-based validation.

