Groovy avoid XML External Entity Injection -
i have problem xml external entity injection.
working example:
def xslt = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<!doctype [\n" + "<!entity e system \"/etc/passwd\"> ]>\n" + " <xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/xsl/transform\" version=\"1.0\">\n" + " <xsl:template match=\"/\">\n" + "\n" + " <row>\n" + " &e;\n" + " </row>\n" + " </xsl:template>\n" + " </xsl:stylesheet>" def input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<records>\n" + " <row>\n" + " <data>data1</data>\n" + " </row>\n" + "</records>" transformerfactory factory = transformerfactory.newinstance(); factory.setfeature(xmlconstants.feature_secure_processing, true); streamsource xsltstream = new streamsource(new bytearrayinputstream(xslt.getbytes())) transformer transformer = factory.newtransformer(xsltstream); streamsource ins = new streamsource(new bytearrayinputstream(input.getbytes())) bytearrayoutputstream bout = new bytearrayoutputstream() streamresult out = new streamresult(bout); transformer.transform(ins, out); print bout.tostring() as result contents of /etc/passwd file displayed. can avoid problem?
the security feature set, not working?
Comments
Post a Comment