[medium] semgrep: Improper restriction of XML external entity reference ('XXE') #894

Closed
opened 2026-11-05 16:55:02 +00:00 by pruefwerk · 1 comment
Member

medium Finding

Scanner: semgrep
Severity: medium
Rule: gitlab-csharp_injection_rule-XmlDocumentXXEInjection
CWE: CWE-611
CRA: cra-ai-20 — Automatisierte Sicherheitstests (Annex I)

Description

External XML entities are a feature of XML parsers that allow documents to contain references
to
other documents or data. This feature can be abused to read files, communicate with external
hosts,
exfiltrate data, or cause a Denial of Service (DoS).

XML parsers and document loaders must be configured to not resolve entities. This can be done
by:

  • Ensuring you are running a version of .NET Framework greater than 4.5.2 (released in 2014).
  • Using XDocument which disables entity resolution and is generally safe from DoS.
  • Setting XmlDocument's XmlResolver to null.

Example of safely loading an XML file using XmlDocument:

XmlDocument document = new XmlDocument();
document.XmlResolver = null;
document.Load("users.xml");

For more information on XML security, see OWASP's guide:
https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#net

Location

File: compliance-agent/rules/cra_semgrep_csharp.cs (line 121)

Code

            doc2.Load(file);

Remediation

None


Fingerprint: 98c68c47030d7c4a757d8babf380b99a89bc51565e3dd77766445cee29067d21
Generated by compliance-scanner
Open in Prüfwerk / In Prüfwerk öffnen

## medium Finding **Scanner:** semgrep **Severity:** medium **Rule:** gitlab-csharp_injection_rule-XmlDocumentXXEInjection **CWE:** CWE-611 **CRA:** cra-ai-20 — Automatisierte Sicherheitstests (Annex I) ### Description External XML entities are a feature of XML parsers that allow documents to contain references to other documents or data. This feature can be abused to read files, communicate with external hosts, exfiltrate data, or cause a Denial of Service (DoS). XML parsers and document loaders must be configured to not resolve entities. This can be done by: - Ensuring you are running a version of .NET Framework greater than 4.5.2 (released in 2014). - Using `XDocument` which disables entity resolution and is generally safe from DoS. - Setting `XmlDocument`'s `XmlResolver` to null. Example of safely loading an XML file using `XmlDocument`: ``` XmlDocument document = new XmlDocument(); document.XmlResolver = null; document.Load("users.xml"); ``` For more information on XML security, see OWASP's guide: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#net ### Location **File:** `compliance-agent/rules/cra_semgrep_csharp.cs` (line 121) ### Code ``` doc2.Load(file); ``` ### Remediation None --- *Fingerprint:* `98c68c47030d7c4a757d8babf380b99a89bc51565e3dd77766445cee29067d21` *Generated by compliance-scanner* [Open in Prüfwerk / In Prüfwerk öffnen](https://pruefwerk.breakpilot.com/findings?target=6ae9aa2160f5d8045fc570a7)
pruefwerk added the severity:mediumcra:annex-ipruefwerk labels 2026-11-05 16:55:03 +00:00
Author
Member

Prüfwerk: Die Datei liegt in Testdaten (z. B. fixtures/ oder testdata/), die von der Prüfung ausgenommen sind.

The file lies in test data (such as fixtures/ or testdata/), which is left out of the scan.

**Prüfwerk:** Die Datei liegt in Testdaten (z. B. fixtures/ oder testdata/), die von der Prüfung ausgenommen sind. The file lies in test data (such as fixtures/ or testdata/), which is left out of the scan.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: platform/pruefwerk#894