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.
## 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)
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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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
Remediation
Use Path.GetFileName, normalize the result, and verify the full path remains under the base directory before reading.
Fingerprint:
55d59e0c4c69810caee141f1600f8324bbac5a5329f7491da119d44b435cc874Generated by compliance-scanner
Open in Prüfwerk / In Prüfwerk öffnen
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.