Summary
A SQL injection vulnerability in the pwg.users.getList web service API of Piwigo allows the filter parameter to be concatenated directly into SQL queries without proper sanitization.
When exploited by an authenticated administrator, this flaw can enable arbitrary SQL command execution against the Piwigo database, potentially exposing or modifying sensitive application data.
Affected context
The vulnerability occurs in Piwigo's web service layer, specifically within the pwg.users.getList API method used to retrieve user lists with filtering capabilities.
It becomes relevant in deployments where:
- The web service API is enabled and accessible
- Administrator-level accounts are present and used for API calls or through the web UI
- The
filterparameter is accepted from client input and passed into a database query
The issue is tied to how dynamic query fragments are constructed based on the filter parameter without adequate validation or parameterization.
Exploit preconditions
- Attack surface: Piwigo web service endpoint
pwg.users.getList, reachable over HTTP/HTTPS. - Required access: Valid authenticated administrator account (or equivalent role able to invoke the method with a custom
filterparameter). - Trigger point: A crafted request to
pwg.users.getListsupplying a maliciousfiltervalue that alters the intended SQL query structure. - Why exploitation is possible: The implementation builds SQL statements by concatenating the
filterparameter directly into the query string, rather than using parameterized queries or rigorous input validation, allowing attacker-controlled input to change the SQL logic.
Why this happens
This vulnerability is a classic instance of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
The root cause lies in dynamically constructing SQL queries using string concatenation with user-controlled data (filter), instead of using prepared statements with bound parameters.
Because the application does not neutralize or validate special SQL meta-characters (such as quotes, operators, or comment delimiters), an attacker with administrative access can inject additional SQL clauses or statements, causing the database to execute unintended commands.
Potential impact
- Retrieval of sensitive user information that would not normally be exposed through the interface
- Unauthorized modification of user records, including roles, email addresses, or status flags
- Creation or deletion of application data, potentially leading to loss of photo metadata or user accounts
- Escalation of control over the application by manipulating administrative or configuration-related records stored in the database
- Potential pivot into the underlying infrastructure if the database has unsafe configuration (e.g., filesystem access, extended procedures)
General mitigation guidance
Effective mitigation focuses on eliminating the pattern of concatenating user input into SQL statements and tightening input trust boundaries:
- Refactor the affected query construction to use parameterized queries / prepared statements for all variable components.
- Constrain the
filterparameter to a well-defined set of allowed values or patterns (e.g., whitelisting specific fields and operators) and reject anything that does not match. - Centralize database access in a data-access layer that forbids ad-hoc string-built SQL and enforces parameterization by default.
- Apply least-privilege to the database account used by the application so that, even if injection defects appear elsewhere, the account cannot perform destructive or administrative operations.
- Introduce consistent input validation and normalization routines for web service parameters, especially those used to influence query conditions, sorting, or filtering.
How teams detect issues like this
Identifying and monitoring for this type of issue typically involves:
- Static analysis rules targeting SQL construction patterns that use string concatenation with request parameters (e.g., spotting
$sql .= $_REQUEST['filter'];-style patterns). - Code review checklists that explicitly require reviewers to verify that all database interactions use prepared statements and that filter/sort parameters are constrained to safe, enumerated values.
- Application-level logging that records unusual or malformed
filtervalues, enabling security teams to look for patterns indicative of injection attempts (e.g., presence of quotes, SQL keywords, or comment markers). - Integration of automated security testing tools (SAST/DAST) into CI/CD to flag endpoints where untrusted inputs flow into SQL query strings without parameterization.

