CVE-2023-4218: Improper Restriction of XML External Entity Reference (CWE-611)
value: In Eclipse IDE versions < 2023-09 (4.29) some files with xml content are parsed vulnerable against all sorts of XXE attacks. The user just needs to open any evil project or update an open project with a vulnerable file (for example for review a foreign repository or patch).

CWE description: The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
CVSS v3 base score: 5
Published: 2023-11-09T09:15Z
Repository: https://github.com/eclipse-platform/eclipse.platform.swt
Language: Other
Files changed: bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF, bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF, bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java	
Commit date: 2023-08-03 08:17:59 +0200
Commit message: Refactor XML parsing

Diff: diff --git a/bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF
index cf3a8d15e7..4593e63162 100644
--- a/bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF
@@ -7,11 +7,11 @@ Bundle-ManifestVersion: 2
 Export-Package: org.eclipse.swt.tools.internal,
  org.eclipse.swt.tools.views
 Bundle-ActivationPolicy: lazy
 Bundle-Localization: plugin
 Bundle-RequiredExecutionEnvironment: JavaSE-17
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
  org.eclipse.swt.tools.base;bundle-version="3.106.0",
  org.eclipse.e4.ui.model.workbench;bundle-version="2.1.400",
  org.eclipse.swt;bundle-version="3.119.0",
  org.eclipse.ui;bundle-version="3.113.0",
  org.eclipse.e4.ui.di;bundle-version="1.2.600"
diff --git a/bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF
index a7fd869f0e..3adef453a2 100644
--- a/bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.swt.tools/META-INF/MANIFEST.MF
@@ -6,11 +6,11 @@ Bundle-Version: 3.110.100.qualifier
 Bundle-ManifestVersion: 2
 Export-Package: org.eclipse.swt.tools.internal; x-internal:=true
 Bundle-ActivationPolicy: lazy
 Bundle-Localization: plugin
 Bundle-RequiredExecutionEnvironment: JavaSE-17
-Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
  org.eclipse.core.resources;bundle-version="3.4.0",
  org.eclipse.jdt.core;bundle-version="3.4.0",
  org.eclipse.ui;bundle-version="3.4.0",
  org.eclipse.jface.text;bundle-version="3.4.0",
  org.eclipse.swt.tools.base;bundle-version="3.106.0";visibility:=reexport,
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index d923b2367a..df6f5c332e 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java	
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java	
@@ -15,12 +15,10 @@ package org.eclipse.swt.tools.internal;
 
 import java.io.*;
 import java.util.*;
 import java.util.Map.*;
 
-import javax.xml.parsers.*;
-
 import org.w3c.dom.*;
 import org.xml.sax.*;
 
 @SuppressWarnings("unchecked")
 public class MacGenerator {
@@ -946,11 +944,13 @@ public void setSelectorEnum(String selectorEnumName) {
 }
 
 Document getDocument(String xmlPath) {
 	try (InputStream is = createInputStream(xmlPath))  {
 		if (is != null) {
-			return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(is));
+			@SuppressWarnings("restriction")
+			Document d = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(new InputSource(is));
+			return d;
 		}
 	} catch (Exception e) {
 		//ignored
 	}
 	return null;

Vulnerable code: Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.4.0",
import javax.xml.parsers.*;

			return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(is));
Fixed code: Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0",
			@SuppressWarnings("restriction")
			Document d = org.eclipse.core.internal.runtime.XmlProcessorFactory.parseWithErrorOnDOCTYPE(new InputSource(is));
			return d;