xxl-job icon indicating copy to clipboard operation
xxl-job copied to clipboard

xxljob-2.4.0 模版注入

Open unam4 opened this issue 1 year ago • 0 comments

客户端使用xxl-job-core 在这个com.xxl.job.core工具类里用一个可以利用的点。 com/xxl/job/core/util/JdkSerializeTool.java 反序列化 image

可控而且是public。 com/xxl/job/core/util/ScriptUtil.java 写文件,执行命令 image image

com/xxl/job/core/util/FileUtil.java

image

等等。都是可以直接调用。 很容易可以想到利用方式就是写文件,或者代码执行,任意文件删除。 image

xxljob使用了freemarker模版进行渲染,渲染路径为classpath下的/templates/

image

freemarker版本是2.3.32,也就是说通过文件写入恶意的模版文件,就能造成代码执行。

image

全局拦截器的代码, image

对应的实现类。 image

获取这个,然后判读用户 image

进行16进制处理。

image image

然后判断用户是否存在,若果存在,在继续判断密码的md5值是否等于数据里对应的值。看来是无法绕过拦截器的。这样看来其实,token也是一个隐患,永不过期,嗅探到数据包,也是可以永久使用。

复现

poc ${"freemarker.template.utility.ObjectConstructor"?new()("org.springframework.expression.spel.standard.SpelExpressionParser").parseExpression("T(java.lang.Runtime).getRuntime().exec("open -a calculator")").getValue()}

image image

执行后修改了登录页的模版。再次打开就能造成代码执行。

修复建议

升级版本,做好过滤。

unam4 avatar Feb 20 '24 15:02 unam4