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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -