Fastjson 1.2.x Remote Code Execution Without Gadget Vulnerability Notice

Overview

Recently, NSFOCUS CERT detected that a Fastjson 1.2.x remote code execution vulnerability without gadget was disclosed online; Due to the defects in the internal type parsing logic of Fastjson deserialization, unauthenticated attackers can construct specially crafted malicious JSON data to bypass the traditional autoType black and white list protection mechanism, and remote code execution can be achieved without any third-party gadget exploitation classes in the target service classpath. The CVSS score is 9.8. At present, the vulnerability details and PoC have been made public, and wild exploitation has been found. Relevant users are requested to take measures to protect themselves 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.

Scope of Impact

Affected version

  • 1.2.68 <= Fastjson1.x <= 1.2.83

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

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 used through pom.xml:

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

Mitigation

Official upgrade

At present, the official security update for Fastjson1.x has not been released yet. It is recommended that affected users migrate to Fastjson2.x after evaluating business compatibility. Download link: https://github.com/alibaba/fastjson2/releases

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); 
  1. Add JVM startup parameters:
-Dfastjson.parser.safeMode=true 

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

  1. Configure through the fastjson.properties file:

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

fastjson.parser.safeMode=true

Refer to 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.

Product Protection

The historical rules of NSFOCUS WEB Application Protection System (WAF) supports this vulnerability protection: 27004897 fastjson_remote_code_exec_strict

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.