解决 com.alibaba.fastjson.JSONException: autoType is not support.

转载自:https://blog.csdn.net/adsl624153/article/details/79562282

叙述

升级fastjson的版本后,反序列化List集合时,报错:Exception in thread “???” com.alibaba.fastjson.JSONException: autoType is not support.

解决方案

2017年3月15日,fastjson官方发布安全升级公告,该公告介绍fastjson在1.2.24及之前的版本存在代码执行漏洞,当恶意攻击者提交一个精心构造的序列化数据到服务端时,由于fastjson在反序列化时存在漏洞,可导致远程任意代码执行。
    自1.2.25及之后的版本,禁用了部分autotype的功能,也就是”@type”这种指定类型的功能会被限制在一定范围内使用。
    而由于反序列化对象时,需要检查是否开启了autotype。所以如果反序列化检查时,autotype没有开启,就会报错。

在springboot整合redis时,要配置以下这些参数:

代码

// fastjson在2017年3月爆出了在1.2.24以及之前版本存在远程代码执行高危安全漏洞。指定序列化白名单
        ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
        ParserConfig.getGlobalInstance().addAccept("com.xiaolyuh.");
        ParserConfig.getGlobalInstance().addAccept("com.taobao.pac.client.sdk.dataobject.");

下面附上 官方给出了开启autotype的方法:enable_autotype

发布了22 篇原创文章 · 获赞 30 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/lizhengyu891231/article/details/103800351
今日推荐