-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch to fix IDOR vulnerability in userinfo.php #1541
base: 2.0.x
Are you sure you want to change the base?
Changes from 1 commit
0f14e5d
21bc3c4
da7cd82
39583be
77cd02e
9f8b917
b3dc56b
894de02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,24 @@ public function &get($id) { | |
return $user; | ||
} | ||
|
||
/** | ||
* retrieve a user from hash_uid | ||
* | ||
* @param string $hash_uid hash_uid of the user | ||
* @return mixed reference to the {@link icms_member_user_Object} object, FALSE if failed | ||
*/ | ||
public function &getHash($hash_uid) { | ||
$user = FALSE; | ||
$sql = "SELECT * FROM " . $this->db->prefix('users') . " WHERE hash_uid = '" . $hash_uid . "'"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Àdding |
||
if (!$result = $this->db->query($sql)) {return $user;} | ||
$numrows = $this->db->getRowsNum($result); | ||
if ($numrows == 1) { | ||
$user = new icms_member_user_Object(); | ||
$user->assignVars($this->db->fetchArray($result)); | ||
} | ||
return $user; | ||
} | ||
|
||
/** | ||
* insert a new user in the database | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
|
||
$xoopsOption['pagetype'] = 'user'; | ||
include 'mainfile.php'; | ||
$hash_uid = (int) $_GET['uid']; | ||
$hash_uid = $_GET['uid']; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The input should be filtered and tested before using. In the original code, we force it to be an integer before proceeding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a little better. I recommend reviewing the icms_core_DataFilter::checkVar() method. Strings can still be malicious and validating input and access are the best defense against breaches. You can view how we've utilized it in a lot of places - includes/finduser.php is a good example. |
||
if (icms_get_module_status("profile")) { | ||
$module = icms::handler("icms_module")->getByDirName("profile", true); | ||
|
@@ -85,7 +85,7 @@ | |
'lang_deleteaccount' => $icmsConfigUser['self_delete'] ? _US_DELACCOUNT : '')); | ||
$thisUser = icms::$user; | ||
} else { | ||
$thisUser = icms::handler('icms_member')->getUser($uid); | ||
$thisUser = icms::handler('icms_member')->getUserHash($hash_uid); | ||
if (!is_object($thisUser) || !$thisUser->isActive()) { | ||
redirect_header('index.php', 3, _US_SELECTNG); | ||
} | ||
|
@@ -94,7 +94,7 @@ | |
$icmsTpl->assign('user_ownpage', false); | ||
} | ||
} else { | ||
$thisUser = icms::handler('icms_member')->getUser($uid); | ||
$thisUser = icms::handler('icms_member')->getUserHash($hash_uid); | ||
if (!is_object($thisUser) || !$thisUser->isActive()) { | ||
redirect_header('index.php', 3, _US_SELECTNG); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hash_uid
should be escaped in case of SQL Injection.$this->db->quote($hash_uid)
or$this->db->quoteString($hash_uid)
should be used here