今天我们的系统被安全部门通报说请求的接口存在gatling-Fastjson 反序列化漏洞。系统依赖的fastjson是1.2.83。
我们在Controller里使用getKv()方法获取传递的参数,然后出来完业务后,通过renderJson(data)的方式返回给调用者json数据。在ConfigMain的configConstant()里没有配置其他json工厂,采用的是JFinalJson。我查看了Controller里的getKv方法,JsonRequest的构造函数里是这么写的:
public JsonRequest(String jsonString, HttpServletRequest req) { Object json = com.alibaba.fastjson.JSON.parse(jsonString); if (json instanceof com.alibaba.fastjson.JSONObject) { jsonObject = (com.alibaba.fastjson.JSONObject)json; } else if (json instanceof com.alibaba.fastjson.JSONArray) { jsonArray = (com.alibaba.fastjson.JSONArray)json; } this.req = req; }
这里第一行直接调用fastjson的JSON.parse方法解析json串,这里有没有可能存在触发gatling-Fastjson 反序列化漏洞的可能。琢磨了一上午了,我本地又没办法重现。就来这里请教一下!
我们之前给某Y 做的系统就是有源码扫描,直接匹配源码的。我们是直接拿掉了fastjson改为了HuToolJson,虽然fastjson好用性能强,不过系统的瓶颈也不在这里,其他 json 工具也是够用了。
如果你项目没有用到fastjson的骚用法,可以直接上fastjson2,没啥影响