Struts2-045 vulnerability handling pitfalls (upgrade Struts2.5 requires special attention to the configuration ),
Recently, a problem occurred in the company's ssh construction of old projects. People caught the vulnerability and obtained the permission. Fortunately, the white guest did not perform much damage, the reason was that the Struts2 framework had a vulnerability and shared the pitfalls it encountered when solving it.
Methods for detecting Struts2 vulnerabilities:
Can download K8 great god Struts vulnerability detection tool http://qqhack8.blog.163.com/blog/static/1141479852014631102759126/
Hazards of the 045 vulnerability:
Almost unconditionally, all URLs are exploited by this vulnerability, even if you do not use the upload function
Cause Analysis of 045 vulnerabilities:
Read more
Versions involved in the 045 vulnerability:
2.3-2.5, that is to say, 2.5.10 and above are all secure versions. We use 2.3.28.1 in our project, so we are caught with the vulnerability.
Solution:
The point is: Upgrade the jar package to Struts2 to a secure version. Here I use the latest version 2.5.14.1 on the official website.
Attachment official download link http://struts.apache.org/download.cgi#struts2514.1
Pitfalls:
This is mainly about the configuration required when Struts 2.3 is upgraded to 2.5. There are several configurations in 2.5 that need special attention.
1. Required jar packages for Struts 2.5
2. Modify the core filter of web. xml
Core interceptor
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
Changed to (A. ng path is missing)
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
3. Modify the header DTD constraint of struts. xml
The constraint is changed to 2.5. Otherwise, the <global-allowed-methods> label cannot be used.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd">
4,Add the range of dynamic methods in struts. xml
Add Tag
<global-allowed-methods>regex:.*</global-allowed-methods>
Note that the label is in the <package> label order.Write in strict order
Generally, it is on the <global-exception-mappings> label.
Note: if there is any infringement, please reply and delete it immediately