Summary
FilePress up to version 2.2.0 contains a SQL injection vulnerability in the Shares Filelist API (dzz/shares/admin.php), where the order argument is incorporated into database queries without sufficient sanitization.
A remote attacker can manipulate this parameter to inject arbitrary SQL, potentially accessing or modifying database contents through crafted HTTP requests.
Affected context
The vulnerability occurs within the Shares Filelist API of FilePress when handling requests routed through dzz/shares/admin.php.
It manifests when user-controlled input, particularly the order argument used for sorting or ordering results, is passed into SQL statements without robust validation or whitelisting.
Environments that expose the Shares Filelist API to untrusted clients or the public internet are more susceptible, especially where the application connects to databases containing sensitive or high-value data.
Exploit preconditions
- Attack surface: HTTP interface of the Shares Filelist API in FilePress.
- Required access: Remote, unauthenticated or low-privileged access to endpoints that process the
orderparameter (depending on deployment and access controls). - Trigger point: Submission of crafted requests where the
orderargument contains malicious SQL fragments or unexpected query syntax. - Why exploitation is possible: The application concatenates or interpolates the
orderargument into SQL queries without strict validation, escaping, or whitelisting, allowing attacker-controlled input to alter the structure of the executed query rather than being treated purely as data.
Why this happens
This vulnerability stems from constructing SQL queries using untrusted input for dynamic ordering without enforcing a safe, constrained set of values.
Instead of mapping the order parameter to a predefined list of allowed columns and sort directions, the application allows user-supplied strings to influence the query text directly.
This behavior aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), and may also touch CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, as unsafe data is propagated into the database layer without proper neutralization.
The core pattern is mixing control and data in SQL statements, where parameters influencing query structure are not segregated or normalized before use.
Potential impact
- An attacker may read sensitive information from database tables beyond what the application normally exposes.
- An attacker could modify, insert, or delete records, leading to data tampering or loss.
- Application integrity may be compromised, affecting user accounts, permissions, or configuration data.
- In some environments, SQL injection could be chained to achieve further compromise, such as writing files or escalating privileges within the database.
- Logging and auditing data can be altered, undermining incident response and forensics.
General mitigation guidance
Effective mitigation focuses on treating all client-supplied input as untrusted and separating query structure from data:
- Restrict dynamic ordering to a hard-coded whitelist of allowed columns and sort directions, mapping user-provided tokens to safe internal constants.
- Use parameterized queries or prepared statements for user-supplied values, ensuring that data is never concatenated directly into SQL strings.
- Normalize and validate ordering-related inputs by rejecting any value that does not match expected simple identifiers (e.g., predefined field names and
ASC/DESConly). - Apply least-privilege to the database account used by the application, granting only the minimal set of operations required.
- Introduce centralized data access layers or ORM abstractions where query-building patterns are reviewed and hardened once, instead of ad hoc SQL assembly across the codebase.
How teams detect issues like this
Detection typically combines code-level analysis with runtime monitoring:
- Use static analysis rules to flag raw SQL construction that interpolates request parameters (particularly fields like
order,sort, orcolumn). - During code review, look for patterns where query fragments (e.g., ORDER BY clauses) are built from unsanitized input or where whitelisting is missing or incomplete.
- Employ application-level security checks that enforce consistent use of parameterized queries and forbid direct concatenation of request parameters into SQL strings.
- Monitor database logs and web access logs for abnormal query patterns, such as unexpected operators, comment markers, or concatenated expressions in ORDER BY clauses originating from user input.
- Integrate security-focused automated review tools into CI pipelines to regularly scan for SQL injection patterns and other injection flaws.

