SLazar147150 (Community Member) asked a question.

XXE flaw with parameter: javax.xm.transform.Templates

The method reporting flaw: CWE ID 611, uses a parameter passed in: Templates template

in order to create a new Transformer instance:

Transformer transformer = template.newTransformer() ...

 

Flaw is generated for "transformer.transform" call. 

 

Many posts point at the fix with securing factory:

factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");

factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");

which works fine as long as factory, template and transformer are in same method context.

 

However with "Templates" passed in as parameter, even if template was produced from a secured factory, flaw is still generated.

 

Is flaw generated because this is a public api and Templates parameter cannot be verified? (as produced by a secured factory)

Is there a way avoid this flaw by "securing" transformer produced from Templates?

 

The method in question:

static public void applyTransform(Templates template, JAXBSource source,... Result result) {

Transformer transformer = null;

try {

transformer = template.newTransformer();

Source streamSource;

...

transformer.transform(streamSource, result); // CWE ID 611

 

thanks,

Stefan

 

 


Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.