Skip to content

[Java][False negative] in XXE taint propagation from inputstreams #9893

@chmodxxx

Description

@chmodxxx
  • It appears that there is an issue in taint propagating RemoteFlowSource if it goes through InputSource + StringReader constructors , not sure if that is intentional or not because it's missing some valid flows.

I have an example vulnerable code (https://github.com/JoyChou93/java-sec-code/blob/master/src/main/java/org/joychou/controller/XXE.java#L47-L50)

           String body = WebUtils.getRequestBody(request);
            logger.info(body);
            XMLReader xmlReader = XMLReaderFactory.createXMLReader();
            xmlReader.parse(new InputSource(new StringReader(body)));  // parse xml
            return "xmlReader xxe vuln code";

This normally should be flagging as valid XXE vulnerability , however it's not with the normal XXE taint configuration.
If we add the following hack-y taintstep , the vulns will be flagged

   override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
        exists(MethodAccess m | m.getAnArgument() = pred.asExpr() and succ.asExpr() = m)
      }

Default XXE config : no findings
Screen Shot 2022-07-25 at 9 14 18 PM

After taint step :

Screen Shot 2022-07-25 at 8 56 06 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions