Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

White list sort order and direction for /user/orders, vulnerability reported by @whuHouYF

givanze855c8572b72
diff --git a/app/component/orders.php b/app/component/orders.php
index d38db59..7eeac97 100755
--- a/app/component/orders.php
+++ b/app/component/orders.php
@@ -29,11 +29,22 @@ use function Vvveb\url;
class Orders extends ComponentBase {
public static $defaultOptions = [
- 'start' => 0,
- 'order_id' => null,
- 'customer_order_id' => null,
- 'limit' => ['url', 4],
- 'order' => ['url', 'price asc'],
+ 'start' => 0,
+ 'limit' => ['url', 4],
+ 'user_id' => null,
+ 'order_status' => null,
+ 'order_status_id' => null,
+ 'payment_status' => null,
+ 'payment_status_id' => null,
+ 'shipping_status' => null,
+ 'shipping_status_id' => null,
+ 'email' => null,
+ 'phone_number' => null,
+ 'search' => null,
+ 'order_by' => ['url', 'order_id'],
+ 'direction' => ['url', 'DESC'],
+ 'language_id' => null,
+ 'site_id' => null,
];
public $options = [];
@@ -41,6 +52,16 @@ class Orders extends ComponentBase {
function results() {
$orders = new \Vvveb\Sql\OrderSQL();
+ if (isset($this->options['order_by']) &&
+ ! in_array($this->options['order_by'], ['order_id', 'created_at', 'updated_at'])) {
+ unset($this->options['order_by']);
+ }
+
+ if (isset($this->options['direction']) &&
+ ! in_array($this->options['direction'], ['asc', 'desc'])) {
+ unset($this->options['direction']);
+ }
+
$results = $orders->getAll($this->options);
if (isset($results['order'])) {