Skip to content

Commit 17c305d

Browse files
authored
Merge pull request #491 from jjrom/develop
[SECURITY ISSUE] Correct issue that allow to get private ressources w…
2 parents 0e56e9d + 2cc72e1 commit 17c305d

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

app/resto/core/RestoConstants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RestoConstants
2020
// [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class
2121

2222
// resto version
23-
const VERSION = '9.6.0';
23+
const VERSION = '9.6.1';
2424

2525
/* ============================================================
2626
* NEVER EVER TOUCH THESE VALUES

app/resto/core/RestoRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private function instantiateRoute($validRoute, $method, $params)
326326
'auth' => $validRoute[0]
327327
);
328328
}
329-
329+
330330
/*
331331
* Authentication is required
332332
*/

app/resto/core/RestoUser.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,16 @@ public function __construct($profile, $context)
205205
*/
206206
else {
207207

208-
if (isset($profile['username'])) {
209-
$this->profile = (new UsersFunctions($this->context->dbDriver))->getUserProfile('username', $profile['username']);
210-
}
211-
else {
212-
$this->profile = (new UsersFunctions($this->context->dbDriver))->getUserProfile('email', $profile['email'], array(
208+
$target = isset($profile['username']) ? array('username', $profile['username']) : array('email', $profile['email']);
209+
210+
if ( array_key_exists('password', $profile) ) {
211+
$this->profile = (new UsersFunctions($this->context->dbDriver))->getUserProfile($target[0], $target[1], array(
213212
'password' => $profile['password'] ?? null
214213
));
215214
}
215+
else {
216+
$this->profile = (new UsersFunctions($this->context->dbDriver))->getUserProfile($target[0], $target[1]);
217+
}
216218

217219
if (!$this->profile) {
218220
$this->profile = $this->unregistered;

app/resto/core/dbfunctions/UsersFunctions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ public function getUserProfile($fieldName, $fieldValue, $params = array())
206206
/*
207207
* Check password
208208
*/
209-
if (isset($params['password'])) {
209+
if ( array_key_exists('password', $params) ) {
210+
210211
// External authentication
211212
if ($results[0]['password'] === str_repeat('*', 60)) {
212213
RestoLogUtil::httpError(400, 'External user');
213214
}
214-
215+
215216
if (!password_verify($params['password'], $results[0]['password'])) {
216217
RestoLogUtil::httpError(401);
217218
}

0 commit comments

Comments
 (0)