Engine_XalanJ

Version 50.1 by Nicolas Gregoire on 2012/01/11 23:52

Xalan-J is a Java based XSLT engine by the Apache Project.

Supported version

1.0

Command line

$> java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl

Note : xml-apis.jar, xercesImpl.jar and xalan*.jar must be in the $CLASSPATH

Identification strings

xsl:vendor-urlhttp://xml.apache.org/xalan-j
xsl:vendorApache Software Foundation
xsl:version1.0

Special features

  • Java properties disclosure
  • Java environment disclosure
  • Java code execution
  • OS command execution
  • File creation
  • JDBC connectivity

Java properties disclosure

The xsl:system-property() standard function can be called with non standard arguments, mapped to Java properties. In this example, the name of the Java properties is stored in a separate XML file (properties.xml). The XSLT code will, for each property, display its name and its value.

NamespaceFunctionPoCSample output
http://www.w3.org/1999/XSL/Transformsystem-property()xalanj-java-properties.xslxalanj-java-properties-output.txt

Java environment disclosure

The checkEnvironment() extension function (documented here) will display some information about the execution context (including available packages, paths, versions, ...).

NamespaceExtension functionPoCSample output
http://xml.apache.org/xalancheckEnvironment()xalanj-checkenv.xslxalanj-checkenv-output.txt

Java code execution

The attached code will display the current date using a newly created "java.util.Date" object. This should be enough to demonstrate Java code execution.

NamespaceExtension functionPoCSample output
http://xml.apache.org/xalan/java/java.util.Datenew()xalanj-java-date.xslCurrent date:
Wed Jan 11 22:45:07 CET 2012

OS command execution

Once Java code execution is possible, it is trivial to execute arbitrary OS commands using the java.lang.Runtime class. The attached PoC will not read the output of the executed command (because loops are hard in XSLT). But this is not a problem if a reverse-shell have already been started, isn't it ;-)

NamespaceExtension functionPoC
http://xml.apache.org/xalan/javagetRuntime() = exec()xalanj-reverse-bash.xsl

Note : as arrays are not a native type in XSLT, we create one via split() before passing it as an argument to exec(String[] cmdarray).