Merge pull request from GHSA-r2hc-pmr7-4c9r
* Configured XML parsers to resist XXE attacks Signed-off-by: Kai Kreuzer <kai@openhab.org> * added fix for avmfritz Signed-off-by: Kai Kreuzer <kai@openhab.org> * added fix for sonos Signed-off-by: Kai Kreuzer <kai@openhab.org> * added fix for vitotronic and bosesoundtouch Signed-off-by: Kai Kreuzer <kai@openhab.org> * changed avmfritz to singleton pattern Signed-off-by: Kai Kreuzer <kai@openhab.org> * addressed roku binding Signed-off-by: Kai Kreuzer <kai@openhab.org> * address all uses of DocumentBuilderFactory Signed-off-by: Kai Kreuzer <kai@openhab.org> * fixed other occurrences in roku binding Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
@@ -309,6 +309,8 @@ public class DenonMarantzHttpConnector extends DenonMarantzConnector {
|
||||
if (StringUtils.isNotBlank(result)) {
|
||||
JAXBContext jc = JAXBContext.newInstance(response);
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
|
||||
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
|
||||
XMLStreamReader xsr = xif.createXMLStreamReader(IOUtils.toInputStream(result));
|
||||
xsr = new PropertyRenamerDelegate(xsr);
|
||||
|
||||
|
||||
@@ -261,8 +261,15 @@ public class DenonMarantzHandler extends BaseThingHandler implements DenonMarant
|
||||
|
||||
if (status == HttpURLConnection.HTTP_OK && response != null) {
|
||||
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder;
|
||||
try {
|
||||
// see
|
||||
// https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
|
||||
domFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
|
||||
domFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
|
||||
domFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
|
||||
domFactory.setXIncludeAware(false);
|
||||
domFactory.setExpandEntityReferences(false);
|
||||
DocumentBuilder builder;
|
||||
builder = domFactory.newDocumentBuilder();
|
||||
Document dDoc = builder.parse(new InputSource(new StringReader(response.getContentAsString())));
|
||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
|
||||
Reference in New Issue
Block a user