Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加了新Gadget,修复了一个Exploit #51

Merged
merged 10 commits into from
Oct 13, 2023

Conversation

whocansee
Copy link
Contributor

@whocansee whocansee commented Oct 13, 2023

断断续续花了四五天左右时间
修复了Exploit:LDAPTomcatRefListener
加了三种 toString payload(fastjson(全版本可用)、Jackson(全版本可用且稳定触发)、ROME(1.12.0之前可用))并详细测试了他们的可用版本和可用bullet
给上述toString payload加了一个二次反序列化的wrapper选项(SignedObject,仅可用于toString gadget)

@wh1t3p1g
Copy link
Owner

感谢提交,辛苦把console的相关逻辑重新发一个PR。当前PR主要为利用链相关,改完我合并一下

@whocansee
Copy link
Contributor Author

已修改

@wh1t3p1g wh1t3p1g merged commit 7fc092b into wh1t3p1g:master Oct 13, 2023
1 check passed
@wh1t3p1g
Copy link
Owner

已调整部分payload,不保留重复或实战意义较小的利用链

@whocansee
Copy link
Contributor Author

刚刚看了下,新payload缺少触发toString的那部分链,虽然可以生成后再自行补充,但无法直接结合Exploit使用了

@wh1t3p1g
Copy link
Owner

哪一部分,目前payload都是完整的

@whocansee
Copy link
Contributor Author

  • JsonObject、JacksonObject、signedObjectPayload 这些链都是从BadAttributeValueExpException或者包含有一个键值对两个HotSwappableTargetSource的HashMap的readObject方法入口,再调用到JsonObject/POJONode的toString方法,从而接上后半条链。单单只是序列化JsonObject/POJONode对象是不行的。
  • 另外由于FastJson、Jackson、ROME这三者序列化逻辑的不同,它们支持的bullet也是有差异的,具体过程我已经测试过,就结果来说前两者支持TemplatesImplBullet和LDAPAttributeBullet,ROME支持TemplatesImplBullet和JdbcRowsetImpl;对于Jackson和ROME来说,要稳定触发TemplatesImpl还需要一些额外的工作;我在之前的提交中已经完成了。

@wh1t3p1g
Copy link
Owner

JsonObject、JacksonObject、signedObjectPayload 这些链都是从BadAttributeValueExpException或者包含有一个键值对两个HotSwappableTargetSource的HashMap的readObject方法入口,再调用到JsonObject/POJONode的toString方法,从而接上后半条链。单单只是序列化JsonObject/POJONode对象是不行的。

这个看一下 makeReadObjectToStringTrigger

另外由于FastJson、Jackson、ROME这三者序列化逻辑的不同,它们支持的bullet也是有差异的,具体过程我已经测试过,就结果来说前两者支持TemplatesImplBullet和LDAPAttributeBullet,ROME支持TemplatesImplBullet和JdbcRowsetImpl;对于Jackson和ROME来说,要稳定触发TemplatesImpl还需要一些额外的工作;我在之前的提交中已经完成了。

目前保留下来的都是稳定触发的,ROME这个目前不更新上去了(Hessian可以修改JDK),ROME template触发昨天没调,晚上看看。

@whocansee
Copy link
Contributor Author

不好意思,一开始没注意makeReadObjectToStringTrigger,这部分没问题了

关于bullet:

  1. 目前的JsonObject1/2 payload支持三种bullet,但在JsonObject的序列化逻辑中,调用到JdbcRowsetImpl里我们想要的getter之前就会因为调用到其它getter报错而结束流程,所以实际上JsonObject1/2用不了JdbcRowSetImplBullet
    另外JsonObject2其实也应该要像JsonObject1一样,最后再用array这类Reference包裹一遍。用来绕过JsonObject#readObject()#resolveClass黑名单检查

  2. JacksonObject目前仅支持TemplatesImplBullet,实际还可以支持LdapAttributeBullet,只需要增添一个判断:仅当bulletObj instance of TemplatesImpl的时候才使用Dynamic Proxy重新包装一遍(包装后会强制使用Templates接口中的getter,类似于Rome中构造ToStringBean时传入的第一个参数类,虽然可以稳定触发TemplatesImpl,但也会导致用不了LDAPAttribute)

3.ROME也可以用TemplatesImpl,只需要增添一个和第二点中类似的,对BulletObj的判断,符合条件时传入Templates接口而不是Obj.getClass() 发之前才发现已经加上了哈哈

@whocansee
Copy link
Contributor Author

关于Jackson再补充一下,实战情景下,对于没有Spring AOP依赖的目标,这条链就用不了了。
但实际上就算没有Spring AOP依赖,光靠一个Jackson也是可以完成攻击的(比如使用LDAPAttributeBullet就不需要Spring AOP动态代理包裹)所以我建议再加一条无Spring依赖的Jackson链。

@wh1t3p1g
Copy link
Owner

更新上去了。JsonObject2 对应 fastjson2,目前 JSONObject 没有 readObject检查

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants