A security vulnerability in an open-source php Software

Source: Internet
Author: User
Tags php software


See the public_get_suggest_keyword function:
/Phpcms/modules/search/index. php
[Php]
Public function public_get_suggest_keyword (){
$ Url = $ _ GET ['url']. '& q ='. $ _ GET ['q'];

$ Res = @ file_get_contents ($ url );
If (CHARSET! = 'Gbk '){
$ Res = iconv ('gbk', CHARSET, $ res );
}
Echo $ res;
}
[Php]
$ Url = $ _ GET ['url']. '& q ='. $ _ GET ['q'];
The url does not have any whitelist, and it will be included in the Code without any filtering.
[Php]
$ Res = @ file_get_contents ($ url );
Another function, if a large file is created, can directly crash the server.
After searching for a circle, this code is only used in one JS:
[Javascript]
$ (Document). ready (function (){
$ ("# Q"). suggest ("? M = search & c = index & a = public_get_suggest_keyword & url = "+ encodeURIComponent ('HTTP: // www.google.cn/complete/search? Hl = zh-CN & q = '+ $ ("# q"). val ()),{
OnSelect: function (){
Alert (this. value );
}
});
 
});


Warning:
1. The passed parameters must be filtered for security.
2. If you perform url and path operations, you must perform path filtering.
3. I don't know how to stop using @ file_get_contents.
4. The domain name white list must be implemented in the above case.

Related Article

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.