Middleware acts as software glue between the OS and applications, simplifying development by abstracting complexity. It enables decoupling, reuse of common functions (e.g., authentication, logging), and efficient data flow. Common types include message queues (RocketMQ, Kafka), RPC frameworks (Dubbo, gRPC), caches (Redis), and web servers/gateways (Nginx, Tomcat). The document then details numerous security vulnerabilities in popular middleware. For Apache, critical flaws include the Log4j2 RCE (JNDI injection), Shiro-721 (Padding Oracle attack), and Solr RCE/XXE. Tomcat vulnerabilities involve arbitrary file writes, AJP file inclusion (Ghostcat), and weak passwords enabling WAR file uploads. JBoss and WebLogic suffer from various deserialization flaws, SSRF, and weak passwords. IIS issues include PUT uploads, short filename guessing, and parsing bugs. Redis risks include unauthorized access, SSH key injection, and remote code execution via master-slave replication. Struts2 and Fastjson are prone to OGNL injection and deserialization attacks. Finally, Spring Cloud Function has a SpEL injection RCE, and Nginx has a parsing vulnerability when using PHP-FPM.
Middleware, in simple terms, is the "software glue" or "translator" that sits between the operating system (the bottom layer) and business applications (the top layer). It abstracts away the complexity of the underlying technology, allowing developers to focus on business logic.
Based on their use cases, common types of middleware include:
I. Apache
1.1 RCE — Remote Code Execution Vulnerabilities
1.1.1 Log4j2 Remote Code Execution Vulnerability (December 2021)
1.1.1.1 How It Works
1.1.1.2 Vulnerability Verification
VulHub: Locate the injection point on the target range. We can find that /solr/admin/cores? has a parameter that accepts input.
Crafting the Payload:
If JNDI injection is present, the LDAP server will execute the payload we uploaded and then leave a record on DNSLog. We can observe that an access record is left and the preceding parameter is executed, with the Java version number echoed back to us.
1.1.1.3 Remediation
1.1.2 Shiro-721 Critical Code Execution Vulnerability (2021)
1.1.2.1 How It Works
This vulnerability stems from an issue with the rememberMe field in Apache Shiro cookies, which is encrypted using AES-128-CBC mode. An attacker can use a Padding Oracle attack to generate malicious code, construct a crafted rememberMe field, and then replay the request to the website, triggering a deserialization attack that ultimately leads to arbitrary code execution.
1.1.2.2 Affected Versions
1.2.5 <= shiro <= 1.4.2
1.1.2.3 Vulnerability Fingerprint
1.1.2.4 Exploitation Tips
1.1.2.5 Mitigation
1.1.3 Solr Remote Code Execution Vulnerability
1.1.3.1 Remote Command Execution (RCE)
1.1.3.1.1 Overview
Solr is a high-performance, full-text search server built on Lucene and developed using Java 5. It is a standalone, enterprise-grade search application server adopted by many organizations as an open-source service. The basic principle involves indexing documents via HTTP using XML into a search collection. Querying that collection is also done over HTTP, returning an XML/JSON response. Key features include efficient and flexible caching, vertical (faceted) search, hit highlighting, index replication for high availability, a powerful Data Schema system for defining fields, types, and text analysis, and a web-based administration interface.
1.1.3.1.2 Vulnerability Details
CVE-2017-12629: In versions of Apache Solr prior to 7.1 and Apache Lucene prior to 7.1, remote code execution is possible by leveraging XXE and using the Config API add-listener command to access the RunExecutableListener class. Although Elasticsearch uses Lucene, it is not susceptible to this issue. Note that an XML External Entity expansion vulnerability exists in the XML Query Parser, which by default can be exploited on any query request using the parameter deftype=xmlparser. This can be used to upload malicious data to the /upload request handler or, as a blind XXE, to read arbitrary local files from the Solr server using the FTP wrapper. Also note that a second vulnerability relates to remote code execution via the RunExecutableListener, which is available on all affected Solr versions.
1.1.3.1.3 Affected Versions
Apache Solr versions prior to 7.1.0
1.1.3.1.4 Exploitation
1.1.3.1.5 Remediation
1.1.3.2 Remote Command Execution via XXE (CVE-2017-12629)
1.1.3.2.1 Vulnerability Details
In versions of Apache Solr prior to 7.1 and Apache Lucene prior to 7.1, remote code execution is possible by leveraging XXE and using the Config API add-listener command to access the RunExecutableListener class. Although Elasticsearch uses Lucene, it is not susceptible to this issue. Note that an XML External Entity expansion vulnerability exists in the XML Query Parser, which by default can be exploited on any query request using the parameter deftype=xmlparser. This can be used to upload malicious data to the /upload request handler or, as a blind XXE, to read arbitrary local files from the Solr server using the FTP wrapper. Also note that a second vulnerability relates to remote code execution via the RunExecutableListener, which is available on all affected Solr versions.
1.1.3.2.2 Affected Versions
Apache Solr versions prior to 7.1.0
1.1.3.2.3 Exploitation
1.1.3.2.4 Remediation
1.1.3.3 Unauthorized Upload (CVE-2020-13957)
1.1.3.3.1 Vulnerability Details
In certain versions of Solr, the ConfigSet API contains an unauthorized upload vulnerability that an attacker can exploit to achieve remote code execution. The full exploitation chain: upload a configset → upload another configset based on the first (bypassing authentication checks) → create a collection using the new configset → achieve RCE via the Solr Velocity template.
1.1.3.3.2 Affected Versions
1.1.3.2.3 Remediation
Upgrade to Apache Solr 8.6.2 or higher.
1.2 Deserialization Vulnerabilities
1.2.1 Shiro-550 Java Deserialization Vulnerability (2020)
1.2.1.1 Attack Signature
The Set-Cookie header in the response contains the field rememberMe=deleteMe
1.2.1.2 Affected Versions
Apache Shiro <= 1.2.4 is vulnerable
1.2.1.3 Vulnerability Principle
1.2.1.4 Mitigation
1.3 Parsing Vulnerabilities
1.3.1 Vulnerability Cause
1.3.2 Exploitation
1.3.3 Remediation
1.4 Directory Traversal
1.4.1 Vulnerability Cause
1.4.1 Exploitation Method
1.4.1 Remediation
2. Tomcat
2.1 Introduction to Tomcat
Tomcat is a Servlet container developed by the Jakarta project under the Apache Software Foundation. Following the technical specifications provided by Sun Microsystems, it implements support for Servlets and JavaServer Pages (JSP), and offers unique features as a web server, such as the Tomcat management and control platform, security realm management, and Tomcat valves. Since Tomcat itself includes an embedded HTTP server, it can also be regarded as a standalone web server.
Important files:
2.2 Arbitrary File Write Vulnerability
2.2.1 Vulnerability Details
2.2.2 Affected Versions
2.2.3 Exploitation
2.3 AJP File Inclusion Vulnerability (CVE-2020-1938)
2.3.1 Vulnerability Details
2.3.2 Affected Versions
2.3.3 Exploitation
2.4 Weak Password / WAR File Upload
2.4.1 Vulnerability Details
Tomcat supports deploying WAR files from the management backend, allowing an attacker to drop a webshell directly into the web directory. Accessing the backend, however, requires that the user holds the appropriate permissions.
2.4.2 Affected Versions
2.4.3 Exploitation
III. JBoss
3.1 JBoss Deserialization
Use the downloaded tool for detection: java -jar DeserializeExploit.jar
3.1.1 JBoss 5.x/6.x Deserialization Vulnerability (CVE-2017-12149)
3.1.1.1 Principle
The ReadOnlyAccessFilter in JBoss's HttpInvoker component deserializes the data stream from the client without performing any security checks.
3.1.1.2 Access URL
http://192.168.1.102:8080/ and http://192.168.1.102:8080/invoker/readonly — a 500 response indicates the vulnerability exists.
3.1.1.3 Download the exploitation tool to get a reverse shell:
http://scan.javasec.cn/java/JavaDeserH2HC.zip
3.1.2 JBoss 4.x JBossMQ JMS Deserialization Vulnerability (CVE-2017-7504)
3.1.3 JBoss Remote Deployment Vulnerability
4. WebLogic
4.1 Deserialization
4.1.1 XML Decoder Deserialization Vulnerability (CVE-2017-10271)
4.1.1.1 Vulnerability Details
WebLogic's WLS component contains an XMLDecoder deserialization vulnerability — simply POST a crafted XML payload to achieve RCE.
4.1.1.2 Affected Versions
4.1.1.3 Reproduction
Potentially vulnerable paths:
4.1.1.4 Vulnerability Verification
4.1.2 XML Weblogic Unauthorized Access - CVE-2020-14882 && Command Execution - CVE-2020-14883
4.1.1.1 Vulnerability Details
4.1.1.2 Affected Versions
4.1.1.3 Vulnerability Reproduction
4.2 SSRF Vulnerability (requires the UDDI component selected when installing Weblogic)
4.2.1 Vulnerability Details
4.2.2 Affected Versions
4.2.3 Vulnerability Reproduction
4.2.4 Vulnerability Fix
4.3 Weak Passwords
Login address: http://192.168.190.136:7001/console/login/LoginForm.jsp
weblogic/weblogic weblogic/Oracle@123
Combined with a file upload to get a shell
Vulnerability Fix
5. IIS
5.1 PUT Vulnerability
5.1.1 Vulnerability Cause
5.1.2 Exploitation
5.1.3 Vulnerability Fix
5.2 Short Filename Guessing
5.2.1 Vulnerability Cause
5.2.2 Exploitation
5.2.3 Vulnerability Fix
5.3 Parsing Vulnerability
5.3.1 Vulnerability Cause
5.3.2 Vulnerability Fix
5.4 (MS15-034) HTTP.sys Remote Code Execution Vulnerability
5.4.1 Vulnerability Details
5.4.2 Vulnerability Detection
5.4.3 Exploitation
5.4.4 Vulnerability Fix
6. Redis
6.1 Redis Introduction
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types, including string, list, set, zset (sorted set), and hash. All these data types support push/pop, add/remove, intersection/union/difference, and richer operations, and these operations are all atomic. On top of this, Redis supports sorting in various ways. Like memcached, data is cached in memory for efficiency. The difference is that Redis periodically writes updated data to disk or appends modification operations to an append-only log file, and on this basis implements master-slave synchronization. Default port 6379.
6.2 Redis Unauthorized Access
6.2.1 Vulnerability Details
6.2.2 Prerequisites
6.2.3 Exploitation
6.3 Redis key-based SSH login
6.3.1 Vulnerability details
6.3.2 Prerequisites
6.3.3 Exploitation
6.4 Remote master-slave replication RCE
6.4.1 Vulnerability principle
6.4.2 Impact
6.4.3 Exploitation
6.5 Local Redis master-slave replication RCE reverse shell
6.5.1 Vulnerability principle
6.5.2 Exploitation
6.6 Security hardening
Redis security settings: after configuring, reload the config file to restart Redis.
7. Struts2
7.1 S2-001 command execution
7.1.1 Vulnerability details
7.1.2 Vulnerability detection
7.1.3 Exploitation
7.2 S2-005 command execution
7.2.1 Vulnerability details
The S2-005 vulnerability originates from S2-003 (affected versions: below Struts 2.0.12). Struts2 parses each HTTP parameter name as an OGNL statement to execute (think of it as Java code). OGNL expressions access Struts objects through #, and the Struts framework filters the # character to prevent security issues. However, by using Unicode encoding (\u0023) or octal (\43), the security restriction is bypassed. For S2-003, the vendor patched it by adding a security configuration (disabling static method calls and class method execution, etc.), but the security configuration itself was bypassed, leading to the vulnerability again. An attacker could use an OGNL expression to flip these two options back open. In other words, the S2-003 patch effectively locked the door, but left the key inserted in the lock — the security options that were meant to be disabled could be re-enabled through the whitelisted OGNL expression.
Summary
7.2.2 Exploitation
7.3 S2-007 command execution
7.3.1 Exploitation
7.4 S2-008
7.4.1 Vulnerability details
7.4.2 Exploitation
8. Fastjson
8.1 How to determine whether it is fastjson
8.2 Deserialization
8.2.1 Vulnerability details
8.2.2 Prerequisites
8.2.3 Exploitation
9. Spring Cloud
9.1 Introduction to Spring Cloud
Spring Cloud is a development framework based on Spring Boot for building and deploying distributed systems. It provides a set of tools and frameworks that help developers rapidly build cloud-native applications, along with robust capabilities such as service governance, load balancing, routing, and configuration management. Spring Cloud simplifies the development and deployment of microservices, improving development efficiency and software quality.
9.2 SpEL Remote Code Execution Vulnerability (2022)
9.2.1 Vulnerability details
9.2.2 Vulnerability principle
9.2.3 Affected versions
9.2.4 Exploitation
9.2.5 Remediation
10. Nginx Parsing Vulnerability
10.1.1 Vulnerability details
10.1.2 Payload