Skip to content

Commit

Permalink
Harden Security/Profile/Get processor
Browse files Browse the repository at this point in the history
- Should not allow loading a user other than the current authenticated user
- Should not return sensitive fields
  • Loading branch information
opengeek committed Jun 8, 2023
1 parent 39a5672 commit 47d914f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core/src/Revolution/Processors/Security/Profile/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ public function getLanguageTopics()
*/
public function initialize()
{
$id = $this->getProperty('id');
if (empty($id)) {
return $this->modx->lexicon('user_err_ns');
}
$this->user = $this->modx->getObject(modUser::class, $id);
$this->user = $this->modx->user;

Check warning on line 50 in core/src/Revolution/Processors/Security/Profile/Get.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Profile/Get.php#L50

Added line #L50 was not covered by tests
if (!$this->user) {
return $this->modx->lexicon('user_err_not_found');
}
Expand All @@ -78,6 +74,7 @@ public function process()
$userArray['blockedafter']) : '';
$userArray['lastlogin'] = !empty($userArray['lastlogin']) ? date('m/d/Y', $userArray['lastlogin']) : '';

unset($userArray['password'], $userArray['cachepwd'], $userArray['sessionid'], $userArray['salt']);

Check warning on line 77 in core/src/Revolution/Processors/Security/Profile/Get.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Processors/Security/Profile/Get.php#L77

Added line #L77 was not covered by tests
return $this->success('', $userArray);
}

Expand Down

0 comments on commit 47d914f

Please sign in to comment.