[high] semgrep: NetDataContractSerializer deserializes type information from its input, so data from outside can run code (CWE-502). #599

Closed
opened 2026-11-03 19:26:23 +00:00 by pruefwerk · 1 comment
Member

high Finding

Scanner: semgrep
Severity: high
Rule: cra-ai-20-csharp-unsafe-deserialization
CWE: CWE-502

Description

NetDataContractSerializer deserializes type information from its input, so data from outside can run code (CWE-502). Use a serializer bound to known types (System.Text.Json, DataContractSerializer, JSON.NET with TypeNameHandling.None).

Location

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

Code

            var ndcs = new NetDataContractSerializer();

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

## high Finding **Scanner:** semgrep **Severity:** high **Rule:** cra-ai-20-csharp-unsafe-deserialization **CWE:** CWE-502 ### Description NetDataContractSerializer deserializes type information from its input, so data from outside can run code (CWE-502). Use a serializer bound to known types (System.Text.Json, DataContractSerializer, JSON.NET with TypeNameHandling.None). ### Location **File:** `compliance-agent/rules/cra_semgrep_csharp.cs` (line 93) ### Code ``` var ndcs = new NetDataContractSerializer(); ``` --- *Fingerprint:* `78c5a7c8f627519a75403c2e8fe4f3bf8ecfa37d94af5eb2de1b7248fc56077f` *Generated by compliance-scanner* [Open in Prüfwerk / In Prüfwerk öffnen](https://pruefwerk.breakpilot.com/findings?target=6ae9aa2160f5d8045fc570a7)
pruefwerk added the pruefwerkcra:annex-iseverity:high labels 2026-11-03 19:26:23 +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#599