HDWiki 5.1 arbitrary User Password Modification Vulnerability and repair

Source: Internet
Author: User

A logic vulnerability exists in password resetting in HDWiki, which allows attackers to modify arbitrary user passwords.
Detailed description:
Control/user. php
Function dogetpass (){
......
} Elseif (isset ($ this-> post ['verifystring']) {
$ Uid = $ this-> post ['uid'];
$ Encryptstring = $ this-> post ['verifystring'];
$ Idstring = $ _ ENV ['user']-> get_idstring_by_uid ($ uid, $ this-> time );
If ($ idstring = $ encryptstring ){
// A logic error is returned because the submission is empty and the query is returned empty.
$ Newpass = $ this-> post ['Password'];
$ Renewpass = $ this-> post ['repassword'];
$ Error = $ _ ENV ['user']-> checkpassword ($ newpass, $ renewpass );
If ($ error = 'OK '){
// Eval ($ this-> plugin ["ucenter"] ["hooks"] ["getpass"]);
UC_OPEN & $ msg =$ _ ENV ['ucenter']-> getpass ($ uid, $ newpass );
$ _ ENV ['user']-> update_field ('Password', md5 ($ newpass), $ uid );
$ _ ENV ['user']-> update_getpass ($ uid );
$ This-> message ($ this-> view-> lang ['resetpasssucess '], 'index. php? User-login ', 0 );
} Else {
$ This-> message ($ error, 'back', 0 );
}
} Else {
$ This-> message ($ this-> view-> lang ['resetpassmessage'], WIKI_URL, 0 );
}
}
 
Function get_idstring_by_uid ($ uid, $ time) {// obtain the verification code
Return $ this-> db-> result_first ("SELECT code FROM ". DB_TABLEPRE. "activation WHERE uid = $ uid AND available = 1 AND type = 1 AND time> ($ time-3*24*3600) order by time DESC ");
}
Proof of vulnerability: http://www.bkjia.com/index. php? User-getpass-user ID
 
The normal situation should be like this, user-getpass-1-xxx, but because of logic problems, you can go around.
In this case, the verifystring variable in the form is empty. Enter the new password twice and then reset it.
 
In fact, there is an injection here. When you get the verification code...
Solution: For logic problems, consider the case where the detection code is empty and the user's reset record is not in the database.
 
Temporary solution:
} Elseif (isset ($ this-> post ['verifystring']) {
$ Uid = $ this-> post ['uid'];
$ Encryptstring = $ this-> post ['verifystring'];
$ Idstring = $ _ ENV ['user']-> get_idstring_by_uid ($ uid, $ this-> time );
/* Determine the null condition */
If (empty ($ encryptstring) | empty ($ idstring )){
$ This-> message ($ error, 'back', 0 );
}

Author milk Tank

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.