Summary
A SQL injection flaw in Piwigo's Activity List API endpoint allows an authenticated administrator to manipulate database queries and extract sensitive information.
When exploited, this issue can expose user credentials, email addresses, and all stored gallery content by injecting crafted SQL into backend queries.
Affected context
This vulnerability arises in Piwigo deployments that expose the Activity List API endpoint and rely on dynamically constructed SQL queries based on request parameters.
The issue manifests when user-controlled input—originating from an authenticated administrator session—is interpolated into SQL statements without robust parameterization or validation.
While the attack surface is restricted to authenticated administrators, any compromised or shared admin account, or an admin operating within a malicious browser context, can become an effective vector.
Exploit preconditions
- Attack surface: Piwigo web application, specifically the Activity List API endpoint.
- Required access: Valid authenticated administrator session with permission to access the Activity List feature.
- Trigger point: Submission of crafted input parameters that are incorporated into SQL queries executed by the Activity List endpoint.
- Why exploitation is possible: The backend combines administrator-controlled input with SQL statements in an unsafe way, lacking strict parameter binding, allowing the injected input to alter the intended query structure and return arbitrary database records.
Why this happens
The core issue maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Application logic builds SQL queries for the Activity List endpoint by concatenating or interpolating request parameters directly into SQL strings instead of using prepared statements with bound parameters and strict typing.
Because the input is not consistently validated or encoded within a parameterized context, an attacker with admin access can introduce SQL control characters and clauses that change the semantics of the query, enabling data extraction beyond the intended scope.
Potential impact
- An attacker may retrieve user credentials stored in the database (e.g., password hashes).
- An attacker may access users' email addresses and profile information.
- An attacker may enumerate and exfiltrate all photo metadata and associated content records.
- An attacker could discover internal application configuration data stored in the database.
- Depending on database configuration, an attacker might pivot to read additional sensitive tables used by plugins or extensions.
General mitigation guidance
Effective mitigation focuses on removing dynamic SQL construction paths for the Activity List endpoint and similar features:
- Use parameterized queries or prepared statements consistently, binding all external inputs as parameters rather than concatenating them into SQL strings.
- Apply strict input validation and canonicalization on query parameters (e.g., whitelisting expected values such as enumerations, column names, sort directions, and limits).
- Separate query logic from presentation logic so that filtering, ordering, and pagination are implemented through controlled mappings rather than direct user-driven SQL fragments.
- Minimize the sensitivity of data accessible from any single administrative function, enforcing least privilege within the application's internal query layer.
- Introduce secure-by-default database access patterns through shared utility functions or ORM APIs that make unsafe query construction harder or impossible.
How teams detect issues like this
Organizations can identify and monitor for this class of issue through a combination of review and runtime controls:
- Static analysis: Configure tools or custom rules to flag string-based SQL construction, especially where request parameters or admin-controlled variables are concatenated into queries.
- Code review: During peer review, treat any raw SQL usage as high-risk; verify that all parameters are bound, and that filter/sort options come from controlled mappings rather than raw input.
- Security testing: Use authenticated SQL injection testing as part of regular application security assessments, including targeted testing of admin-only APIs and dashboards.
- Logging and monitoring: Analyze database and application logs for anomalous queries with unusual operators, stacked statements (if supported), or patterns inconsistent with normal Activity List operations.
- Policy enforcement: Adopt coding guidelines that mandate ORMs or query builders with prepared statements, and enforce these patterns in CI through linters or security-focused quality gates.

