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

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

high Finding

Scanner: semgrep
Severity: high
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 170)

Code

            var path = Path.Combine(@"C:\Plant\Reports", Request.QueryString["file"]);

Remediation

Use Path.GetFileName, normalize the result, and verify the full path remains under the base directory before reading.


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

## high Finding **Scanner:** semgrep **Severity:** high **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 170) ### Code ``` var path = Path.Combine(@"C:\Plant\Reports", Request.QueryString["file"]); ``` ### Remediation Use Path.GetFileName, normalize the result, and verify the full path remains under the base directory before reading. --- *Fingerprint:* `55d59e0c4c69810caee141f1600f8324bbac5a5329f7491da119d44b435cc874` *Generated by compliance-scanner* [Open in Prüfwerk / In Prüfwerk öffnen](https://pruefwerk.breakpilot.com/findings?target=6ae9aa2160f5d8045fc570a7)
pruefwerk added the cra:annex-ipruefwerkseverity:high labels 2026-11-05 02:27: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#861