xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Rusty Harold <elharo AT ibiblio.org>
- To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
- Subject: Re: [XOM-interest] secure parsing
- Date: Tue, 16 Sep 2014 23:58:36 -0400
That's not going to work. XOM will reset those features after you set them.
On Tue, Sep 16, 2014 at 3:49 PM, Mike Wilson <mikewse AT hotmail.com> wrote:
> In the end I changed it to this which more closely resembles the
> suggestions
> by OWASP:
>
> XMLReader reader = XMLReaderFactory.createXMLReader();
> reader.setFeature(
> "http://xml.org/sax/features/external-general-entities", false);
> reader.setFeature(
> "http://xml.org/sax/features/external-parameter-entities", false);
> reader.setFeature(
> "http://apache.org/xml/features/disallow-doctype-decl", true);
> Builder builder = new Builder(reader);
> Document doc = builder.build(new StringReader(value));
>
> Mike Wilson wrote:
> > Never mind, having the XMLReader stuff as a dependency is ok.
> > This is the resulting code:
> >
> > XMLReader reader = XMLReaderFactory.createXMLReader();
> > reader.setEntityResolver(new EntityResolver() {
> > public InputSource resolveEntity ... {
> > return new InputSource(); // no contents
> > }
> > });
> > Builder builder = new Builder(reader);
> >
> > Thanks
> > Mike
> >
> > Mike Wilson wrote:
> > > Thanks, Elliot
> > >
> > > Is there any way to do this without introducing
> > dependencies to other
> > > libraries? Currently we only depend on XOM and use all its default
> > > behaviour.
> > >
> > > And just to double-check; you don't have any solution similar
> > > to setFeature
> > > to disable this? You mention in the tutorial that XOM controls f ex
> > > external-general-entities and external-parameter-entities.
> > >
> > > Best regards
> > > Mike
> > >
> > > Elliotte Rusty Harold wrote:
> > > > It can be done but it's not as easy as it probably should be.
> > > >
> > > > You'd need to start by setting up a SAX XMLReader
> > > configured to use a
> > > > custom EntityResolver that returns the empty string for all
> > > > entities you
> > > > don't want to load (or just for all entities). Then you pass
> > > > this to the
> > > > XOM Builder constructor.
> > > >
> > > > On Tue, Sep 16, 2014 at 5:06 AM, Mike Wilson
> > > > <mikewse AT hotmail.com> wrote:
> > > >
> > > > > [resending as subscriber]
> > > > >
> > > > > Hi,
> > > > >
> > > > > We are using XOM to communicate XML over the internet and
> > > > need to protect
> > > > > ourselves from XML hacks such as mentioned on:
> > > > >
> > > > <https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29
> > > > _Processing
> > > > > >
> > > > >
> > > > https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_
> > > > Processing
> > > > >
> > > > > What is the most straight-forward way to configure XOM to
> > > > achieve this?
> > > > >
> > > > > Currently we are just doing:
> > > > > Builder builder = new Builder();
> > > > > Document doc = builder.build(new StringReader(xmlstr));
> > > > >
> > > > > Thanks
> > > > > Mike
> > > > > _______________________________________________
> > > > > XOM-interest mailing list
> > > > > XOM-interest AT lists.ibiblio.org
> > > > > http://lists.ibiblio.org/mailman/listinfo/xom-interest
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Elliotte Rusty Harold
> > > > elharo AT ibiblio.org
> > > > _______________________________________________
> > > > XOM-interest mailing list
> > > > XOM-interest AT lists.ibiblio.org
> > > > http://lists.ibiblio.org/mailman/listinfo/xom-interest
> > > >
> > >
> > > _______________________________________________
> > > XOM-interest mailing list
> > > XOM-interest AT lists.ibiblio.org
> > > http://lists.ibiblio.org/mailman/listinfo/xom-interest
> > >
> >
> > _______________________________________________
> > XOM-interest mailing list
> > XOM-interest AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/xom-interest
> >
>
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>
--
Elliotte Rusty Harold
elharo AT ibiblio.org
-
[XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Elliotte Rusty Harold, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Elliotte Rusty Harold, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/17/2014
- Re: [XOM-interest] secure parsing, Elliotte Rusty Harold, 09/18/2014
- Re: [XOM-interest] secure parsing, Mike Wilson, 09/19/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/17/2014
-
Re: [XOM-interest] secure parsing,
Elliotte Rusty Harold, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Mike Wilson, 09/16/2014
-
Re: [XOM-interest] secure parsing,
Elliotte Rusty Harold, 09/16/2014
Archive powered by MHonArc 2.6.24.