[medium] semgrep: A file path is built from request input — "..\" in it reaches files outside the intended folder (path traversal… #895

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

medium Finding

Scanner: semgrep
Severity: medium
Rule: cra-ai-20-csharp-path-traversal
CWE: CWE-22

Description

A file path is built from request input — ".." in it reaches files outside the intended folder (path traversal, CWE-22). Take only the file name (Path.GetFileName) and check the full path stays under the base folder.

Location

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

Code

            var text = File.ReadAllText(@"C:\Plant\Logs\" + Request["name"]);

Remediation

None


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

## medium Finding **Scanner:** semgrep **Severity:** medium **Rule:** cra-ai-20-csharp-path-traversal **CWE:** CWE-22 ### Description A file path is built from request input — "..\" in it reaches files outside the intended folder (path traversal, CWE-22). Take only the file name (Path.GetFileName) and check the full path stays under the base folder. ### Location **File:** `compliance-agent/rules/cra_semgrep_csharp.cs` (line 173) ### Code ``` var text = File.ReadAllText(@"C:\Plant\Logs\" + Request["name"]); ``` ### Remediation None --- *Fingerprint:* `a0cdbb26b8f26ffacb1a51f5c2a6743e3adfb85663ac7d26a0393026e2b21aef` *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:04 +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#895