Advisory Database
  • Advisories
  • Dependency Scanning
  1. composer
  2. ›
  3. zendframework/zendframework1
  4. ›
  5. GHSA-2x36-qhx3-7m5f

GHSA-2x36-qhx3-7m5f: ZendFramework1 Potential SQL injection in the ORDER implementation of Zend_Db_Select

June 7, 2024

The implementation of the ORDER BY SQL statement in Zend_Db_Select of Zend Framework 1 contains a potential SQL injection when the query string passed contains parentheses.

For instance, the following code is affected by this issue:

$db     = Zend_Db::factory( /* options here */ );
$select = $db->select()
->from(array('p' => 'products'))
->order('MD5(1); drop table products');
echo $select;

This code produce the string:

SELECT "p".* FROM "products" AS "p" ORDER BY MD5(1);drop table products ASC

instead of the correct one:

SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);drop table products" ASC

The SQL injection occurs because we create a new Zend_Db_Expr() object, in presence of parentheses, passing directly the value without any filter on the string.

References

  • framework.zend.com/security/advisory/ZF2014-04
  • github.com/FriendsOfPHP/security-advisories/blob/master/zendframework/zendframework1/ZF2014-04.yaml
  • github.com/advisories/GHSA-2x36-qhx3-7m5f
  • github.com/zendframework/zf1

Code Behaviors & Features

Detect and mitigate GHSA-2x36-qhx3-7m5f with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions starting from 1.12.0 before 1.12.7

Fixed versions

  • 1.12.7

Solution

Upgrade to version 1.12.7 or above.

Impact 9.8 CRITICAL

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Learn more about CVSS

Weakness

  • CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Source file

packagist/zendframework/zendframework1/GHSA-2x36-qhx3-7m5f.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:15:35 +0000.