Thinkphp Remote Code Execution Vulnerability Alert

Thinkphp Remote Code Execution Vulnerability Alert

December 11, 2022 | Jie Ji

Overview

Recently, NSFOCUS CERT has monitored that the exploit details of the Thinkphp remote code execution vulnerability are publicly disclosed on the Internet. Due to the incoming parameter inspection defect in the Thinkphp program, when Thinkphp enables the multilingual function, unauthenticated attackers can pass in parameters through get, header, cookie, etc., to achieve directory traversal and file inclusion, and finally achieve remote code execution by the pearcmd file with trick. The details of the vulnerability have been made public. Relevant users are requested to take protective measures as soon as possible.

ThinkPHP is a free open source, fast and simple object-oriented lightweight PHP development framework. NSFOCUS CERT has successfully reproduced this vulnerability:

Reference link: https://blog.thinkphp.cn/3078655

Scope of Impact

Affected version

  • v6.0.0 <= ThinkPHP <= v6.0.13
  • v5.1.0 <= ThinkPHP <= v5.1.41
  • v5.0.0 <= ThinkPHP <= v5.0.24

Unaffected version

  • ThinkPHP >= v6.0.14
  • ThinkPHP = v5.1.42

Vulnerability Detection

1. Execute the following command to view the version information of ThinkPHP:

php think version

If it is within the affected range, the product may be affected by this vulnerability.

2. Check whether ThinkPHP has multilingual function enabled.

1) Thinkphp6:

Check whether there are comments in the following content in app/middleware.php. If there are no comments, ThinkPHP has enabled multi-language function, and the product is affected by this vulnerability.

\think\middleware\LoadLangPack::class

2) Thinkphp5:

Check app/middleware.php, if the following content exists, ThinkPHP has enabled multilingual function, and the product is affected by this vulnerability.

 ‘lang_switch_on’=> true

Mitigation

Official upgrade

If the upgrade is not possible, the user can do the protection in the following ways.

1. Thinkphp6:

Check app/middleware.php and comment the following content:

\think\middleware\LoadLangPack::class

2. Thinkphp5:

Check app/middleware.php, change ‘lang_switch_on’ => true to the following:

‘lang_switch_on’=>false

3. Restart Thinkphp

Statement

This advisory is only used to describe a potential risk. NSFOCUS does not provide any commitment or promise on this advisory. NSFOCUS and the author will not bear any liability for any direct and/or indirect consequences and losses caused by transmitting and/or using this advisory. NSFOCUS reserves all the rights to modify and interpret this advisory. Please include this statement paragraph when reproducing or transferring this advisory. Do not modify this advisory, add/delete any information to/from it, or use this advisory for commercial purposes without permission from NSFOCUS.

About NSFOCUS

NSFOCUS, Inc., a global network and cyber security leader, protects enterprises and carriers from advanced cyber attacks. The company’s Intelligent Hybrid Security strategy utilizes both cloud and on-premises security platforms, built on a foundation of real-time global threat intelligence, to provide multi-layered, unified and dynamic protection against advanced cyber attacks.

NSFOCUS works with Fortune Global 500 companies, including four of the world’s five largest financial institutions, organizations in insurance, retail, healthcare, critical infrastructure industries as well as government agencies. NSFOCUS has technology and channel partners in more than 60 countries, is a member of both the Microsoft Active Protections Program (MAPP), and the Cloud Security Alliance (CSA).

A wholly owned subsidiary of NSFOCUS Technologies Group Co., Ltd., the company has operations in the Americas, Europe, the Middle East and Asia Pacific.