/

CVE-2026-27634

Severity:

CRITICAL RISK

(9.8)

SQL Injection in Piwigo Date Filter Parameters

CVE-2026-27634

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise / Data Exfiltration

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A SQL injection vulnerability in Piwigo's date filter parameters allows attacker-controlled input to be concatenated directly into SQL queries without escaping or type validation.

When exploited, an unauthenticated attacker could extract the full database contents, including user password hashes, by manipulating specific web service parameters.

Affected context

This vulnerability occurs in Piwigo's web service layer within ws_std_image_sql_filter(), where four date filter parameters are used to build image selection queries.

The issue is present when the application:

  • Accepts f_min_date_available, f_max_date_available, f_min_date_created, and f_max_date_created from HTTP requests
  • Concatenates these values directly into SQL strings
  • Does not enforce robust server-side type checks, whitelisting, or parameter binding

In this context, maliciously crafted values can influence the structure of the SQL query instead of being treated purely as data.

Exploit preconditions

  • Attack surface: Public HTTP endpoints exposing Piwigo's web service features that rely on ws_std_image_sql_filter().
  • Required access: No authentication required; the vulnerable parameters are reachable by unauthenticated users in affected configurations.
  • Input vector: Attacker supplies crafted values for:
  • f_min_date_available
  • f_max_date_available
  • f_min_date_created
  • f_max_date_created
  • Trigger point: The server constructs and executes SQL queries using these parameters without escaping or parameterization.
  • Why exploitation is possible: User-controlled strings are directly concatenated into SQL, allowing the attacker to alter query logic, access additional tables, and exfiltrate data.

Why this happens

The root cause is the construction of SQL queries by string concatenation using untrusted input, without proper escaping, parameter binding, or type enforcement.

Instead of treating the four date parameters strictly as typed values (e.g., validated date strings bound to placeholders), the implementation injects them directly into the query text.

This pattern corresponds to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where special characters or segments in user input can terminate or extend SQL statements.

The vulnerability exists at the abstraction level of query construction, not in the database engine itself, and is independent of the specific SQL dialect used.

Potential impact

  • An attacker may read arbitrary database tables, including users and configuration data.
  • An attacker could access user password hashes for offline cracking and potential account takeover.
  • An attacker may enumerate internal schema details (table names, column names, relationships).
  • An attacker could combine data exposure with other weaknesses to escalate to full application compromise.
  • Depending on the database and query context, an attacker might be able to modify or delete data.

General mitigation guidance

Effective mitigation focuses on eliminating direct concatenation of untrusted input into SQL and enforcing strict data typing:

  • Adopt parameterized queries or prepared statements for all database access paths, including filters and search endpoints.
  • Treat date filters as typed values; validate them against strict server-side date formats and reject or normalize invalid input.
  • Use query builders or ORM layers that generate parameterized SQL by default, reducing the need for manual string assembly.
  • Centralize database access logic so that low-level query construction is not reimplemented in multiple places.
  • Apply least-privilege to the database account used by the application, limiting which tables and operations can be performed.
  • Implement robust error handling that avoids exposing detailed SQL errors or schema information in responses.

How teams detect issues like this

Organizations can detect similar SQL injection risks using a mix of code-centric and runtime approaches:

  • Static analysis: Configure rules to flag:
  • String concatenation involving SQL keywords and variables derived from HTTP request parameters.
  • Direct interpolation of user-controlled values into WHERE, ORDER BY, or LIMIT clauses.
  • Code review: During manual reviews, focus on:
  • Functions that construct dynamic SQL, especially filter or search helpers (like ws_std_image_sql_filter()).
  • Endpoints that are unauthenticated but interact with the database.
  • Inconsistent use of parameterized queries across the codebase.
  • Security testing: Use automated DAST or fuzzing tools to probe parameters with SQL meta-characters and detect anomalous responses.
  • Logging and monitoring: Monitor database query logs for:
  • Unusual patterns, such as concatenated literals, tautological conditions, or union-like constructs.
  • Sudden spikes in query volume or schema-discovery queries.

Applying these strategies in CI/CD (e.g., via SAST tools or pre-merge checks) can help prevent similar vulnerabilities from being introduced.

Sources

SourceLink
github.comgithub.com/Piwigo/Piwigo/commit/0d5ed1f7778bbe263410446d8cf64594df75bd08
github.comgithub.com/Piwigo/Piwigo/security/advisories/GHSA-mgqc-3445-qghq
piwigo.orgpiwigo.org/release-16.3.0

Frequently asked

questions

Yes. If the affected Piwigo instance is exposed over the internet, an unauthenticated remote attacker can send crafted HTTP requests with malicious date parameters to exploit the SQL injection.

No. The vulnerability is reachable via unauthenticated access in typical deployments, meaning no login or prior knowledge of credentials is required.

Replace all string-concatenated SQL that uses these date parameters with fully parameterized queries, enforce strict server-side date validation, and centralize query construction in a data access layer that defaults to safe parameter binding.

Establish coding standards that prohibit direct SQL string concatenation with user input, mandate the use of parameterized queries and ORM/query builders, incorporate static analysis rules for SQL injection, and include targeted security review for any new database-related features or filters.

Find out what's already
exploitable in your codebase.