/

CVE-2026-44642

Severity:

HIGH RISK

(8.1)

SQL Injection (CWE-89) in Piwigo Upgrade Authentication

CVE-2026-44642

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Authentication Bypass and Unauthorized Database Modification

Severity:

HIGH RISK

(8.1)

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

Piwigo contains a SQL injection vulnerability in the upgrade authentication flow, where an unauthenticated username may be concatenated directly into a database query on PHP 8 and later.

When database upgrades are pending, a crafted request may bypass administrator authentication, authorize upgrade execution, and cause unauthorized database changes or service disruption.

Affected context

The vulnerability occurs in Piwigo's administrative upgrade workflow when all of the following conditions may apply:

  • The application runs on PHP 8 or later.
  • Database upgrades are pending.
  • The upgrade authentication function processes an attacker-controlled username.
  • The username is incorporated into an SQL query without reliable parameterization or escaping.

The risk is concentrated in deployments where the upgrade endpoint is reachable and database accounts permit the affected operations.

Exploit preconditions

  • Attack surface: The web-accessible Piwigo database upgrade authentication flow
  • Required access: Network access to submit requests; valid administrator credentials are not required
  • Trigger point: Processing an attacker-controlled username while checking upgrade authorization
  • Required application state: Pending database upgrades and an environment where the legacy escaping check does not protect the input
  • Why exploitation is possible: User input is concatenated into an SQL authentication query, allowing query logic to be altered before status and password checks are evaluated

Why this happens

The underlying bug is improper neutralization of special elements in SQL statements, mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

The upgrade authentication code conditionally escapes the submitted username based on the presence of the removed get_magic_quotes_gpc function. On PHP 8 and later, that condition does not provide effective protection, allowing the username to reach SQL string construction without dependable parameterization. The resulting query may interpret attacker-controlled content as SQL syntax rather than data.

Potential impact

  • An attacker may bypass upgrade authentication.
  • Unauthorized database schema or data changes could occur.
  • The application may enter an unintended upgrade state.
  • Service availability could be disrupted.
  • Stored application data or configuration could be altered.
  • Database access may provide a foundation for further compromise, depending on privileges.

General mitigation guidance

Mitigation generally focuses on eliminating string-built SQL and reducing the authority of the upgrade path.

Common defensive patterns include:

  • Use parameterized queries or prepared statements for every user-controlled value.
  • Avoid conditional, legacy escaping logic as a substitute for query parameterization.
  • Apply strict server-side validation and allowlists to usernames and other identity fields.
  • Require strong administrative authorization through a separately enforced access-control layer before upgrade operations.
  • Restrict upgrade endpoints to trusted administrative networks or authenticated maintenance workflows where practical.
  • Run the application database account with only the privileges required for normal operation and controlled upgrades.
  • Treat upgrade state and authorization checks as separate security decisions rather than relying on query results alone.

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules that flag SQL queries assembled through string concatenation with request parameters.
  • Code review checks for deprecated escaping APIs, conditional sanitization, and authentication decisions based on dynamic SQL.
  • Dynamic testing of upgrade endpoints with malformed identity values and database error monitoring in non-production environments.
  • Web application firewall or gateway policies that identify suspicious SQL syntax in upgrade authentication requests.
  • Database audit logging for unexpected authentication-query patterns, schema changes, or upgrade actions initiated without a normal administrator session.
  • Automated security review tools can help identify direct interpolation of request data into database queries.

Sources

SourceLink
github.comgithub.com/Piwigo/Piwigo/commit/1ff9d04534feb5f8f3cc2d3613c0fe8b51a1c0ba
github.comgithub.com/Piwigo/Piwigo/commit/2cfa7a3d194c8b95edde43038d8f5be5a359e785
github.comgithub.com/Piwigo/Piwigo/releases/tag/16.4.0
github.comgithub.com/Piwigo/Piwigo/security/advisories/GHSA-6wj3-7fhw-gfpm

Frequently asked

questions

It may be remotely exploitable when the Piwigo upgrade authentication endpoint is reachable over the network and database upgrades are pending. Exploitation does not require valid administrator credentials.

The attacker generally needs network access to submit a request to the affected web workflow. The precise exposure depends on routing, authentication gates, and deployment-specific administrative restrictions.

The safest pattern is to replace dynamically constructed SQL with parameterized queries, validate identity inputs independently, and enforce authorization before any upgrade operation is permitted.

Use prepared statements consistently, remove obsolete escaping assumptions, apply least privilege to database accounts, restrict maintenance endpoints, and include SQL injection testing in code review and continuous security testing.

Find out what's already
exploitable in your codebase.