{"id":"GHSA-2x36-qhx3-7m5f","aliases":[],"title":"ZendFramework1 Potential SQL injection in the ORDER implementation of Zend_Db_Select","description":"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.\n\nFor instance, the following code is affected by this issue:\n```\n$db     = Zend_Db::factory( /* options here */ );\n$select = $db->select()\n    ->from(array('p' => 'products'))\n    ->order('MD5(1); drop table products');\necho $select;\n```\nThis code produce the string:\n```\nSELECT \"p\".* FROM \"products\" AS \"p\" ORDER BY MD5(1);drop table products ASC\n```\ninstead of the correct one:\n```\nSELECT \"p\".* FROM \"products\" AS \"p\" ORDER BY \"MD5(1);drop table products\" ASC\n```\nThe 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.","severity":"critical","score":9.8,"published":"2024-06-07T22:24:52.000Z","modified":"2024-12-04T05:39:35.461Z","withdrawn":false,"knownExploited":false,"affected":[{"ecosystem":"Packagist","name":"zendframework/zendframework1","ranges":[{"events":[{"introduced":"1.12.0"},{"fixed":"1.12.7"}],"type":"ECOSYSTEM"}],"versions":["1.12.0","1.12.1","1.12.2","1.12.3","1.12.4","1.12.5","1.12.6"],"fixed":["1.12.7"]}],"references":["https://framework.zend.com/security/advisory/ZF2014-04","https://github.com/FriendsOfPHP/security-advisories/blob/master/zendframework/zendframework1/ZF2014-04.yaml","https://github.com/zendframework/zf1"],"sources":[{"name":"OSV","id":"GHSA-2x36-qhx3-7m5f","modified":"2024-12-04T05:39:35.461646Z","url":"https://osv.dev/vulnerability/GHSA-2x36-qhx3-7m5f"}],"assessments":[{"source":"OSV","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8}]}