Skip to content

Commit 4c44252

Browse files
Address security concerns raised via github issue
1 parent fa33914 commit 4c44252

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/BpmnXMLConverter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ public BpmnModel convertToBpmnModel(InputStreamProvider inputStreamProvider, boo
276276
if (xif.isPropertySupported(XMLInputFactory.SUPPORT_DTD)) {
277277
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
278278
}
279+
280+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_DTD)) {
281+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
282+
}
283+
284+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_SCHEMA)) {
285+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
286+
}
279287

280288
if (validateSchema) {
281289
try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {

modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ public CmmnModel convertToCmmnModel(InputStreamProvider inputStreamProvider, boo
165165
if (xif.isPropertySupported(XMLInputFactory.SUPPORT_DTD)) {
166166
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
167167
}
168+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_DTD)) {
169+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
170+
}
171+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_SCHEMA)) {
172+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
173+
}
168174

169175
if (encoding == null) {
170176
encoding = DEFAULT_ENCODING;

modules/flowable-dmn-xml-converter/src/main/java/org/flowable/dmn/xml/converter/DmnXMLConverter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ public DmnDefinition convertToDmnModel(InputStreamProvider inputStreamProvider,
229229
if (xif.isPropertySupported(XMLInputFactory.SUPPORT_DTD)) {
230230
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
231231
}
232+
233+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_DTD)) {
234+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
235+
}
236+
237+
if (xif.isPropertySupported(XMLConstants.ACCESS_EXTERNAL_SCHEMA)) {
238+
xif.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
239+
}
232240

233241
if (validateSchema) {
234242
try (InputStreamReader in = new InputStreamReader(inputStreamProvider.getInputStream(), encoding)) {

modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/serialization/StringToXmlDocumentDeserializer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public class StringToXmlDocumentDeserializer implements InboundEventDeserializer
3232
public Document deserialize(Object rawEvent) {
3333
try {
3434
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
35+
36+
documentBuilderFactory.setValidating(false);
37+
documentBuilderFactory.setExpandEntityReferences(false);
38+
documentBuilderFactory.setXIncludeAware(false);
39+
documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
40+
documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
41+
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
42+
documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
43+
44+
3545
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
3646
try (InputStream inputStream = new ByteArrayInputStream(convertEventToBytes(rawEvent))) {
3747
Document document = documentBuilder.parse(inputStream);

0 commit comments

Comments
 (0)