Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit be21131

Browse files
committed
Merge branch 'security/zf2016-02'
Patches ZF2016-02, and prepares for 1.12.19 release.
2 parents d2560a5 + 3269719 commit be21131

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ Master: [![Build Status](https://api.travis-ci.org/zendframework/zf1.png?branch=
1818
RELEASE INFORMATION
1919
===================
2020

21-
Zend Framework 1.12.19dev Release.
22-
Released on MMM DD, YYYY.
21+
Zend Framework 1.12.19 Release.
22+
Released on July 13, 2016.
2323

2424
IMPORTANT FIXES FOR 1.12.19
2525
---------------------------
2626

27+
This release contains security fixes:
28+
29+
- **ZF2016-02**: The implementation of `ORDER BY` and `GROUP BY` in
30+
`Zend_Db_Select` contained potential SQL injection vulnerabilities,
31+
and have been patched.
32+
2733
See http://framework.zend.com/changelog for full details.
2834

2935
NEW FEATURES

library/Zend/Db/Select.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class Zend_Db_Select
8181
const SQL_ASC = 'ASC';
8282
const SQL_DESC = 'DESC';
8383

84-
const REGEX_COLUMN_EXPR = '/^([\w]*\s*\(([^\(\)]|(?1))*\))$/';
84+
const REGEX_COLUMN_EXPR = '/^([\w]*\s*\(([^\(\)]|(?1))*\))$/';
85+
const REGEX_COLUMN_EXPR_ORDER = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/';
86+
const REGEX_COLUMN_EXPR_GROUP = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/';
8587

8688
/**
8789
* Bind variables for query
@@ -511,7 +513,7 @@ public function group($spec)
511513
}
512514

513515
foreach ($spec as $val) {
514-
if (preg_match(self::REGEX_COLUMN_EXPR, (string) $val)) {
516+
if (preg_match(self::REGEX_COLUMN_EXPR_GROUP, (string) $val)) {
515517
$val = new Zend_Db_Expr($val);
516518
}
517519
$this->_parts[self::GROUP][] = $val;
@@ -603,7 +605,7 @@ public function order($spec)
603605
$val = trim($matches[1]);
604606
$direction = $matches[2];
605607
}
606-
if (preg_match(self::REGEX_COLUMN_EXPR, (string) $val)) {
608+
if (preg_match(self::REGEX_COLUMN_EXPR_ORDER, (string) $val)) {
607609
$val = new Zend_Db_Expr($val);
608610
}
609611
$this->_parts[self::ORDER][] = array($val, $direction);

library/Zend/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class Zend_Version
3232
/**
3333
* Zend Framework version identification - see compareVersion()
3434
*/
35-
const VERSION = '1.12.19dev';
35+
const VERSION = '1.12.19';
3636

3737
/**
3838
* The latest stable version Zend Framework available

tests/Zend/Db/Select/StaticTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,10 @@ public function testSqlInjectionWithOrder()
834834
$select = $this->_db->select();
835835
$select->from(array('p' => 'products'))->order('MD5(1);drop table products; -- )');
836836
$this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);drop table products; -- )" ASC', $select->assemble());
837+
838+
$select = $this->_db->select();
839+
$select->from('p')->order("MD5(\";(\");DELETE FROM p2; SELECT 1 #)");
840+
$this->assertEquals('SELECT "p".* FROM "p" ORDER BY "MD5("";("");DELETE FROM p2; SELECT 1 #)" ASC', $select->assemble());
837841
}
838842

839843
public function testSqlInjectionWithGroup()
@@ -845,6 +849,10 @@ public function testSqlInjectionWithGroup()
845849
$select = $this->_db->select();
846850
$select->from(array('p' => 'products'))->group('MD5(1); drop table products; -- )');
847851
$this->assertEquals('SELECT "p".* FROM "products" AS "p" GROUP BY "MD5(1); drop table products; -- )"', $select->assemble());
852+
853+
$select = $this->_db->select();
854+
$select->from('p')->group("MD5(\";(\");DELETE FROM p2; SELECT 1 #)");
855+
$this->assertEquals('SELECT "p".* FROM "p" GROUP BY "MD5("";("");DELETE FROM p2; SELECT 1 #)"', $select->assemble());
848856
}
849857

850858
public function testSqlInjectionInColumn()

0 commit comments

Comments
 (0)