Fastjson 2.x Remote Code Execution Vulnerability Notice

Overview

Recently, NSFOCUS CERT detected that a Fastjson 2.x remote code execution vulnerability was disclosed online; Because Fastjson2.x may still handle @type in JSON through the built-in whitelist when SupportAutoType is not enabled by default configuration, an unauthenticated attacker can construct specially crafted malicious JSON data and achieve remote code execution without any third-party dangerous classes on the target service. The CVSS score is 9.8. At present, the vulnerability details have been disclosed. Relevant users are requested to take measures as soon as possible.

Fastjson is Alibaba’s open source JSON parsing library. It can parse strings in JSON format, support serialization of Java Beans into JSON strings, and can also deserialize from JSON strings to JavaBeans; it has the characteristics of high execution efficiency and a wide range of applications.

Reference link: https://github.com/alibaba/fastjson2/issues/7702

Scope of Impact

Affected version

  • Fastjson 2.x <= 2.0.62

Note: The official Fastjson 1.2.68 and later versions have added the SafeMode function, which can completely disable autoType.

Unaffected version

  • Fastjson 2.x > 2.0.62

Detection

Manual inspection

Relevant users can use the following command to detect the current version of Fastjson used:

lsof | grep fastjson

Or find out if there is a fastjson-[version].jar file in the project directory.

Projects packaged with maven can view the current fastjson version in use through pom.xml:

If the current version is within the affected range and SafeMode is not enabled, there will be a security risk.

Mitigation

Official upgrade

At present, the official security patch has been released to fix this vulnerability. It is recommended that affected users update as soon as possible for protection.

Download link: https://github.com/alibaba/fastjson2/pull/7695/changes

Other protective measures

If the relevant users are temporarily unable to perform upgrade operations, the following measures can also be used for temporary relief:

Fastjson introduced the safeMode security mode in versions 1.2.68 and later. After configuring safeMode, autoType is not supported regardless of whitelist or blacklist, which can prevent deserialization vulnerability attacks; three ways to enable SafeMode are as follows:

1. Configure in the code:

ParserConfig.getGlobalInstance().setSafeMode(true);

2. Add JVM startup parameters:

-Dfastjson.parser.safeMode=true

If there are multiple package name prefixes, they can be separated by commas.

3. Configure through the fastjson.properties file:

Configure through the fastjson.properties file of the class path, the configuration method is as follows:

fastjson.parser.safeMode=true

The official document: https://github.com/alibaba/fastjson/wiki/fastjson_safemode

When using security devices such as WAF to intercept JSON data with the key containing the @type field in the request body, it is necessary to overwrite both the URL parameters and the request body and pay attention to encoding bypass.

NSFOCUS product protection

The historical rules of NSFOCUS WEB Application Firewall (WAF), Network Intrusion Prevention System (IPS) and NSFOCUS Unified Threat Sensor (UTS) support this vulnerability protection. Relevant users are requested to upgrade the rule package to the latest version to form security product protection capabilities.

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, a pioneering leader in cybersecurity, is dedicated to safeguarding telecommunications, Internet service providers, hosting providers, and enterprises from sophisticated cyberattacks.

Founded in 2000, NSFOCUS operates globally with over 3000 employees at two headquarters in Beijing, China, and Santa Clara, CA, USA, and over 50 offices worldwide. It has a proven track record of protecting over 25% of the Fortune Global 500 companies, including four of the five largest banks and six of the world’s top ten telecommunications companies.

Leveraging technical prowess and innovation, NSFOCUS delivers a comprehensive suite of security solutions, including the Intelligent Security Operations Platform (ISOP) for modern SOC, DDoS Protection, Continuous Threat Exposure Management (CTEM) Service and Web Application and API Protection (WAAP). All the solutions and services are augmented by the Security Large Language Model (SecLLM), ML, patented algorithms and other cutting-edge research achievements developed by NSFOCUS.

Leave a Reply

Your email address will not be published. Required fields are marked *

NSFOCUS
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.