Who is affected by the Fastjson vulnerability CVE-2022-25845?
Fastjson versions up to 1.2.80 allow deserialization of arbitrary classes that extend Throwable when user-controlled JSON is parsed with AutoType enabled, potentially leading to remote code execution. However, exploitation requires a suitable gadget class on the classpath, and only a low-impact data leakage gadget was publicly known.
jfrog.com
Published on jfrog.com
A few weeks ago, a new version for Fastjson was released (1.2.83) which contains a fix for a security vulnerability that allegedly allows an attacker to execute code on a remote machine. According to several publications, this vulnerability allows an attacker to bypass the “AutoTypeCheck” mechanism in Fastjson and…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the AutoType check only blocks classes not extending Throwable, so any Throwable-derived class bypasses the blacklist and can be instantiated with attacker-controlled properties.
Impact
An attacker could execute arbitrary code if a suitable Throwable-derived gadget class exists on the classpath, but public gadgets only cause low-impact data leakage, so real-world risk is limited.
What the attacker needed
Fastjson <= 1.2.80; User-controlled JSON passed to parse/parseObject; No target class specified; Suitable Throwable-derived gadget on classpath
The fix
Upgrade Fastjson to version 1.2.83 or later, or enable Safe Mode.
How it was found
- Identify a Java application using Fastjson 1.2.80 or earlier that passes user-controlled JSON to JSON.parse or JSON.parseObject without specifying a target class.
- Craft a JSON payload with an @type key set to java.lang.Exception and a second @type key set to a Throwable-derived gadget class present on the classpath.
- Include properties that will be set via setters on the gadget class, such as a name property that triggers command execution.
- Send the JSON to the vulnerable endpoint; Fastjson deserializes the gadget class and invokes its setters, potentially executing arbitrary code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Fastjson is a Java library that converts JSON text into Java objects. If an application lets users supply JSON and enables a feature called AutoType, an attacker can specify which Java class should be created. The vulnerability lets an attacker create any class that extends Throwable (Java's base class for errors), and if that class has dangerous methods, code could run.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.